Arduino IOT Project: watering plants and soil moisture monitoring

(Last Updated On: July 17, 2019)

soil moisture

Description:

This is an iot based project designed for monitoring the Soil moisture and controlling the Solenoid valve from anywhere around the world. The soil moisture is monitored using the Blynk application. This project is based on the Nodemcu esp8266 wifi module, soil moisture sensor, Solenoid Valve, and Arduino Uno or Mega.

In this project two-way communication is used, we can monitor the soil moisture and also control the Solenoid valve in Realtime.

If you are working on the moisture sensor for the first time then I recommend you should watch my getting started tutorial on the moisture sensor, in which I explained all the basics, including the moisture sensors modes “digital and analog” , the purpose of the potentiometer and leds, the basic circuit connections and programming explaining everything.


The components and tools used in this project can be purchased from Amazon, the components Purchase links are given below:

Arduino Uno: https://amzn.to/2tVz1vu
Mega 2560: https://amzn.to/2ze1kdu
Soil Moisture Sensor: https://amzn.to/2W5IkFz
Nodemcu esp8266 wifi module: Best price: https://amzn.to/2NAvmiB
12v 10A SPDT relay: https://amzn.to/2MThQBK
2n2222 npn transistors: https://amzn.to/2EmXsIb
10k Resistor: https://amzn.to/2KTd6OW
lm7805 Voltage Regulator: https://amzn.to/2IZEl5x
330-ohm resistors pack: https://amzn.to/2NtlAeh
female DC power jack socket: https://amzn.to/2KEo1gt
470 uf capacitors: https://amzn.to/2xDCOzf
5×7 cm vero board: https://amzn.to/2OHGbvn
female headers: https://amzn.to/2zqmtiJ
connection wires: https://amzn.to/2DpBuW7
Super Starter kit for Beginners: https://amzn.to/2KJvmKG
Jumper Wires: https://amzn.to/2KMoVXs
Bread Board: https://amzn.to/2MS4q8X
12v Adaptor: https://amzn.to/2Ntr6h1
PCB plate: https://amzn.to/2IUwpCt
Variable Supply: https://amzn.to/2MT4Qfj
Digital Multimeter: https://amzn.to/2Nvft9i
Vero Board / strip board: https://amzn.to/2MTf9jD
Soldering iron kit: “best” You guys should definitely purchase this: https://amzn.to/2zfoNuJ
Solder wire: https://amzn.to/2ufUMWf
Wire Stripper: https://amzn.to/2KOqxfU
wire cutter: https://amzn.to/2ucIq14
PCB small portable drill machine: https://amzn.to/2Nu62XF

Circuit Diagram:

soil moisture

9.1.0 version of the cadsoft eagle software is used for making the schematic. The Nodemcu module tx and Rx pins are connected with pin2 and pin3 of the Arduino. while the Vin pin of the Nodemcu module is connected with the output of the voltage regulator. This is a regulated 5v power supply based on the lm7805 voltage regulator. Two 470uf capacitors are connected at the input and output side of the regulator.  A 330-ohm resistor is connected in series with a 2.5v led. This is a current limiting resistor. while J1 is a dc female socket, over here you can connect a 12v adaptor or battery. But you can also power up the Nodemcu module using your laptop USB port. But in my case, I am going to use a 12v adaptor.

The soil moisture Sensor VCC pin is connected with Arduino’s 5v, the ground is connected with the Arduino’s ground while the A0 pin of the moisture sensor which is the analog output pin of the moisture sensor is connected with the Arduino’s analog pin A1. While the digital output pin of the moisture sensor is not connected.  While the remaining two pins are connected with the two-legged lead.

These two relays will be used to control the Solenoid valve and the water pump.


For controlling these relays we will need relay drivers, the relay drivers simply consists of the 2n2222 NPN transistors, 10k  resistors, and diodes. As you can see a 10k resistor is connected with the base of 2n2222 NPN transistor as it’s a BJT “bipolar junction transistor” a current controlled device, that’s why we need a current limiting resistor. We usually use a 10k resistor. The emitter of the 2n2222 NPN transistor is connected with the ground while the collector is connected with one side of the relay coil, while the other side of the relay coil is connected with 12volts. This relay can be energized and de-energized using this transistor.  As you can see this relay consists of 5 pins, two coil pins, common, normally closed and normally open. These three pins have no physical connection with the coil pins…. In my previous tutorial based on home automation using Nodemcu and Blynk application, I have explained this in very detail, and in that tutorial, I also explained how to connect a lamp or any other load with the relays output watch video tutorial on my YouTube channel. All the connections are exactly the same. These are freewheeling diodes, used against back emf protection.

Blynk application Designing:

soil moisture

Follow the Following steps or watch video at the end of this Article for the best understanding.

  1. First of all open the blynk application
  2. set the project name as Soil Moisture.
  3. Click on the choose device and select Nodemcu and make sure you set the connection type to wifi and then click on the create button, an authentication token will be sent on your email id, which will be then used in programming, simply copy and paste it in programming.
  4. Click anywhere on the screen and search for the gauge and add it, click on the gauge and set the name as Soil Moisture. now click on the pin and select virtual and select v2. Set the maximum value to 1023, change the font then click on the push and select 1 second.
  5. now click on the screen and add two numeric input buttons which will be used for controlling the solenoid valve and water pump……click on the numeric input…set the name as solenoid valve….click pin and select the virtual pin10…set the minimum value to 10 and the maximum value to 11.these 10 and 11 values will be used to control the relay connected with pin13 of the Arduino. …now repeat the same steps for other numeric input button.


Programming:

In this project two programs are used, one program is written for the Arduino, while another program is written for the Nodemcu esp8266 wifi module.

Arduino Programming:

we simply ready the moisture using the analogread function and store the value in variable msvalue. Then using the serial.println function the value is send to the serial monitor for the debugging purposes  and then save the value in variable sdata1. And then add the value of this variable with the cdata and use comma as the delimeter for separating the sensor value. Then we send the complete message to the Nodemcu module and use a delay of 1 second and then at the end empty the cdata variable for storing new values.

Nodemcu esp8266 wifi module programming:

Watch Video Tutorial:

Recommended For You

About the Author: Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

4 Comments

  1. Pretty element of content. I simply stumbled upon your
    site and in accession capital to say that I get actually
    loved account your weblog posts. Anyway I’ll be subscribing
    in your augment and even I achievement you get admission to constantly quickly.

Leave a Reply