Software apps and online services
To protect our new chickens from the different predators, an automatic door is needed. We had a look on the available solutions on the market, but none could meet our requirements:
- Remote monitoring and control by using an app
- Possibility to add additional sensors and actors to measure temperature or buzzer alert
- Not too expensive
It would be way more fun to build it myself, so this is the start of my first microcontroller project.Concept
A simple aluminium plate with guide rails will serve as the door. It is attached to a DC motor by using nylon wire. The DC motor includes a gearbox, resulting in 200 rpm on 12V DC. The used motor has a hall sensor encoder built in. To keep the door in the "up" position, it is not needed to engage the motor. Resulting power consumption will therefore be very low.
The control module I used is the Arduino MKR1000. It has WiFi built in and plenty of I/O. I have installed a WiFi Access Point in my garden shed, so WiFi reception is perfect within my chicken coop.
After booting or restarting the Arduino, the first step will be to "calibrate" the encoder values for its up and down positions. The app will ask to give the Up command or to confirm the door is already in the Up position. Once done, the encoder value is set to zero.
For the next step, the app will ask to give the Close command and Close confirmation. The encoder value at that moment will be stored in a variable. From now on, we can control the door between a zero encoder value and closed encoder value.
To control the door automatically, I've used a cheap photoresistor. Threshold value for daylight and sunset are preset within the Blynk dashboard as well as the operating mode: manual or automatic.
The DHT22 temperature & humidity sensor is only used to monitor both values.
1. The solution is not working very reliably. After some days, the door movement or sensor reading stops working. Browsing on the internet showed more people are having the same problem with the MKR1000 in combination with a web service - it is to be analysed if this can be solved.
New code includes a connection validation to Blynk. Only when the connection is in place, blynk.run will be executed. If the connection is down, it will try to reconnect first.
Data exchange to Blynk has been reduced to a 1 minute interval for slow changing values like Temperature, lux, humidity, etc. The encoder (= fast changing) will send it's value every second in case it has changed (=door is moving). If the door is standing still, it'll also send each minute to make sure the Supergraph in Blynk correctly displays historical values. Setup data is configured in PULL mode and will only be refreshed every 10s when the app is open on your smartphone.
==>> With those corrections, the setup is running for 3 weeks without a single interruption in functionality. I measured 4 reconnects with Blynk, with no impact on it's reliability.Future improvements
1. Install magnetic reed switches to serve as a reliable positioning measurement and to generate position alarms in case the door will not reach the requested position in time.
2. IR camera to be able to monitor if all chicken have entered in the coop before the door closes. Maybe also to keep an eye on the egg nest or to monitor the outside at night.
3. Motion sensor including buzzer or strobo light to scare away predators who are too close to the chicken coop.