Introduction: Automatic Chicken Feeder
Maybe you had this feeling already, you are on the way to your job and then you think about how you forgot to give your chickens a bit of breakfast too. I think you can problably use a Automatic Chicken feeder then! With this IoT-device your chickens will always have their breakfast on time!
Before we get started with building this awesome thing, I will first introduce myself. I am Bertil Vandekerkhove (I know it is a weird name, but just listen to Google Translate. It does the job almost perfect) and I'm a student at Howest studying NMCT! This instructable is a step-by-step guide on how I build my first years final project. I hope you will enjoy it and let's get started!
Step 1: Getting the Required Materials
In the above list you can see all the materials required for this project.
Step 2: Building the Enclosure
Before we can actually build the enclosure we need to get some material to build it from. I use 8mm MDF, because it is pretty cheap and easy to use. If you are going to recreate this you can choose whatever type of wood you want or even make it out of metal. But just make sure that the measurements are correct for your thickness of wood.
The sheets of wood you will need are (in cm):
- 2 x (100,8 x 44,6) - side panels
- 1 x (50,8 x 100) - back panel
- 1 x (50 x 80) - front panel
- 1 x (50 x 40) - inner front panel
- 1 x (51,6 x 50) - top panel
- 2 x (3.6 x 8) - smaller side panels
- 1 x (8 x 51,6) - smaller frontpanel
- 1 x (11,4 x 49,8) - plank for the scale
- 1 x (50 x 20) - front panel for shelf
- 2 x (50 x 25) - funnel
- 2 x (30 x 35) - funnel
- 1 x (50 x 38) - top panel for shelf
- 1 x (18 x 5) - shelf for motor
And then for the foodslide we will need (in cm):
- 1 x (30 x 16)
- 2 x (20 x 16)
- 1 x (30 x 21,6)
We start off with the side panels, attach two help blocks per panel. On the top of the panel you place the help block on 13cm from the side and on the bottom on 8cm from the side. Repeat this for the other side panel
After that take the back panel and add a help block in the four corners.
Now take te side panels and the back panel and screw them togheter using some 3,5mm screws, after that screw the shelf panels into place using the bottom help block. Then take the inner front panel and screw it in the top help blocks. Now if you did everything right it should look like picture 3.
After this we are going to make the funnel for the food. Take the right panels en saw them into triangles, the 50x25 panels need to be 50x24 triangles and the 30x35 panels 30x32 triangles. Make sure the triangles don't end in a point but with a 2cm side.
To make the funnel set the pieces up next to eachother and hold them togheter with some duct tape.
To attach the funnel into the enclosure attach some help blocks on the inside at 22 cm from the top as shown in picture 7. After this drop down the funnel into place and screw it into the help blocks. You can fill the gaps with some duct tape.
Then you take the motor shelf, the pvc pipe and the motor itself. Position the hole of the pvc pipe under the funnel and attach it to the shelf with some zip ties, do the same thing for the motor. After this use some help blocks to attach the shelf to the back panel.
After this take the panels to make the foodslide and attach the back panel of it to the motor shelf and the bottom plate to the enclosure.
Now take the big front panel en attach it to the enclosure with some hinges and install a magnetic lock, do the same for the top panel.
Step 3: Make the Scale
To measure how many food their is left in de feeder we need a scale made of a load cell. Take the load cell and screw it into a little piece of wood and then take the scale plank and attach it to the other side of the load cell using some bolts and nuts. Make sure it is centered and levelled. After this mount the scale into the enclosure and use the smaller side- and front panel(s) around it.
Step 4: Setting Up the Raspberry PI (RPi)
To use the Rpi you will need an OS for the RPi, I chose to use Rapsbian. Download the file from the website and then use Etcher to get it onto the SD-card. After this is done go to the SC-card and search fot the file "cmdline.txt" and add at the end of the line : "ip=169.254.10.1". Then you can use Putty to make a SSH-connection with the RPi by typing 169.254.10.1 in Putty at Host Name and clicking on Open. When you first boot your RPi you have to log in with the next credentials: username = pi and password = raspberry.
To connect with your home network you need to type the following code:
echo “password” | wpa_passphrase “SSID” >> /etc/wpa_supplicant/wpa_supplicant.conf
Type sudo nano /etc/wpa_supplicant/wpa_supplicant.conf and check if your network is there.
Close the wpa_cli with quit or Ctrl+D.
Check if you have a vaild IP-address with:
ip addr show dev wlan0
To round up test your connection with:
Step 5: Making the Circuit
In the pictures above you can see the layout of the printboards, make sure when you make these you don't short anything. I chose to put the T-cobbler, the DRV8825 and the HX711 on female headers so you can easy swap them if this should be necessary but you don't have to do this.
Step 6: HX711
To get the measurement of the load cell you need to use a weight sensor. I use the HX711.
Connections for the HX711:
- E+: red wire.
- E-: black wire.
- A+: white wire.
- A-: green wire.
- VCC: 5V.
- SCK: GPIO22.
- DOUT: GPIO23.
- GND: GND.
After you have connected everything, you will have to calibrate the scale first. Use the class HX711 and then the following code:
hx = HX711(23, 24)<br>hx.set_reading_format("LSB", "MSB") #hx.set_reference_unit(327) -> this has to be in comment hx.reset() hx.tare() val = hx.get_weight(5) sleep(0.5) hx.power_down() hx.power_up() print(val)
Now let the code run and place something on the scale. Make sure you know the exact weight of it. Wait until you have like 20 values and then take the average of it. Then you divide this number with the weight of the item u used. Now fill that number into hx.set_reference_unit(number) and uncomment it. Test it out by putting different object on the scale.
Step 7: Stepper Motor
Obviously we need some electronics to make the whole system work. To control the stepper motor we need a stepper driver, I chose the DRV8825.
Connections to DRV8825:
- VMOT: +12V (coming from the DC-DC-converter).
- GND: GND (coming from the DC-DC-converter).
Make sure to place a capacitor between those two.
- 2B: red stepper wire.
- 2A: blue stepper wire.
- 1B: black stepper wire.
- 1A: green stepper wire.
- FAULT: you can leave this unwired but can also hang it to 5V.
- GND: GDN (coming from the Raspberry PI (RPi)).
- ENABLE: no wire needed.
- MS1-MS2-MS3 : no wire needed.
- RESET - SLEEP: attach to eachother and then to the 3,3V.
- STEP: GPIO20.
- DIR: GPIO21.
Before you attach everything , just attach the VMOT+GND, GND to Rpi, RESET-SLEEP and STEP-DIR. We first need to set the Vref for the stepper driver. The Vref has to be the half of the current the stepper motor needs. For this motor it is around 600mV, measure the voltage and the little screw and turn it until it is around 600mV. After this you can attach the other wires.
Step 8: 3D Print Turbine
To push the food from the reservoir to the feeding place u will need this turbine. For the people that don't have acces to an 3D-printer you can always use a 3D hub, like this one -> HUB
Step 9: Installing MySQL
To save the data from the system there is a database integrated into it. To let the database work we first have to install MySQL on the RPi.
Type the following commands in your Putty connection:
sudo apt update
sudo apt install -y python3-mysqldb mariadb-server uwsgi nginx uwsgi-plugin-python3
Test if your MariaDB is working with:
sudo systemctl status mysql
After this we are going to create a few user into our database with the following commands:
CREATE USER 'project-admin'@'localhost' IDENTIFIED BY 'adminpassword';
CREATE USER 'project-web'@'localhost' IDENTIFIED BY 'webpassword';
CREATE DATABASE project;
GRANT ALL PRIVILEGES ON project.* to 'project-admin'@'localhost' WITH GRANT OPTION;
GRANT SELECT, INSERT, UPDATE, DELETE ON project.* TO 'project-web'@'localhost';
UPDATE mysql.user SET Super_Priv='Y' WHERE user='project-web' AND host='%';
Now the database exists we can fill the database with the necessary tables and stored procedures.
after this, copy the code in Projectdb.sql en past it into mariadb.
If this works then you do the same for the other three .sql files and you end with:
If everything went right your database is now ready to go!
PS: If something doesn't work, remember... Google is your friend ;-) !
Step 10: Installing the Code
Step 11: How to Use
- Put the two plugs in.
- Wait a bit for the webserver to start.
- Type the IP of your RPi into the browser.
- On the 'home'-screen you can see a chart of the measured food.
- On the 'feeding times'-screen you can set the feeding times.
- On the 'history'-page you can see the deposit history.
Participated in the