Project Feeder
Ever wanted to feed your pets while away from home, or just from the comfort of your sofa? If so, this project is for you! Project Feeder is an open source project that allows you to feed your pets automatically, or manually from your phone or pc. You can also follow a livestream and keep track of the eating behaviour of your pet.
Before you start!
This project is a task made for college and was time bound, so it is very "work in progress". This is why I'm aware that there are things that can be improved and may be updated in the future. I encourage you to be creative, improve and expand on this concept.
To start off we will go over the requirements to build this project. You will really need the skills and tools listed below.
Maker skills:
- 3D-printing or access to a printing service
- Soldering
- Basic electronics knowledge
Tools:
- 3D-printer
- Soldering iron
- Hot glue gun, or other glue that works 3D-printer filament compounds
- Screwdrivers
Supplies
The total cost of building this project is around €120 depending on where you buy the part and what kind of discounts you get.
Important:
Some parts are marked with "Unique", it means it is specific to the structural design of the build and you need an exact copy of that part.
Raspberry Pi 4 Model B / 2GB + 16GB (min. requirement) Micro SD card
Stock on Rasberry Pi is very limited at the moment, this will need some looking around.
12V 60W Power Supply Adapter
https://www.banggood.com/AC-100-240V-to-DC-12V-5A-...
5.5mm X 2.1mm DC Power Supply Jack Socket (Unique)
https://www.banggood.com/10pcs-5_5-x-2_1mm-DC-Powe...
DC-DC 12V To 5V 3A Buck Step Down Power Module (Unique)
https://www.banggood.com/LM2596-DC-DC-Voltage-Regu...
42mm 12V Nema 17 Two Phase Stepper Motor
https://www.banggood.com/42mm-12V-Nema-17-Two-Phas...
L298N Dual H Bridge Module
https://www.banggood.com/Wholesale-L298N-Dual-H-Br...
GY6180 VL6180X Time Of Flight Distance Sensor
https://www.banggood.com/GY6180-VL6180X-Time-Of-Fl...
Infrared Obstacle Avoidance Sensor (x3)
https://www.banggood.com/3Pcs-Infrared-Obstacle-Av...
USB camera
https://www.banggood.com/Electronic-Camera-Module-...
Backlight 16×2 LCD, 8051 microcontroller I2C
https://www.hobbyelectronica.nl/product/1602-lcd-d...
Bidirectional level shifter
https://www.banggood.com/nl/Two-Channel-IIC-I2C-Lo...
Common value resistors (10k, 220R, 470R)
https://www.banggood.com/Wholesale-Geekcreit-600pc...
LED's (x2)
Diodes (x2)
12V ON/OFF switch (Unique)
https://www.banggood.com/5pcs-12V-Round-Rocker-Tog...
Nuts: 3x8mm, 3x10mm, 3x12mm
Flashing the SD Card
For this step you will have to flash your SD card with the provided image:
https://thomy.stackstorage.com/s/KbCfVgoU0t8gU3C
The image comes equiped with a pre-build apache web server, database and code to interface with the feeder. So you don't have to do anything that involves setting up the software.
If you want to take a look into the code, you can get all the required code from:
https://github.com/VanIseghemThomas/ProjectFeeder
Make sure you know how to properly flash the SD card or do not interrupt the process because that can result in a corrupted card. For flashing the card I used software called Win32DiskManager. An other program I know works and is a bit more user friendly is called Ethcer. Both work equally well.
SSH Into the Pi
When the flashing is done you can now put the SD card into the pi and power it on. Make sure you're plugged into your pi using an ethernet cable. Now you should be able to connect to it using SSH with ip 169.254.10.1 . I use a program called PuTTY, but if you don't feel like installing software you can always type the following command into the command prompt:
ssh feederpi@169.254.10.1
Now open a session. When connecting for the first time you will encounter a warning, you can ignore that and just continue. You will be asked to log-in as a user and after that the password, for this image use the following credentials:
- User: feederpi
- Password: Redeef1
The 'pi' user is also active but you won't be able to log-in as it. This is because it is set up to automatically log-in on power and run the program. This is why you will encounter the following when logged in:
[sudo] password for feederpi:
Just press crtl+c and you should have a shell now.
Now type the following:
sudo -i
Now you are logged in as root.
Setting Up Wifi
Now you are logged in as root and can type:
wpa_passphrase "Your SSID" "Your Password" >> /etc/wpa_supplicant/wpa_supplicant.conf
To check if your configuration was added correctly type the following. You can also delete the plain text password for security if you want, but make sure to save the changes upon exit.
nano /etc/wpa_supplicant/wpa_supplicant.conf
Now you can reboot your pi by typing:
reboot now
Now give the pi some time to boot and log back in with SSH like before, to see if you've got a connection to wifi you type:
ip a
Under the wlan0 interace you should see something similar with an ip-address, this means you've succesfully connected to your wifi. Later when everything is hooked up, the software will display this to an LCD.
Printing the Parts
The parts you will need for this project are found here:
https://www.thingiverse.com/thing:4459996
Printing all these parts will take a while, so you'll need some patience.
These are the settings I used (PLA):
- Layer height: 0.3mm
- Print speed: 50-60mm/s
- Nozzle temp: 200°C
- Bed temp: 60°C
There's not much to say about this except, have fun printing.
Assembling the Parts (intro)
Alright now we go on to assembling everything. Before I explain all of it I'll go over some things to keep in mind and that will help you get this done.
TIP 1:
I've decided to make all the holes 2.5mm except 3mm like the bolts. This is so you can tap a thread by screwing in the bolts and eliminates the need of nuts. Getting the bolt in is pretty difficult, use your soldering iron to widen the top, this will make it easy to get the bolt in and start screwing.
TIP 2:
If like me you are running low on bolts, just only screw in diagonal pairs. This saves a lot of them and works fine.
Assembling the Top (Dispenser)
The parts are layed out as in the picture.
They're hold together by the so called 'plates'. One of the plates assembles to your stepper motor.
Make sure that the top of the bolts are flush with the surface, else the feeding will block up. You should use the 3x8mm bolts for this and the "Stepper_offset" model between the stepper and the outside of the plate.
Now put mill on to the stepper, it should go on fairly easy. If not, you could use some vaseline.
The rest is pretty straight forward, just take a screw where you find a hole.
Assembling the Top (Container)
Here you see how I made my container. The canister is originaly used for dried pieces of union.
At the top, you want to attach the TOF-sensor, this one will be used to measure how much food there is left in the container. In the pictures you can see how I attached it. First I melted the holes for the pins with my soldering iron, then glued the sensor in place with some hot glue while the cables are connected.
For closing the container I made 2 holes with my soldering iron and screwed in 2 bolts. A rubber band, zip tie or wire can all be used to close it that way.
Assembling the Bottom
For the placement of the different modules reference the pictures, they are pretty self explainatory. Part of these pictures already have wiring in them, you should look past that for now. The pictures where taken in the middle of developping this project. Initially the plan was to put in a load cell and weigh the food but due to my load cell amp breaking at the last moment, I had to scrap that feature and replace it with a video live stream which is also pretty neat. The option is always there to add a load cell, but you'll have to dig into the code and edit some stuff.
Electronics, Sensors and Actuators
Now it's time to put the soldering iron on. I've provided 2 representations of what you need to do, one standard electrical schematic, one visual representation. I highly suggest you use the electrical schematic because it gives a lot more insight on how everything works and is connected to eachother in my opinion. The only reason the other one is here, is because it was mandatory. Reason I say this, is because there isn't a whole lot of space for cables, so you'll have to be effecient with wiring GND, +5V, etc. which depends on how you want to run your cables. So don't wire everything exactly to each other like the schematic, it will work but won't fit.
For the switch you can see I wired up all 3 of the leads, this is because the switch comes with a built-in LED that indicates if power is switched on. The 2 uncolored leads act as the switch, the colored lead goes to GND.
In general this is the order I wired everything:
- Power section: power jack, h-bridge, boost buck converter, switch
- Raspberry Pi (See next step for more info)
- IR-sensors
- LED's
- Stepper inputs
- I2C portion: 3.3V, SDA, SCL
It's not essential but usefull to have a prototyping pcb laying around to solder to like I did.
Also don't forget to hook up the camera to a USB port of the pi.
Important:
Make sure to adjust the boost buck converter to 5V before hooking up the 5V portion of the circuit. Else you could run the risk of frying everything. To adjust this you turn the potentiometer and look at the voltage readout on the screen.
Electronics, Raspberry Pi
Due to limitations in the software to draw the schematic I wasn't able to draw how to hook up the raspberry pi.
For +5V you could just wire to the 5V pin of the pi, but this bypasses safety such as the fuse. If you look on the bottom you should see some pads that are labeled as TPxx, in our case we are looking for TP1 or TP2. Solder your +5V lead to one of them but be carefull not to bridge with other traces. This will most likely also void the warranty. I've personally tried hooking it up to both test pads and came to the conlusion it is probably the easiest and safest to use TP2, its away from other exposed pads and doesn't have a lot of traces around it.
For GND just take one of the pins on top like the schematic shows, this is perfectly fine now.
Testing the Electronics
When everything is hooked up correctly it's good practice to first test everything before assembling everything completely.
Here a checklist:
- IPV4 address shows up on the lcd
- Able to connect to IP through the browser
- Able to turn the stepper by "feeding" and see LED's light up
- Container status reads and updates
- Live stream from camera
- Detecting eating events
Troubleshooting:
Here I list some of the problems I got into and how to fix them.
- My LCD lights up but displays nothing:
1) At the time of writing this, the pi needs about 2 minutes to fully boot so you have to give it some extra time.
2) You didn't connect you LCD correctly. You can see if you connected it correctly by typing the following command in a shell:
sudo i2cdetect -y 1
This has to return 2 addresses: 0x27 (=LCD) and 0x29 (=TOF sensor). If 0x27 doesn't show up you've got to check the wiring of the lcd. If both dont show up, you have to check the wiring of the SDA and SCL pins. E.g. check if you swapped the two by accident. Worst case you did something wrong with the 2 individual components or something broke.
- My LCD is stuck at "Connecting to WiFi"
This means your pi is stuck trying to connect to one of the networks you configured to connect to. This means either you are not in range of the acces point or you did something wrong while configuring e.g. a typo. In that case go back to "Setting up WiFi" and go over it again.
The software is also set up to connect to home networks with an IP address that starts with "192.168". If your network is set up with an other private range such as "10.0" or "172.16" you will have to go into /home/pi/project/main.py and in the function get_ips() change: if "192.168" in ip --> if "Your private range here" in ip.
- My LCD displays the ip but I can't connect:
1) Make sure you are connecting to the 192.168.X.X ip, the other ip 169.254.10.1 is always configured to connect over ethernet straight to your pc. This will not work if you are not plugged in.
2) Make sure you're on the same network, or you've enabled port forwarding on your network if you want to access the feeder from outside it's network.
- The stepper shakes and doesn't turn:
This means you didn't correctly connect the inputs or outputs of the dual H-bridge. Try swapping them around untill it works.
Completion
Now you've figured out how to get everything running, it's time to put everything together. I had to put the 2 parts together with tape, this because the the design of the holes isn't sturdy enough to hold the tension and it cracked for me. This is one major thing to be improved in the future. A cleaner option is to just glue the two parts together but this could be a problem when something inside breaks and you want to get access to the inside. That's why I went with good old electrical tape.
When you go to the website you should be greeted with a dashboard where you can do things like manualy feeding, check the status, look at data and add presets.
Extra: Chrome Extension
If you don't feel like browsing to the dashboard and just want to quickly check the status or feed you can use the Chrome extension. Due to it not being in the official Chrome web store, you'll have to load it like you would develop such a package.
First make sure you download the Feeder Extension folder from the github directory:
https://github.com/VanIseghemThomas/ProjectFeeder
Go to the following URL:
chrome://extensions/
Once there, enable developer mode and load the extension folder. Now it should appear as an extension.
If it doesn't appear in your Chrome bar you can find it in the Chrome menu.
The Software
If you like to tinker with the software or for some reason need a new copy of a file, all the files you need are found in the GitHub respository I made: https://github.com/VanIseghemThomas/ProjectFeeder
I also provided a EER-schematic for the database, in case you feel like adding features to the API. A dump of the database can be found in the GitHub repository aswell. All the backend code is writen in Python. Flask is used for routing and Socket.io for websockets.