Automating watering of home garden using ESP32-Wrover-IE

Automating watering of home garden for an extended holidays will keep away holyday makers from worrying of plants at home.

ESP32 garden watering system almost ready

The ESP32 watering system Cost of Goods does not exceed MYR130.

Here are the list of cost, MPN/CPN (Manufacturer Part Number, Customer Part Number), the website I had used to purchase the parts.

Overview of components
CPN/MPNDescriptionSupplier URLQuantityCost
BB-AHALR-3V-011CH Active H/L 3V OptoCoupler Relay Modulehttps://my.cytron.io/p-1ch-active-h-l-3v-optocoupler-relay-module17.00
MAKER-SOIL-MOISTUREMaker Soil Moisture Sensor (Capacitive)https://my.cytron.io/p-maker-soil-moisture-sensor120.58
WR-GROVE-2561Grove 4 Pin Buckled to Female Cablehttps://my.cytron.io/p-grove-4-pin-buckled-to-female-cable11.50
WR-JW-40FF40 Ways Female to Female Jumper Wirehttps://my.cytron.io/p-40-ways-female-to-female-jumper-wire12.50
WR-JW-40MF40 Ways Male to Female Jumper Wirehttps://my.cytron.io/p-40-ways-male-to-female-jumper-wire12.50
MO-SMWP-5VMicro Submersible Water Pump DC 3V-5Vhttps://my.cytron.io/p-micro-submersible-water-pump-dc-3v-5v13.90
40-CaseboxBattery Holder With Connector Or Case Boxhttps://shop.techmakers.com.my/1-2-3-4-battery-holder-with-connector-dc-jack-or-case-box-with-on-off-switch-cover-aa-aaa-3-7v-18650-9v11.80
40-500272JST Connector Wire Cable 1 Pairhttps://shop.techmakers.com.my/jst-male-female-connector-wire-cable10.90
ESP32-WROVER-IEESP 32 NODEMCU IOThttps://shop.techmakers.com.my/arduino-nodemcu-iot-esp32-esp-32-wifi-bluetooth-development-board132.80
40-17Core1 meter 17/0.2mm 20AWG Whitehttps://shop.techmakers.com.my/jumper-wire-multi-strand11.50
40-17Core1 meter 17/0.2mm 20AWG Bluehttps://shop.techmakers.com.my/jumper-wire-multi-strand11.50
40-ESP32/S38Pin Base(purple)https://shop.techmakers.com.my/esp32-ultra-low-power-consumption-dual-core-wifi-bluetooth-development-board114.50
1N5819Schottky Rectifier, 40 V, 1 A, Single, DO-41 (DO-204AL), 2 Pins, 550 mVhttps://my.element14.com/stmicroelectronics/1n5819/diode-schottky-1a-40v-do-41/dp/980121959.30
Total100.28
Estimated cogs of the system, not including external antenna, watering parts and battery

The cost of main materials are MYR 100.28, the diode that will act as flyback to prevent current flow in opposite direction has a MOQ (Minimum Order Quantity) of 5. Hence, any buyer needs to buy at least 5 units from Element14.

MOQ is an usual term when item is purchased, especially when it comes to ordering item that the courier cost, or cost of operations requires a bare minimum quantity that a manufacturer or a vendor are willing to provide to complete a business transact with the buyer/customer.

Espressif ESP32-Wrover-IE

Espressif ESP32-Wrover-IE, I prefer to use this as it is affordable for any hobbyist that looking for a IoT dev board. It comes with 38 pins that has a wide numbers of GPIO. On top of that, it has built-in WiFi and BlueTooth to this SoC. IE is chosen for the ESP32-Wrover variant as it allows developers to attach an external antenna to extend the range of the built in anteanna. At MYR33 ~ it is a good board for developers and students alike.

Extender board 38 pins for ESP32-Wrover

This is a good board to complement the ESP32-Wrover-IE. This board allows neater interface of supplier voltage, ground and data pin next to each other. On top of that the clear labelling of the pins help developers to work more effective and efficiently. Color code black means ground, red means supplier voltage and lastly yellow are the data pin. Color code allows easier wiring of sensors on to the board under development. The extender board 38 pins are more reliable than the conventional breadboard. Spend more on this as its really reflects of you get what you paid for.

