While there are many solutions that cater to managing garden irrigation, they’re either powered by the AC mains supply or run on batteries, that need replacing at intervals. To circumvent problems with inconsistent mains power or having to check on batteries regularly, this project had to run off solar power.
It should also be able to notify about its state of operation, the amount of water used and any problems in the water supply.
Parts selection
The ESP8266 from Espressif, was the perfect fit as the controller. Inexpensive and readily available, the ESP12E NodeMCU board was used. The modules WiFi is used to send updates to a MQTT broker. The ESP8266 mentions 20uA as 'Deep Sleep' current consumtption,as per the datasheet, but we'll see later that to achieve that on a general purpose development board requires additional modifications.
For time keeping, I prefer the DS3231 over the DS1307, primarily for its internal temperature compensated oscillator and all inclusive packaging. Here the chip is used on a RTC module that has a CR2032 socket soldered.
The solenoid valve, controlling the flow of water, was particularly important. If the system is to remain ‘open’ for up to an hour, a regular, normally closed solenoid valve, would consume a substantial amount of battery power. So for this project I’ve selected a bi-stable solenoid valve which uses power only when changing states.
The valve requires a directional change in current to change state and this is done using a H-bridge FET driver.
Powering the whole unit is a single 18650 Li-ion cell. The battery is topped up during the day by a CN3065 charger controller and a 6V, 1W solar panel.
A voltage booster is used to drive the H-bridge chip at 5V. Power to this 5V sub-system is controlled by a IRF3205 MOSFET. Cutting off power to secondary circuits helped extend battery life considerably.
A hall effect based flow rate sensor with PWM output completes the list of parts.
Building the hardware and firmware.
Espressif’s non-OS SDK for the ESP8266 provides all necessary drivers for the on-chip peripherals. The firmware is made using these peripheral drivers itself, along with some of my own for reading the flow sensor and driving the solenoid valve.
I’ve wired all the components onto a FR1 type general purpose board. Soldering such maybe be tedious but sometimes it feels therapeutic even. Also it allowed me to change parts of the system at a later stage when problems occurred during testing.
| Wires used to create connections on a paper phenolic type general purpose board |
The RTC is powered from a GPIO. The 400uA current requirement is low enough to allow this and turning its power off during the deep sleep cycle becomes easier.
The 5V boost converter input is controlled by the IRF3205 MOSFET. Its low Rds is perfect for power control applications. The MOSFET is also controlled by another GPIO and only enabled when the solenoid is to be driven.
A HTML page and some javascript for updating configuration was added into a spiffs partition on the ESP8266 flash.
Problems
The bi-stable solenoid arrived with no documentation or part number mentioned. there wasn’t any data available on the current requirements, and so my initial driver consideration, which was the L293D H-brgide IC, blew out after running for a couple of days. The solenoid also had intermittent difficulty changing states. Assuming this to be due to a higher current requirement, the driver was changed to a DRV8833 FET H bridge driver. It resolved these problems.
The solar panel, on a good clear day is able to output 6V at 45mA around noon time. The other components had to have low sleep current draw.
The ESP8266 mentions 20uA in deep-sleep. not the best, but it would suffice for this application. But when you use a ready development board, like the nodemcu, other components contribute power consumption which cannot be controlled by the firmware. So some modifications had to be done to the nodemcu board.
The DS3231 pulls about 300uA from its VCC. Its powered by a GPIO of the ESP8266. The GPIO is pulled low in the firmware before the ESP8266 enters deep sleep.
The nodemcu board, when put into deep — sleep still consumed 10mA. The CP2102 USB to UART chip was a major contributor to this with a couple of mA being sucked by the 3.3V AMS1117 regulator.
Since the ESP8266 was being powered by a Li-ion 3.7V battery, the AMS1117 could be taken out.

I did not want to give up on the ability to flash the ESP. so had to keep the CP2102 soldered on-board.
The first modification to do was separate the CP2102 from the ESP’s 3.3 supply line. This was done by cutting tracks to VDD and REGIN of CP2102.
![]() |
| Cutting the 3.3V trace to VDD and REGIN using a magnifying glass. |
To power the chip while flashing, Vusb of the USB connector was soldered to the REGIN.
I also had to decouple the Tx pin of the ESP from the cp2102, because,
even when not powered, the CP2102 would pull the Tx pin low, and this
prevented the ESP from booting up. It has to be soldered back to reprogram the board. Will later replace it with a switch if required.
Finally, current draw settled at 22uA for the entire system in deep sleep.
Finishing up
For purposes of visualizing the MQTT data, I've used the IoT MQTT Panel android app.

Comments
Post a Comment