Introduction: Automatic Trash Bin
If you have been watching my channel for a long time, then you most likely remember a project about a trash bin with an automatic cover. This project was one of the first in Arduino, one can say my debut. But it had one very big drawback: the system consumed more than 20 milliamps, which made it impossible to work autonomously from batteries. And today, with new knowledge and dozens of projects behind me, I will correct this problem.
Step 1: Components
To create this, we need a bucket with a cover opening on the hinges. This was bought in household goods and called a bucket for washing powder. As a board of Arduino I took Nano model. The servo drive is desirable with a metal reducer. Next - an ultrasonic distance sensor and a battery compartment for 3 finger batteries. For a beauty let's take this stylish plastic case.
Step 2: Hardware
First we get rid of excess plastic on the cover. It's a latch and the handle. The distance sensor fits perfectly into the box, only the connection pins are stick out. We'll remove them. First we will cut the plastic of the pins. At the servo drive we extend the wires as they must reach to the front of the trash bin. And we are connecting everything according to this simple circuit. The sensor will powered from one of the pins of the Arduino, so as not to solder a pile of wires to the power pin, because the servo is already connected there.
Now we place everything in the case. First we will make holes for the sensor. I marked the centers with knife. First I drilled hole with a common drill for the accuracy of the center and then enlarged it with a step drill.
Fill everything with hot glue. The battery compartment is glued with a double-sided adhesive tape, and the wire from the servo driver will go out through the side hole.
Step 3: Servo and Box Mount
Now clean with sandpaper servo side and the bin cover at this place. We glue them together with usual instant glue. We can additionally strengthen it with the cable ties. Also you need to make the groove under the wires, so that they aren't strongly clamped. Of course, the servo drive must enter to the bucket and don't cling to anything. Wires were fastening along the edge of the bucket with hot glue.
The box itself is fastened to the bucket with screws and nuts. It is necessary to fix it so that the sensor beam doesn't catch the basket cover. For this you can put a couple of nuts under the upper screws.
Step 4: Mechanism
First I made it from a stick of ice cream. But it was too thick, and did not allow the cover to close freely. Then I did the same thing from the piece of metal jar for a canned food. In the upper part the rod of servo driver is fixed with a piece of paper clip. And this piece is glued using superglue and soda to the strip of metal.
Well, let's mounted it. Very carefully twist the servo to the extreme position and fix the rocker in the position of the opened cover. Well, now our bucket closes and opens. Do it carefully, because this product of China can break, if work on the contrary. In principle, the hardware part is ready, let's proceed to programming. At first, we will write a simple algorithm, without energy saving.
Step 5: Programming in XOD
I use visual-based programming langulage XOD, it is based on nodes. A node is a block that represents either some physical device like a sensor, motor, or relay, or some operation such as addition, comparison, or text concatenation. You can watch all process of making whis project in XOD in my video about trash bin. Also first photo is a simple XOD program without some "hysteresis", and third photo is with it.
You can download XOD trash bin project in project page on GitHub.
As you have already noticed, to create this device we didn't need knowledge of any programming languages. We just had to think out the logic of the work correctly and know which nodes exist in the program. It's a task for a couple of evenings of reading the documentation. In xod, we clearly see what data is transmitted, from where it is transmitted and where it comes. Create the long sheet of the code is the next step of the Arduino fans. You can start from here with functional programming.
So, it works! Let's talk about energy saving.
Step 6: Energy Saving. Hardware Modifications.
So, we have 3 energy consumers, the Arduino itself, the sensor and the servo drive. To make the Arduino eat less from battery, you need to turn off the "pwr" LED, which glows constantly when there is power on the board. Just cut the track leading to it.
Next there is a voltage regulator on the back of the board, we don't need it too, bite off its left pin. Now Arduino at sleep mode needs literally a couple of dozen micro amps. The sensor can be turned on and off directly by an Arduino.
But the servo in the standby mode consumes a lot of energy. So that we will use the mosfet transistor as in the video about the electronic weather forecaster. You can take any mosfet from this list. Also need a resistor of 100 Ohms and 10 kilo Ohm. I will leave the full list of components for the project in the description under the video.
The new circuit will look like this, the servo powered through the mosfet. At the beginning of the movement, the servo takes a large current, so you need to put the capacitor on the power input.
Step 7: Programming. Arduino IDE
The logic of the work is as follows. Unfortunately, xod hasn't yet added power modes, so I wrote the firmware classically in Arduino IDE, where I regulate the system with the library "LowPower". Wake up, fed power to the sensor, get the distance, and turn off the sensor. If you need to open and close the cover, connect the power to the servo, turn on it, and turn off the power again.
You can download Arduino IDE sketch from GitHub project page
Step 8: Conclusions
Now the circuit in standby mode consumes about 0.1 milliamps and can safely work for a long time from finger batteries. But look what's the matter: for stable operation, you need a voltage higher than 3.6 Volts, that is, above 1.2 Volts per battery.
Judging from graph for an alkaline battery, it can be seen that the battery discharges exactly half, that is, about 1.1 Ampere hours. That is approximately 460 days of work in standby mode, isn't bad? But the battery will spend only the half of the capacity, and then it can be inserted, for example, in the remote control from the TV. But if you use lithium batteries, they will work almost to 100% of capacity, and this is almost 3 Ampere hours, that is, 3 times longer. Lithium batteries are more expensive than alkaline batteries, but I think it's worth it.
Thanks for your attention, and don't forget, that there is video about making this project!
We have a be nice policy.
Please be positive and constructive.