Watering your plants in the apartment when you're in a holiday is always a problem. You need to ask a friend to help every every couple of days, trust him or her with your key. Another solution is over-watering but this won't work if you are more then a few days off.
So i began to search online stores for an automated solution and i found only systems for gardening: electronic faucets with timers. I've thought this systems are a little dangerous for an apartment, any malfunction and you could flood your apartment and your neighbors.
I've decided to build my own low cost system (under 50$) using a water recipient a pump a watering kit with hose, drippers and custom electronics.
I will try to explain how i've built it. This project requires moderate electronics and building skills.
Note: Many pictures i've attached contains notes with explainings, please read them to clarify things.
Step 1: Things Required
1. Arduino pro mini 328p (eBay) 2.7 $
2. HC-05 bluetooth module (eBay) 3.8$
3. a NPN tranzistor that is rated for at least a few amps, i've used IRF540N < 1$
4. a 220 ohms, 0.25W rezistor <1$
5. a diode, 1N4004 <1$
6. wires to connect the parts < 1$
7. water pump, i've used a submersible pump rated for 12 v 2.2A (measured) (Aliexpress) 10.3$, you can use a different pump as long it will accomodate your needs, i will talk about this later
8. Drip irrigation system (eBay) 13$ I've chosen the 10meeters 15 drippers system. This consists of hoses, drippers and holders
9. Power supply, the supply must be rated for 12V and 2-3A. I've salvaged mine from a 12 V 2 A charger (eBay) 3.2 $
10. PCB (eBay) <1$ per piece
11. 2 x KF301-2P plug in screw connector (eBay) <1$ per piece
12. L7805CV 5V regulator (eBay) < 1$ per piece
13. A small plastic box with plug, i haven't found one on ebay the pcb with the electronics and the power supply must fit inside. My box dimensions measured outside are: 112 x 67 x 52 mm
14. 5.5mm DC Power Plug Jack Socket male and female (eBay) < 1$ per piece
15. male&female pcb connectors (eBay) < 1$ for what we need
16. RTC DS1307 real time clock for arduino (eBay) < !1
17. Water resistant glue
Info: Some small items are found on eBay only on larger quantities ex 5, 10, 20 pieces. If that was the case i've specified the <1$ price, but the actual price of purchasing those quantities is higher.
1. Soldering iron, flux, wire holder
2. Wire cutter
5. small saw to cut the pcb and the power supply plastic enclosure or dremel with cutting tool with same purpose
6. power drill and 8.5 mm drill bit
7. USB to serial FTDI adapter FT232RL to programm the arduino pro mini
8. Arduino IDE
9. Phone or tablet with bluetooth capabilities. I've used an android tablet in my video.
10. Optional: magnifying glass, multimeter
1. Soldering, check this tutorial
2. working with tools like power drill, dremel tool etc
3. Basic arduino programming, this tutorial might be useful
Step 2: Setting Up the Drip Irrigation System
First you need to decide how many drippers will the system have. Mine was a 10 dripper system, but i think the pump can work with more, you need to experiment with that.
In the first picture you can see the system layout it consists of a series of arms each ending with a dripper, connected by the "T" connectors. Each arm should be about 55 cm long and the hose between the drippers about 35 cm. I've added some labels on the pictures.
I've cutted the main hose with a cable cutter, and attached the "T" connectors and drippers by pressing the hose with bear hands and twisting at the same time. After that a i've applied a bit of water resistant glue where the hose meets the "T" connectors and drippers.
At one end the hose must fit into the water pump, for this particular pump this wasn't the case so i've cut a piece of a bigger hose that fits into the water pump, and tied it with a small piece of copper cable from the small hose. I've tested it to be water tight. All this can be seen in the pictures above.
The last thing here is to prepare the water pump, the original purpose for this pump was to remove gasoline from the gas tank so it has two alligator connectors for the car battery. We need to remove those with a cable cutter, strip 3 mm of wire of each cable and solder the copper wires to the male Power Plug Jack Socket. Remember that this sockets are center positive so solder the red wire to the corresponding socket pin. If you don't know what that pin is use a multimeter with the resistance function to find out.
Step 3: Making the PCB
The PCB will hold the microcontroller, the bluetooth communication, the RTC module, a power tranzistor with a diode for protection and a small rezistor, connectors wires and a 5V regulator.
I've attached the fritzig schematic so things will be easy. The first picture represents the exported jpg image of the schematic, the last sketch.fzz file is the original file, you can open it with this tool.
1. cut the female PCB connectors, there are two 12 pin connectors for the microcontroller and also a two pin connector for the corresponding for the A4 and A5 pins on the microcontroller. There is also a 6 pin connector for the bluetooth device and a 5 pin connector for the RTC DS1307
2. After all the connectors are cut there must be soldered on the back of the PCB (where the copper is)
3. Solder the two KF301-2P plug connectors
4. Put L7805CV 5V regulator inside the microcontroller's place on the PCB. Bend it's legs and solder it on the other side then cut the exces legs with the cable cutter
5. Solder the NPN IRF540N tranzistor, and the 1N4004 protection diode, cut the exces legs after.
6. Solder the 220 ohm rezistor between the corresponding digital pin 5 and the tranzistor base pin
7. Solder thicker wires between the tranzistor and the KF301-2P plugs (red and black as they are marked on the pictures)
8. Solder all the red(+), black(-), and white(signal) wires according to the fritzig schematic
9. Solder male pins on the microcontroler you need two 12 male pins on the sides, 2 male pins for A4 and A5, and 6 bent pins for programming.
10. Solder 5 male pins on the RTC DS1307, and put a 3.3 v battery inside
11. Optional: with the magnifying glass inspect the solderings for short circuits, and check if the wires are properly soldered on the back of the PCB, also you can check with the multimeter (resistance setting) if there is a short circuit between positive and negative connections. Another test is to power the circuit without the microcontroller, bluetooth and RTC module and check the corresponding voltage with the multimeter.
12. Place the microcontroller, HC-05 bluetooth device and RTC module on the female PCB connectors and push gently so they fit .
Step 4: Make the Enclosure
1. Cut the 12 V 2 A charger, i've used a dremel tool to cut it, and then gently extract the PCB with the components inside. You must be careful not to damage the components inside when you cut it. After cutting it cut the 4 wires with the cable cutter and unsolder the cables.
2. The electronic box preparations consists in two things:
A. on the box back side interior, remove the plastic protuberances with the dremel cutting tool, in my box the PCB does't have enough room inside if you do, be careful not to damage the box or to remove the four screw holders for the box
B. You need to drill a hole using the 8.5 mm bit in the center of the front side of the box, as shown in the pictures. In the hole mount the 5.5 mm DC Power Plug Jack Socket female header.
3. Then the power supply live and neutral leads must be soldered to the box neutral and live leads. After that solder two wires red and white for the positive and negative 12 v output, these wires will go on the right KF301-2P connector on our PCB. After that using two pieces of double sticky tape stick the power supply pcb on the back side of the plastic case.
4. Solder two wires to the 5.5 mm DC Power Plug Jack Socket female header and remember the center positive thing, use the multimeter to check that. The other end of the wires will go on left KF301-2P.
5. Use a piece of foam to ensure sealing between the custom PCB we have created and the power supply, for debugging purposes i've left the PCB "floating" inside the box, but due to limited space and the foam it does't move. If you feel you're not in debugging mode after testing the system you can use double sticky tape to stick it to the front side of the box
Step 5: Coding
We're all most done! We now need to program the arduino pro mini.
If you don't know how to use a USB FTDI adapter check this link.
The source code is Here.
I'll try to explain briefly what the code does. Using the RTC module the system knows the time.
The softwareserial library is set to work with the HT-05 bluetooth module, it listens for watering commands and sets the watering time and duration. The commands are in the format: "watering hour:watering minute:watering seconds number".
In the main loop the bluetooth serial is checked and if so the commands are read and then are set. I am also checking a routine called isWateringTime, if it returns true the watering process starts for the defined number of seconds.
For debugging purposes the current time, watering time etc are printed over Serial and over bluetooth.
The required libraries are "Wire", "RTClib", "SoftwareSerial". First two libs are required for the RTC module and the third for the bluetooth module. The code is pretty straight forward.
First time the sketch runs, if the RTC is not programmed yet you should uncomment the line "rtc.adjust(DateTime(__DATE__, __TIME__));" and upload it. This will set the time to the RTC module the same as on your computer. After that comment the line and upload it again.
Step 6: Using the System, Calibration, Final Thoughts
A word about safety first. Although this is safer then valves attached to the main water supply, this is an experimental system so bugs might be there, the risk is that all the water from the tank might be pumped all at once so my advise is to use this system (at least at the beginning) in a space where water spills are not a problem for example a balcony with a water disposal pipe or a garden.
For debugging don't assemble the box yet, until you have tested that it runs ok. A good idea is to check the next 5 steps and if all works ok then you can assemble the box.
1. Connect to the system with any bluetooth app either android or IOS will do. i'we tested it with this app. First thing scan, then select the device, pair the bluetooth module, enter password and connect to it. Go to CMD line mode. There are plenty of tutorials for this i won't give any more details.
2. If all went right you should see a the current hour and minute printed every minute
3. Set the end flag to nothing
4. To program the device issue commands like:HH:MM:tt:
HH is watering hour
MM is watering minute
tt is the number of working seconds
The : separator is important between each number.
After you write this command hit send. You should see a message "Set for HH:MM" and "Duration: tt s". This means that the time was set successfully.
5. When the internal clocks reaches the programmed time, the pump runs for the specified number of seconds, then stops. This will repeat every day.
Set up, calibration
First, you need to connect the hose to the pump, i found a hose that fits perfectly into the pump (as seen in the pictures). If you like the connection to be permanent apply some water resistant glue where the pump meets the hose and let it harden. I've attached a picture with the pump and the hose.
You will need a water recipient large enough to fit the pump submerged, and with enough water to last for the period you're away. You can find out what is the optimal amount of water by experimenting with the system before you set it up.
For each plant fasted the hose holder in the soil using a little pressure, if you consider that a plant is larger it may need two or more drippers. (as you can see in the photo)
The pump has a on/off switch on it's cable i haven't removed that so checked is ON.
Each dripper has a red part that can be screwed more or less, the more you screw it the less water will get out. You can use this to calibrate each dripper for each plant (some plants need more or less water). Another think is that the closer the dripper is to the pump the more pressure it will have, so you can compensate for that too, by screwing or unscrewing the red part.
The pump needs to be submerged or it won't work. You should also check for leakage, the water is suppose to come out from the drippers, anywhere else it's a problem and needs to be sealed.
At the first run it will take a few seconds maybe more to get the water from the pump to the hose to the last dripper, so be patient.
There are a lot of improvements the system needs and this is only the beginning. First of all, i would like to store the watering time into the EEPROM so if the power goes down the system won't reset to it's initial hard coded watering time.
I am also thinking of a more complex algorithm of watering that maybe it will take into the account the water humidity or allows a watering time once every x days.
I was asked why haven't built a system that allows individual plants to be watered separately, maybe taking into account the soil humidity. I have two things to say about that first of all this system is an emergency waterer used when you're not home, second of a more complex system could be a lot more expensive, you will need a separate pump for each plant or maybe a valve for each plant, soil humidity sensors etc.
I hope you'll make the most of it!