IOT Projects

Automatic Plant watering system using Arduino or ESP8266

Learn how to create an automatic watering system for plants and crops using Arduino and ESP8266 to monitor on your mobile with Blynk application.

Had to ever planted a plant and forgot to water it and it was dried and dead? yes it happens many times as we are involved in our tight daily routine but we are higly interested in growing plants. in the other case, if you are a faremer and growing a crop it is hard to know the status of the soil from home.

Taking it into consideration we are creating a automated plant water system which uses arduino or ES8266 interfacing with a capacitive soil moisture indicating sensor and connecting them to water pump so when is soil state becomes dry the water pump automatically starts and when the soil is wet the pump will be turned off automatically. Here we are going to show this procedure in different ways :

  • Interfacing with Arduino with out monitoring
  • Interfacing with ESP8266(NodeMCU) to monitor status on mobile.

Before getting into work lets learn how this smart plant watering device works and what components are required to build this device.

Working of smart plant watering system:

We are connecting a single MCU (Arduino, Node MCU, Wemos D1, ESP 32) to a Soil moisture sensor here we are using a capacitive sensor instead of resistance sensor because those sensors has DC current wiith two metallic electrodes printed on the silicon board which cause the electrolysis and the metals corrode by damaging the device permanently.

With capacitive sensor it outputs analog signals and the metallic parts are not exposed to water which tends to long time run of this device. as per the code our MCU fetches the sensor data through the sensor which is placed in the soil. if the soil is dry or wet the sensor will send values accordingly so the MCU will analyse the values and send the signal to the relay module and triggers the water pump accordingly.

With the same logic we can add blynk library to make this a real time monitoring device.

Required components

  • Arduino Uno R3 (or) Node MCU (or) Wemos D1 (or) ESP 32 (or) any compatible board
  • Capacitive soil moisture sensor
  • Water pump ( according to requirement)
  • single channel relay module
  • wires
  • 5V power supply

Features of capacitive soil moisture sensor:

  • Works from 3.3v to 5.5v
  • Output Voltage: 0 ~ 3.0 VDC

Method 1 : Using Arduino without real time monitoring

in this method we are using Arduino with sensor and relay with no display of data , everything runs internally. follow the below schematic diagram to connect components correctly.

Schematic diagram:

Automatic Plant watering system using Arduino schematic diagram

In the above circuit we Interfaced Arduino, Soil moisture sensor, Single channel relay and water pump. Here we had used two types of power supplies one for powering arduino (5v) and another for water pump (according to the pump requirement).

Moisture sensor connection

Connect the analog pin of the capacitive Soil moisture sensor to the A0 pin of the Arduino and + pin to the 3.3v and – pin to the GND.

Relay Module Connection

Connect the Trigger pin (IN) to one of the digital pin on Arduino here we used 13 pin, and connect the VCC to 5v from Arduino and GND to GND of Arduino. Also attach pipes for water input and output.

Water pump connection

Connect the + from the pump power supply to the relay normally open socket and then to the pump + wire, and connect the – from the supply directly to the pump – wire.

Source Code:

In the above code  const int air and const int water can be obtained from calibrating the capacitive soil moisture sensor, source code for calibration can be found at the bottom of the article.

Here we used map function to calculate soil moisture percentage the syntax of map function in Arduino  is given below

We added the values according to the plant watering techniques, we add the min percentage as 10% because if the soil becomes completely dry that will effect the plant, and in the same way maximum percentage where pump should be turned off to 85% to maintain the over water issue. You can modify those values according to your needs.

Method 2 : Using node MCU with real time monitoring using Blynk

This has same logic as method 1 but in this method we are using node MCU ( ESP 8266) instead of Arduino because it does not have network connectivity. Here we are adding blynk library to monitor the sensor data and control it over the mobile application. The circuit diagram for automatic plant watering system over network using ESP8266 is given below

Circuit Diagram:

smart automatic plant watering system using esp8266Here we just replaced the arduino with ESP8266 nodeMCU, you can use wemos D1 or ESP32 in place of nodeMCU. We connected the soil moisture sensor to the 5v power supply because the 3v supply from nodemcu is not sufficient.

Source Code:

You can Add the button to manually turn on and off the pump from blynk application.

Capacitive soil moisture sensor calibration code:

while calibrating follow the rules as shown in the below picture

capacitive soil moisture sensor calibration

Useful ideas:

  • To make the sensor last long apply nail polish enamel on the sides of the open silicon chip to protect from water.
  • Use a silicon or some tubing to protect the circuits above the warning line as they are not water proof.

If you find this project helpful please share it with your friends, and if you have any doubts or got any issues regarding this project please feel free to comment below. Your interest makes us happy and help to add more projects. Thanks and happy creations.

CircuitSchools Staff

We at CircuitSchools publish on basics of electronics and electric components and everything related to evolution of electrical technology with complete analysis of development boards and modules along with latest projects with innovative ideas.

Related Articles

Back to top button