Iot Based Smart Irrigation System Using Nodemcu Esp8266 & Adafruit Io

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

instructables

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.

Step 1: Components Required

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

Step 2: Circuit Diagram for Smart Irrigation System Using IoT

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.

Step 3: Adafruit IO Setup for Smart Irrigation System


IoT Based Smart Irrigation System Using NodeMCU ESP8266 & Adafruit IO: Page 2
Adafruit IO is an open data platform that allows you For this project, we created a total of three feeds- for
to aggregate, visualize, and analyze live data on the solenoid valve, moisture data, and LED. After creating
cloud. Using Adafruit IO, you can upload, display, and feeds, now create an Adafruit IO dashboard to show
monitor your data over the internet, and make your all of these feeds on a single page.
project IoT enabled. You can control motors, read
sensor data, and make cool IoT applications over the To create a dashboard, click on the Dashboard option
internet using Adafruit IO. For test and try, with some and then click on the ‘Action,’ and after this, click on
limitation, Adafruit IO is free to use. We have also used ‘Create a New Dashboard.’ In the next window, enter
Adafruit IO with Raspberry Pi previously. the name for your dashboard and click on ‘Create.’

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.

After this, follow the same procedure to create


3. Now, after this, you need to create a feed. To create another Toggle button block for the solenoid valve.
a feed, click on ‘Feed.’ Then click on ‘Actions,’ and then
on ‘Create a New Feed’ as shown in the image below. 7. Now to add the Graph on your dashboard, follow
the same procedure, but instead of creating a RESET
4 . After this, a new window will open to enter the block, create a Line Chart block for graph view. After
Name and Description of the feed. The writing creating all the blocks, my dashboard looks like this:
description is optional. You can edit your dashboard by clicking on the
settings buttons.
5. Click on ‘Create,’ after this; you will be redirected to
your newly created 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

Set up the feed you're publishing to. Here


AgricultureData is the feed name.

Enter https:// Set up the feeds you're subscribing to. Here ‘LED’ and

‘Pump’ are the feed names. pump else turn it o .

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

Step 5: How NodeMCU Based Smart Irrigation System Works

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

You might also like