I’m not overly keen on cage eggs, so i got a few chooks for around home. Legally we are allowed 5 hens (no roosters) since we live in town. Not wanting to annoy neighbours i went for snuggly quiet little silkies which are the poodle of the chicken world .
Since I am not overly keen on early mornings, i have been trying to find a good way to automate the chicken coop. I made a basic sliding door up and down, tied a piece of string to that, ran it through a pully inside hte top of the coop and out the back.
This meant i pulled the string, it pulled the door up. I could tie it off during the day, or easily close it. Since the chicken coop is near my bedroom but outside, i ran the string in a bedroom window – on weekends i open window, pull string, close window and go back to sleep.
Now days thats getting a little old, i want to automate things!
When the chickens were smaller, i set up a raspberry pi with a basic install of rasbian, i installed a raspberry pi camera on that, and put it all in a case. This was ideal for just watching the chicks whilst at work, and when i was integrating new chicks.
Moving on to the more fun project, i ended up using scraps of things from all over the show. My son had an arduino car that had a servo AS3013 (3kg) that i took, along with a plastic end spinning thing. I attached a piece of dowel to that, and made a crappy mount. This is what my high tech setup looks like.
The idea is that the string for the sliding door wraps about the dowel, pulling it up.
The 3 wires from the servo go on the 5V, ground, and pin 18 according to https://pinout.xyz/pinout/ground which has them neatly in a row, and the Pi itself goes in a nice container to keep dust away. I had to drill out some space for the wires going to the servo.
To make the servo work, i installed the RaPi GPIO librarys
sudo apt-get install -y wiringpi
After this i can just create scripts like this to run the servo (this is continuous rotation servo)
# opendoor.sh # This switches pin 18 to pwm if its not already gpio -g mode 18 pwm Now you can tell gpio to set the PWM clock to those numbers: gpio pwm-ms gpio pwmc 192 gpio pwmr 2000 # This here tells its the placement gpio -g pwm 18 200 #sleep whilst it turns for 2 seconds sleep 2 # Stop the turning and reset that gpio -g pwm 18 150
Likely im doing this wrong, but it works for me, it was simple and easy to setup and do. THis is from tutorial at https://learn.adafruit.com/adafruits-raspberry-pi-lesson-8-using-a-servo-motor/software
Once i had the servo moving, the camera working, and all that , i made a web page that simply runs the php scripts using exec, this means i can click ‘pic’ and get a pic realtime without running a webcam. Terribly insecure and probably not good, but its on local network only, not a major issue. Door scripts are on a crontab to run at a set time.
I uploaded all the code for this to https://github.com/lizquilty/automated-chicken-coop
Now i just need to wait for a sunny day to install it all 🙂