Software apps and online services
Hand tools and fabrication machines
I wanted to build something with an arduino since I have received and completed an "arduino starter kit". Therefore, this project is my first attempt at building something with an arduino (and electronics) and I have done a lot of mistakes along the way. This is far from being perfect and I can't guaranty it will work out if you try this yourself. I have written down all the mistakes I have done so you could avoid them.
English is not my native language, sorry for potential grammatical or syntactic errors.
Feedback will be greatly appreciated.Project
I needed to build a door for chickens that closes and opens automatically at sunrise and sunset. The door could not be connected to the grid (too far from the house) so batteries and solar panels were a requirement. If you have the chance to be able to connect your system to the grid, do so. Battery charging/management is a nightmare.
If, like me, you are new at this, build your circuit on a breadboard first to be sure everything works fine, then solder.
An H-Bridge is a component that will allow you to control your DC Motor. I went with a L298N double H-Bridge at the beginning because I thought that its 5V output would allow me to power the logical circuit. It could have, but unfortunately it draws to much power and would have emptied the batteries at night. I tried also to NOT power the logical circuit with it but even then, it draws to much power.
To give you some numbers : at 4.2V, the arduino and all the others circuit components use 20mA. While the L298N is connected (without powering the motor) the circuit uses ~100mA. With the L293D the circuit consumes ~55mA. I also tried to use transistors to "switch off/on" the H-Bridge but unless you know a lot about transistors, I would not recommend that (leak current when off, not enough current when on,...).Batteries
After some tests, I realized that a battery of 1100mAH is barely enough to get through the night. If you have a H-Bridge which does not leak current when off, it is enough. In my case, I had to connect two batteries in parallel to not have to worry about power shortage.
I would recommend buying a battery with a bigger capacity because batteries in parallel are not a good idea, if one is faulty, the other will go down with it.
I have originally used a P4056 Micro USB 5V 1A but it does not protect the battery against over-discharge. With Li batteries, over-discharge is a real issue, it will kill your battery over time. I used a TP4056 18650 charger allowing me to charge the battery while the battery powers the circuit.
5V is not enough to power the motor. You need a power booster to convert from 5V to 12V. I used the MT3609 Module
I used a geared motor because, once not-powered, it will not move because of mechanical tension to door could apply (the door stay open when the motor is off).Solar panel
Simple solar panel. 2.5W 5V / 500mAh is way more than enough to charge the batteries during the day.
I have reckoned I could save a photosensor because I had a solar panel and should be able to know if it is day or night by measuring the tension emitted from the solar panel. It kind of worked. I am able to measure the tension with two resistors (see schematics). However, that was a mistake. To measure the luminosity, the best way should be to measure the current, not the voltage. The voltage, go from 0 to 5V with a bit of light. And the current is harder to measure. A photo-resistor being cheap, I would suggest using one instead of my circuit.
The door must be light if your motor is not very powerful (like mine). That's why I chose a plastic door which is empty inside. You should not worry about predators raising the door if you have a gutter at the bottom.Switches
The reed switches allow the arduino to know when the door is opened and closed. I have placed a small magnet inside the door (at the top). The magnet closes the circuit when in front of the reed switch.
You may notice in the schematics that the reed switches are connected to a digital pin and the ground. It's normal, I use the pin mode INPUT_PULLUP to detect if the switch is closed.
Others kind of switches may be more adapted.Box
I used a junction box : 11.6 x 11.4 x 5.6 cm
I wanted this as small as possible. I think now, this was a mistake, I should have used a bigger box: less minimalist/pretty but more functional.Soldering
Damn! This is hard.
The project worked for about a week. I did this door for somebody else and something went wrong while I was not there. I can't diagnostic the problem from afar. We had to turn the door off and wait the next time I will be able to have a look. I am pretty sure it is not the battery. The motor would not stop and I do not know why. The loop line 80 in my code should exit and turn off the motor after 15s but it didn't.
I have learnt a lot with this project. I will try to learn a bit more theory on electronics before my next project. Any advice on a book ?
I am pretty sure this all project could be done without the arduino. Logical gates should do the trick and should be cheaper but I lack the knowledge at the moment.Photos