IoT Based Smart Irrigation System
IoT Based Smart Irrigation System
Embedded Systems(EE512)
PROJECT
Topic:
BACKGROUND:
In this Project, I will work with Smart irrigation System that has wide scope to
automate the complete irrigation system. Here I will be building an IoT based
Irrigation System using ESP8266 NodeMCU Module,Arduino Uno , Soil Moisture
Sensor Module and DHT11 Sensor. It will automatically irrigate based on the
moisture level in the soil, Temperature and Humidity of ambient and also send the
Data to ThingSpeak Server to keep track of the land condition. The System also
consist of a water pump module which will be used to sprinkle water on the land
depending upon the land environmental condition such as Moisture, Temperature
and Humidity.
Apparatus Used:
This DC operated mini submersible water pump is ideal for small vending machines and
other applications, in which a small amount of water has to be pumped. The operating
voltage for this DC pump is between 3 to 12V and can be easily controlled with
development boards like Arduino, Raspberry Pi, ESP, and other microcontrollers, so
also frequently used in DIY electronics projects and hobby projects. The pumping height
for this mini DC water pump is between 40 to 110 cm.
Description: The soil moisture sensor is commonly used in smart agriculture or other garden
automation projects to measure the moisture content present in the soil. It consists of 4 pins in
which two pins, Vcc and Gnd are connected to supply voltage. The remaining two pins are digital
(D0) and analog (A0) are the output pins. When the moisture content present in the soil goes
beyond the threshold level, the output of the digital pin (D0) will go low (the output of the digital
pin is either logic 0 or 1). The threshold value of the sensor module can be set by varying the
onboard potentiometer. The analog output pin can be used to calculate the approximate level of
moisture content present in the soil.
Description: It’s is a basic and low-cost digital temperature and humidity sensor. This comes in a
blue perforated plastic enclosure. This has three pin,which are Vcc, Gnd and Data pin.
Description: This 5V Relay module helps us to switch (control) AC/DC loads from a
microcontroller like Arduino, PIC, ARM etc. We can turn on or turn off loads that consume upto
10A using this Relay module. The module also comes with a power indicator led and signal
indicator led. Input/Trigger voltage: 5V
Since this Relay Module require 5 volt Input for energizing its coil, I used Arduino uno for
actuation because node-mcu can provide a max voltage of 3.3 V only (Since I was not having any
external module to be integrated with node -mcu to give the control command to relay ).
Flow Diagram:
Circuit Visualization
Experimental Setup
Coding
The code for both Arduino Uno and ESP8266 NodeMCU is given below:
ESP8266 NodeMCU-IOT
IOT
#include <DHT.h>
#include <ESP8266WiFi.h>
String apiKey = "90LV9J03WOB581W6"; // My API key
const char* server = "api.thingspeak.com";
const char *ssid = "Alexa"; // My WiFi Name
const char *pass = "ES-Project"; // My WiFi Password
#define DHTPIN D3 // GPIO Pin where the dht11 is connected
DHT dht(DHTPIN, DHT11);
WiFiClient client;
void setup()
{
Serial.begin(115200);
delay(10);
dht.begin();
Name: Aditya Shah Roll: 2011mt02
Serial.println("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print("."); // print ... till not connected
}
Serial.println("");
Serial.println("WiFi connected");
}
void loop()
{
unsigned long currentMillis = millis(); // grab current time
if (isnan(h) || isnan(t))
{
Serial.println("Failed to read from DHT sensor!");
return;
}
moisturePercentage = (100.00-((analogRead(moisturePin)/(1023.00))*100.00));
void sendThingspeak() {
if (client.connect(server, 80))
{
String postStr = apiKey; // add api key in the postStr
string
postStr += "&field1=";
postStr += String(moisturePercentage); // add mositure readin
postStr += "&field2=";
postStr += String(t); // add tempr readin
postStr += "&field3=";
postStr += String(h); // add humidity readin
postStr += "\r\n\r\n";
ARDUINO CODINGS-ACTUATION
const int motorPin = 8;
int moisturePercentage;
const int moisturePin = A0;
unsigned long interval1 = 1000;
unsigned long previousMillis1 = 0;
void setup() {
Serial.begin(115200);
delay(10);
pinMode(motorPin, OUTPUT);
void loop() {
It worked correctly and thus, the microcontroller is sending the Data to ThingSpeak Server to keep
track of the land condition i.e, Temperature ,Humidity and moisture information, in a interval of
10 seconds as programmed in Node-MCU.
Working:
Here in this Project,I have used Arduino Uno and NodeMcu , Sensor as discussed above and
Pump Module.So basically ,the sensor will provide the Ambient condition data to NodeMcu
and Arduino Uno .The NodeMcu after getting the data from the sensor, will send the data to
server ,to visualize the ambient condition graphically. The only reason of using Arduino Uno
,is the inability of NodeMCU of providing 5V O/P (NodeMcu at max can give 3.3V) and for
actuating the Relay ,we need 5 V for it’s proper functioning. So I used the Arduino
Uno,which after analyzing the sensor data, will actuate the pump when the ambient
parameter crosses below the predefined threshold value .
Conclusions: So through the Project, I learnt about the two microcontroller and also how to
interface various sensor used ,to those microcontroller. I also understood how to setup the
channel in ThingSpeak and how to connect the same with NodeMCU ,to send the data of
ambient parameters to Server at every predefined time periodically. Thus, with this I
successfully implemented the Automated Soil Irrigation System.