📜 ⬆️ ⬇️

Automatic bird feeder

Back in 2010, Leonid Kaganov (as you know, a great inventor) shared with the readers of his blog the idea of ​​a bird feeder with a webcam and filling the grain by sending paid SMS. I liked the idea. And now, 4 years have passed, the New Year holidays 2014 have come, I took out the arduino uno stumbled from the table, the tp-link 3020 router and, together with bitl (aka the admin of the city site), started the project.


Under the cut a lot of photos.

Manger

The heart of the feeder is the Tp-Link 3020 router with OpenWrt firmware, to which the D-Link DCS-2310L camera and arduino via usb are connected via ethernet. He himself goes to the Internet via wifi. Every minute, cron runs a script that once every 4 seconds determines whether it is necessary and how many times to open the valve on the bunker with feed.

Script
#!/bin/sh COUNT=10 if [ -f /tmp/lock.ceed ]; then LOCK=`cat /tmp/lock.ceed` if [ "$LOCK" -lt "1" ]; then echo '1' > /tmp/lock.ceed while [ "$COUNT" -gt "0" ]; do rm /tmp/status.php wget http://labinsk.ru/feeder/status.php -P /tmp/ -t 5 if [ -f /tmp/status.php ]; then CEED=`cat /tmp/status.php` if [ "$CEED" -gt "0" ]; then until [ $CEED -lt 1 ]; do echo 1 > /dev/ttyACM0 let CEED=$CEED-1 let COUNT=$COUNT-1 sleep 4 done fi fi let COUNT=$COUNT-1 sleep 4 done echo '0' > /tmp/lock.ceed fi else echo '0' > /tmp/lock.ceed fi 

Arduino listens to the com port and in the case of receiving one (0x31) opens the valve for 120 ms.
Sketch Arduino
 int incomingByte = 0; int relay0 = 8; int relay1 = 12; void setup() { Serial.begin(9600); pinMode(8,OUTPUT); pinMode(12,OUTPUT); digitalWrite(relay0,LOW); digitalWrite(relay1,HIGH); delay (200); digitalWrite(relay0,HIGH); } void loop() { if (Serial.available() > 0) { incomingByte = Serial.read(); if(incomingByte==49){ digitalWrite(relay1,LOW); delay (120); digitalWrite(relay1,HIGH); digitalWrite(relay0,LOW); delay (200); digitalWrite(relay0,HIGH); } } } 

')
The mechanism is made of 50mm tee for sewage and car solenoid. A cork from a 5 liter pet bottle is glued in the tee (the bottle acts as a feed hopper). The valve is also made of a piece of sewer pipe.







A self-made two-relay shield is connected to the Arduino, to which the solenoid is connected according to the standard polarity reversal pattern. Eats everything from the power supply for the late USB-SATA adapter.



A house was made, with an installation box for electronics, a swivel mount for a bunker and a flip-down bottom:


So adding feed is much more convenient:


Initially, we wanted to install a feeder in a city park, but due to problems with electricity and wifi, it was decided to install it at home. Actually installation:










Site

The feeder is available at http://www.labinsk.ru/index.php?p=feeder&stream=mjpeg

A few words about the implementation on the server side of the site.
It was decided to abandon the original idea of ​​pouring feed on SMS. The project was not originally meant as commercial. In fact, what kind of benefits can we talk about? And, of course, those who want to send SMS-messages in order to see how the feed is poured - there would be not so much, and the birds would not appreciate such a "care". Therefore, you can fill the feed by simply pressing a button on the page with the video broadcast. So that users do not empty the entire bunker in a matter of hours - a timeout has been entered. At the moment, the “Feed” button is available only 15 minutes after the previous filling of the feed.
Well, it all works is trivial. The user presses the button, the php script adds a record “not processed” to the SQL table, the feeder periodically polls the server, referring to another php script that informs the feeder that a request for filling appears, and then changes in the SQL table, the status of the corresponding record. Thus, it is not the site that sends the command to the feeder, but the feeder periodically asks the site if it is necessary to pour it? Not the most optimal implementation, but simple. Moreover, in this case, we do not need a static ip-address (or some kind of DynDNS) for the Internet connection of the feeder.

Birds









PS
The feeder has been working for 2 months, during this time the birds have eaten about 10 liters of feed (2 bunkers). Food - Sunflower Seeds.

UPD Video test mechanism.

Source: https://habr.com/ru/post/217985/


All Articles