If you find this project interesting, give it a like and share it!
If you are interested in buffering for a short time frame (ex. a holiday) this is the right solution for you, otherwise go to the project BP005 for a self-controlled watering system that operates 365 days per year.
Some years ago I had the opportunity to spend a whole month holiday in Portugal. I didn’t want to ask my friends, or neighbours, to water my plants everyday for me. I thought therefore to build a system for that purpose using the most common microcontroller PIC16F84A.
I thought and tested lots of different solutions in order to find the best one. Reliability was the most important aspect to ensure: a fault could have killed my plants or, worse, flooded my neighbour’s house. Once the system was built, only a few days remained before my departure. So, I set the irrigation timing as best as I could, I asked a friend of mine to go and check once if everything was fine and I left the house crossing my fingers.
When I came back to Milan, I surprisingly found all my plants incredibly grown and healthy. From that moment, I decided to use the system for the whole year. To do that, it was necessary to change the irrigation timing in the code and reprogramming the PIC each time depending on the different seasons and temperatures.
According to my initial purpose, it was not necessary to provide a “user friendly” way for that. A display and others devices around it, would have made the project uselessly complex, more expensive and longer. In the end, I realized that reprogramming the PIC from time to time was not a big hassle and allowed me to use it in every condition. I abandoned my watering can for ever.
As you can see in figure 2 and 3, the system is still today providing water to all my plants in the balcony making me very proud. In particular, in figure 3 you can see where I put the central unit board with the PIC16F84A.
My simple, cheap and quick solution
As you probably know, it is better not to water plants and trees when the sun is high. So, the goal of this project was to find a simple, cheap and quick solution to water all my plants every night, splitting the balcony in three zones with an individual irrigation timing each.
By using a LDR (light dependent resistor), it is possible to activate the watering process after the sunset. This solution avoids the use of a clock that is not the easiest device to make in DIY.
The core of the project is the PIC16F84A. Its task is to control, in automatic or manual mode, all the solenoid valves according to the timing set in the code inside it.
The most expensive components in the projects are the solenoids. By surfing on eBay, I found a very cheap 24V AC model, made to be installed in washing machines, that suited my requirements perfectly (figure 4).
Relays are quite expensive too but I had some small 12V ones at home; otherwise by using some 5V ones, the LM7812 in the schematic below is not necessary but the LM78L05 must be substituted with the LM7805.
What the PIC16F84F is programmed to do
The system ensures watering your plants every night but you can also decide to irrigate manually the three different zones pressing the corresponding push button. The PIC16F84A is the core and controls everything.
THE NIGHT CYCLE
The program inside the microcontroller is normally halted during the day. After the sunset the LDR unblocks it and 64 minutes later the PIC16F84A begins to water the zones one at a time.
The graph in figure 6 displays the peculiar sequence adopted to open and close the solenoid valves. This method ensures to maintain the water pressure low in any condition through the pipes increasing the system’s safety.
You can see practically what the microcontroller does by playing the video below.
By pressing a push button the system starts to water the corresponding zone for one minute or until you will press that button again. The process of opening and closing the solenoid valves is the same described for “the night cycle” in figure 6. Note that the code, as is written, allows you to water manually only during the day when the program is halted.
In the drawing in figure 7 you can identify where LEDs, push buttons, clamps and the other main components are placed in the central unit board.
The four LEDs show the system activity;
- During the day: the red LED is fixed on;
- After the sunset: the red LED blinks (50% duty-cycle) and the three green ones display, in binary notation, the renaming time according to the scheme in figure 8;
- Watering in action: the red LED blinks rapidly, the corresponding LED zone is on;
- When the watering is completed the red LED pulses (20% duty-cycle).
Practical realization and testing
THE WATER PIPING SYSTEM
Building the water piping system is very easy. You need to connect pipes (figure 9), nozzles (figure 10) and junctions (figures 11 and 12) together.
For my balcony i decided to use Ø16mm of rigid pipes that suit perfectly the solenoid valves I bought. With them I “bring” the water from the kitchen’s tap to the three zones. For the lower pots I installed directly the nozzles on them; otherwise for the upper ones I connected soft pipes to the rigid ones in order to make flying nozzles.
I hope the scheme below explains better how I built the piping system for my balcony.
PROGRAMMING THE MICROCONTROLLER
First you need to open with a text editor the code written in c, called “code.c”, available in the compressed file. Set your irrigation timing by changing the values shown in pink in figure 14. Now compile the code by using the XC8 compiler in MBLAB’X IDE (both downloadable for free from the Microchip’s website). In the end, program the PIC16F84A with your software programmer (I use PICPgm).
THE CENTRAL UNIT BOARD
A single side board with some jumpers was sufficient to realize this project. For that reason building the PCB is quite simple.
Once you have soldered all the components, install a small heat sink to the LM7812 and the programmed microcontroller onto its socket.
Now it is the time to test the circuit. Connect a transformer (24V AC – at least 15W) to the circuit and the solenoid valves to the output clamps. If everything works fine, the red LED should be on; by obscuring the LDR, the LED should start blinking.
Test now the solenoids by pressing the push buttons that should open and close them according to the process explained before in the manual irrigation section.
So far, so good? Well, let’s test the automatic night cycle. Obscure the LDR until the red LED starts blinking. As explained before, the watering will start only 64 minutes later and in the meanwhile you should see the green LEDs display the remaining time (figure 8). After that, if the night cycle has gone fine until the end you are ready to install the central unit board into the piping system. Otherwise, if the program resets after having watered the first zone, you will need to substitute C4 with a 2200µF 10V capacitor as I needed to do (as noticeable in figure 1).
The last step is to set the right timing for your zones. This is the procedure I suggest:
- water manually each zone until you are satisfied and write down the three timings. Leave the system switched off;
- the day after, program the microcontroller using the measured timings (from point 1) and plug the system on. During the night the system will water your plants;
- in the following days monitor the system and, if necessary, do some fine adjustments of the timings by reprogramming the PIC;
Finally set the LDR sensitivity by the R14 trimmer and enjoy!
Download the project
Pressing the button below you can download a compressed file with all the necessary material to build this project:
- the PIC16F84A, the LM7812 and the LM78L05 data sheets;
- the pictures of the final project, the schematic, the code, the PCB mask and the PCB layout as shown in this post;
- the schematic and the board files in Eagle format.
If you need some help please do not hesitate to contact me or leave your comments below. Enjoy it!
I have decided to share my knowledge and my projects for free, so I have not inserted any annoying ads on andy-progetti.com. Despite this, if you like my website, please help me in developing it by leaving comments and suggestions, or by making a small donation pressing the button below. Grazie di cuore, Andrea Dal Maso
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.