ESP32-Wrover-IE seated onto the board
Relay, the 1Channel OptoCoupler, allows isolation voltage of submersible pump from the ESP32 controller as well act as a switch to switch on or switch off the electric pump

Relay were selected instead of a MOSFET as motor operations does not requires high precision time. The pump allows error in miliseconds and it will not cause any form of critical failure. And it is a simpler and cheaper solution, the click sound makes the switch appears more authentic and functional to see how the entire system works.

Soil moisture sensor, using capacitive

To prevent wear and tear well as corrusion from elements, added rubber to the exposed parts. Capacitive soil moisture sensor is more expensive, but non capacitive type will wear out faster. For reliability use the more expensive sensor.

Assembled system without enclosure and without battery

Assembling sensors to ESP32 board is easy. Make program is even easier using AI assistance. The first challenge was how to assemble the relay, motor to the ESP32 without shorting the ESP32.

After seeking consultation from a friend and more research from the guidance. Here is the final diagram.

How to connect the power to the submersible motor to diode, relay and the battery pack, and then connect it to the ESP32

Another challenge is soldering the parts and to ensure that the soldered part are properly insulated. Item used are straws, and hot glue. Below are the results.

Not a clean way, but taping wires to work pad and using makeshift padding from discarded switch blade.

Adding solid straws from vitagen can act as support as well to the soldered wires.

Improvised support using vitagen straw and hot glue

Not pretty but utility enough to make the prototype to work.

Or totally add layers upon layers of hot glue to act as insulator for the flyback diode and the exposed wires.

To finish the make shift system with a simple enclosure that is easily available for any food that order as take away.

Food container used as temporary enclosure for the system.

Then added MYR21.00 worth of plumbling bought from pet shops.

Petshop supplies and some random 90 degree pipe elbow

Before completing the entire system, learn how to soil sensor returns value from dry soil or wet soil. In my case any value more than 2400 it is dry, anything less than 2000 is wet.

The setup is simple, just the ESP32 board with a soil moisture sensor, have the data sent to ThingSpeak

Let the sensor starts sending the data from dry soil to verify the value, then after 1 hour, add a good amount of water to verify the wet soil value is correct.

With the value known, assemble the system and have the first prototype software that waters the plant when the soil reaches the dry threshold.

Adding a battery
Adding the controller, now with proper wiring to sensor and relay
Relay, and battery that connects to the submersible pump

Then it run into the first major roadblock. Deep sleep ESP32 on paper is good idea to conserve the battery pack power. But wrong was I, found out later that modern external battery pack for smartphone has a smart circuit that will stop charging or power if there is no load or very low load on the battery. ESP32 when sleep will cause the external battery to sleep with it.

So, for ESP32 using modern battery pack, do not use deep sleep. Make a simple WiFi heartbeat every 2 seconds. Not efficient way to use power but it will ensure the external battery does not sleep. A sleeping external battery will not be able to power up a sleeping ESP32.

Then leave it over the night, encounter roadblock number 2, the water bucket were emptied over the night. Later discovered that the controller were over watered. So, downloaded the data and pump into QWEN.

The new discovery were made that what made the sensor fails to notify the controller.

QWEN generated data analytics of ThingSpeak data

Term discovered is Ghost Spike. Apparently, the soil in my pots can causes gap in between soil and sensor at a micro level. The sensor will sense that the soil as dry as the water puts itself in between the soil and capacitive soil sensor causes a gap that simulate dry condition.

Since, I have no time to update the hardware or to solve soil mixture of my pots. A decision were made to only water the plant at 20.00 hours everyday, with 10 seconds of water flow. Added a data to record 1 to mark the pump has run. Maintain the sensor only to read.

The most updated revision of data sent to ThingSpeak, soil moisture data, ESP32 alive ping, and pump activation
Final setup, adding a makeshift cover to add more water proofing.

Lastly, the system were rushed to production, a simpler approach were used. Added cover to prevent mosquito breeding into water bucket.

Improvement that can be made into this system are not limited to :

  • Adding 2 solar panel
  • Adding 2 rechargable battery pack
  • Discover what is better way to prevent ghost spike

Leave a Reply

Your email address will not be published. Required fields are marked *