Professional Documents
Culture Documents
Iot Based Smart Irrigation System Using Nodemcu Esp8266 & Adafruit Io
Iot Based Smart Irrigation System Using Nodemcu Esp8266 & Adafruit Io
Iot Based Smart Irrigation System Using Nodemcu Esp8266 & Adafruit Io
IoT Based Smart Irrigation System Using NodeMCU ESP8266 & Adafruit IO
by Asis Gotam
Farmers across the world face a lot of di culties in In this project, we are building an IoT ba s e d s m a rt
growing crops because of unpredictable weather irrig a t io n Sy s t e m us ing No de M CU , Moisture
conditions and shortage of water. The traditional sensor, and LDR. It will automatically sprinkle the
irrigation system uses a large amount of water and water to plants when the moisture value goes below a
supplies uneven water to corps. This a ects the particular value. It will also send the moisture data to
quality of crops. Adafruit IO Server to keep track of the land condition.
Adafruit IO dashboard will also have some buttons to
Many farmers already start using the Greenhouse manually turn on/o the solenoid valve and lights.
farming and Smart Irrigation System. Emerging IoT This project uses a solenoid valve to supply the water
technologies and sensors are used to develop the to the plants. You can change the moisture value at
irrigation system that can automatically supply water which the solenoid valve should turn on according to
according to climate conditions like moisture value, your plant's requirement. Here we are using
temperature, etc. NodeMCU ESP8666 which is a very popular Wi-Fi
module for IoT-based Projects.
Ha rdw a re
NodeMCU ESP8266
Soil Moisture Sensor Module
IoT Based Smart Irrigation System Using NodeMCU ESP8266 & Adafruit IO: Page 1
LDR10K Pot
solenoid valve
Relay Module
LED
O nline S e rv ice s
Adafruit IO
In this circuit, the Soil sensor is connected to the A0 pin of NodeMCU. LDR sensor is connected to the D1 pin, and
the Relay module is connected to the D0 pin of NodeMCU. Solenoid Valve is connected to the relay module, so
whenever NodeMCU generates a trigger, it will sprinkle water.
1. To use Adafruit IO, rst, you have to create an 6 . As the dashboard is created now, we will add our
account on Adafruit IO. To do this, go to the Adafruit feeds to the dashboard. To add a feed, click on the ‘+’
IO website and click on ‘Get started for Free’ on the in the top right corner.
top right of the screen.
First, we will add two toggle buttons blocks to control
2. After nishing the account creation process, log in the LED and solenoid valves. And then one Graph
to your account and click on ‘AIO Key’ on the top right block for Moisture Data.
corner to get your account username and AIO key.
When you click on ‘AIO Key,’ a window will pop up with To add a button on the dashboard, click on the Toggle
your Adafruit IO AIO Key and username. Copy this key block.
and username, it will be needed later in the code.
In the next window, it will ask you to choose the feed,
so click on LED feed.
IoT Based Smart Irrigation System Using NodeMCU ESP8266 & Adafruit IO: Page 3
Step 4: Programming NodeMCU for Smart Irrigation System
IoT Based Smart Irrigation System Using NodeMCU ESP8266 & Adafruit IO: Page 4
Complete source code for Sm a rt Irrig a t io n arduino.esp8266.com/stable/package_esp82... into the
Sy s t e m is available in the attachment. ‘Additional Board Manager URL’ eld and click ‘Ok’.
Here we are explaining the program step by step so Now go to Tools > Board > Boards Manager.
that you can easily understand the working of this
code. Start your code by including all the required
libraries.
To program the NodeMCU for Smart Irrigation In Boards Manager window, Type esp in the search
System, plug the NodeMCU into your laptop with a box, esp8266 will be listed there below. Now select the
Micro USB Cable and open Arduino IDE. In this latest version of the board and click on install.
program, only the Adafruit MQTT library is used as an
external library. You can download the library from After installation is complete, go to Tools >Board >and
here: select NodeMCU 1.0(ESP-12E Module). Now you can
program NodeMCU with Arduino IDE.
Adafruit_MQTT.h
Then include the WiFi and Adafruit IO credentials that
you copied from the Adafruit IO server. These will
To program NodeMCU with Arduino IDE go to File– include the MQTT server, Port No, User Name, and AIO
>Perferences–>Settings. Key
Enter https:// Set up the feeds you're subscribing to. Here ‘LED’ and
Read the LDR reading from the A0 pin and compare Publish the moisture data to Adafruit IO feed every 5
the reading. If the reading is less than 200, then turn seconds.
on the LED else turn o the led.
Read the subscribed feeds. If the string is ‘OFF’ is then
Read the moisture reading from the sensor and turn on the LED/Water pump and if the string is ‘ON,’
compare the readings with the required value. If it is then turn o the LED/water pump.
less than the required value then turn on the water
Download
https://www.instructables.com/ORIG/FX0/BO5H/KGQJZ06T/FX0BO5HKGQJZ06T.ino
IoT Based Smart Irrigation System Using NodeMCU ESP8266 & Adafruit IO: Page 5
This is how No de M CU ba s e d Sm a rt Irrig a t io n Comment below if you have any doubts regarding
Sy s t e m us ing IoT works. You can expand this this project and check the demonstration video.
project by using more sensors to measures the other
parameters like humidity, pressure, temperature, etc. Also, Follow us on Instructables for more such
We have previously built an ESP8266 based weather interesting projects.
station to read all these values.
https://youtu.be/bVv8q4_pBNw
IoT Based Smart Irrigation System Using NodeMCU ESP8266 & Adafruit IO: Page 6