ESP8266 Lora based IoT Smart Irrigation System with Cell Phone App

(Last Updated On: July 7, 2020)

ESP8266 Lora


ESP8266 Lora based IoT Smart Irrigation System– In this tutorial; you will learn how to make an IoT Smart Irrigation system using Nodemcu ESP8266 Wifi module, 15Km Lora Transceiver modules, Arduino Nano, and Capacitive Soil Moisture Sensor V1.2.

ESP8266 Lora

This area is around 6 Kilometers from my friend’s house. Currently in this area no GPRS signals are received and as per my friend’s demand, he wants to monitor the soil moisture on his Cell phone.

As no internet is available in this area, so we cannot use any internet supported devices like the Nodemcu ESP8266 or ESP32 modules on the transmitter side. So due to the 6 kilometers long distance we will have to use long-range radio frequency modules.

Thanks to the Reyax Technologies for making such an amazing Long Range 15Km transceiver modules. On the transmitter side, the Lora module is used with the Arduino Nano to send the Sensors data to the Receiver. ON the receiver side, the Lora module is connected with the Nodemcu ESP8266 Wifi module. At this point, you can directly connect the Nodemcu Module with the Laptop and monitor the data on the serial monitor or you can design a cell phone application and monitor the data from anywhere around the world.

ESP8266 Lora

For the demonstration purposes, I connected a variable resistor, I can monitor the values in real-time, notification messages are sent when the Sensor value increases above or decreases below a certain pre-defined value. These values are sent from the transmitter side through a 15Km Lora transceiver module, on the receiver side another 15Km Lora transceiver module is connected with the Nodemcu ESP8266 Wifi Module which receives the data and then sends it to the Blynk application. After performing all the basic tests, finally, I soldered all the components on the Vero boards and fixed the transmitter side in a waterproof plastic enclosure.

ESP8266 Lora

The capacitive soil moisture sensor was working great, there was no disconnection, and I was able to receive the moisture values in real-time.

The type of the capacitive soil moisture sensor I used was later damaged due to the exposed electronic components, that’s why I ordered another capacitive soil moisture sensor which is completely waterproofed.

ESP8266 Lora

I have been testing this IoT smart irrigation system and is working perfectly, without any problem.

The Reyax Lora Module Pinout, Technical Specifications, Basic programming, interfacing, and AT commands are already explained in my previous tutorials. If you are using the Reyax rylr890 based Lora module for the first time then I highly recommend first watch my previous tutorials which cover the extreme basics and then you can resume from here.

In this tutorial, we will cover,

  1. Transmitter and Receiver circuit diagrams explanation
  2. Transmitter and receiver side programming and finally
  3. Testing

Without any further delay let’s get started!!!

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

Purchase from Amazon:

Nodemcu ESP8266 Wifi Module:

Capacitive Soil Moisture Sensor V1.2:

Reyax rylr890 Lora Transceiver Module:

4.7k resistors:

10k resistors:

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

About the Reyax rylr890 Lora Transceiver Module:

ESP8266 Lora

These are the long range wireless 915Mhz Radio Frequency LoRa Transceiver Modules by the Reyax Technology. The amazing thing about these modules is that, we can change the frequencies using the AT commands, which I will explain in a few minutes. These modules are designed for the long range communication up to 15 kilo meters. LoRa transceiver modules can be used in IoT applications, Mobile Equipments, Home security systems, Industrial Monitoring and control equipment, Car Alarm system, Robotics, sensors monitoring, and so on.

This transceiver module has the processor which communicates with the Arduino through the Serial communication. So, the exchange of data between the rylr890 and a microcontroller is controlled by this processor. Now let’s open the datasheet and have look at the specifications.

Reyax rylr890 LoRa Transceiver Module Specification.

VDD Power Supply:

The minimum voltage is 2.8 volts

The Typical Voltage is 3.3 volts

The Maximum voltage is 3.6 volts

Using Arduino I can easily power up these transceiver modules using 3.3 volts.

Frequency Range:

Minimum Frequency Range is 820 MHz

Typical Frequency Range is from 868 to 915 MHz

Maximum Frequency range can be up to 1020 MHz

Communication Range:

Typical Range is 4.5KM

Maximum Range is 15KM

Transmit Current:

Typical value is 43 mA

Receive Current:

Typical value is 16.5 mA

Reyax LoRa Module Pinout:

As you can see in the picture above this transceiver module has a total of 6 pins; which are clearly labeled as VDD, NRST “which is the reset pin active low”. RXD, TXD, pin number 5 is not used, while pin number 6 is the ground.

About the Capacitive soil moisture sensor V1.2:

ESP8266 Lora

This is a soil moisture sensor which measures soil moisture levels by capacitive sensing rather than resistive sensing like other sensors on the market. As I said earlier this capacitive sensor by the DFROBOT is made of corrosion resistant material which gives it an excellent service life.

ESP8266 Lora

The capacitive soil moisture sensor is used just like the Resistive soil moisture simply insert it in to the soil around your plants and make an amazing low cost real time soil moisture monitoring system.

This module includes an on-board voltage regulator which gives it an operating voltage range of 3.3 to 5.5V. It is perfect for low-voltage MCUs, both 3.3V and 5V.

Capacitive Soil Moisture Specification:

Operating Voltage: 3.3 ~ 5.5 VDC

Output Voltage: 1.2 ~ 2.5V

Interface: PH2.0-3P

Dimension: 98mm * 23mm (3.86in x 0.905in)

Weight: 15g


Supports Gravity 3-Pin Interface

Analog Output


Gardening & Farming

Moisture Detection

Intelligent Agriculture

ESP8266 Lora

This white line is the warning line, which means don’t insert this into the soil or the sensor will be damaged. Some Capacitive soil moisture sensors available in the market does not have this warning line; so no matter if the line is present or not don’t insert this sensor completely into the soil. That’s why my sensor was damaged too, due to which then I purchased another capacitive soil moisture sensor like the one you can see in the picture below, in which the electronic components are completely sealed.

ESP8266 Lora

ESP8266 Lora

This soil moisture sensor is provided with a connector which is clearly labeled as GND, VCC, and AOUT. The GND and VCC are the power pins and these should be connected with the Arduino’s GND and 5V.  While the AOUT is the analog output pin which can be connected to any analog pin of the Arduino board.

Study more about the Capacitive Soil Moisture sensor.

ESP8266 Lora based IoT Smart Irrigation System Transmitter Circuit Diagram:

ESP8266 Lora

As you know Arduino Nano is based on the 5v controller while the LoRa transceiver module by the Reyax technology can handle voltages from 2.8 to maximum 3.6 volts. The typical voltage is 3.3 volts as per the datasheet. From this information we know that this module cannot be directly interfaced with the Arduino for this we need some kind of converter which can convert 5 volts into 3.3 volts. But instead of using the converter we can use a simple voltage divider circuit. As you can see 4.7k and 10k resistors are connected in series which gives me 3.4 volts which is perfect for the Reyax LoRa Transceiver module.

A wire from the middle of these resistors is connected with the RXD pin of the Lora module, the other leg of the 10k resistor is connected with the ground, while the other leg of the 4.7k resistor is connected with the TX of the Arduino Nano. The Rx pin of the Arduino Nano is connected with the TXD pin of the LoRa Module. The ground of the LoRa module is connected with the ground of the Arduino Nano.  If you want to use the Arduino Uno you can still follow the same exact connections.

The Ground and VCC pins of the Capacitive Soil moisture sensor are connected with the ground and 5v pins of the Arduino Nano while the Analog output pin of the Capacitive Soil Moisture sensor is connected with the analog pin A1 of the Arduino Nano.

Now let’s have a look at the receiver circuit diagram.

ESP8266 Lora based IoT Smart Irrigation System Receiver Circuit Diagram:

ESP8266 Lora

The IoT Smart Irrigation system Receiver circuit is based on the Nodemcu ESP8266 Wifi Module and 15km Lora transceiver module by the Reyax technology.

So first let’s start with the 5V regulated power supply based on the LM7805 Voltage regulator. The positive and GND pins of the DC female power jack are connected with the input and middle legs of the 7805 voltage regulator. Two 470uf capacitors are connected at the input and output sides of the voltage regulator. A 330 ohm resistor is connected in series with a 2.5V LED. This is a current limiting resistor. A wire from the output of the voltage regulator is connected with the Vin pin of the Nodemcu ESP8266 Wifi module while the ground of the power supply is connected with the ground pin of the Nodemcu module.

The 15Km Lora transceiver module interfacing with the Nodemcu ESP8266 Wifi Module is very simple, while interfacing Lora transceiver module with the Nodemcu ESP8266 you don’t need any voltage converter or a voltage divider. You can start by simply connecting the VDD and GND with the Nodemcu module 3.3V and ground pins. While the Tx pin of the Lora module is connected with the Rx Pin of the Nodemcu ESP8266 and the Rx pin of the Lora module is connected with the Tx pin of the Nodemcu Module. So that’s all about the Transmitter and Receiver circuit diagrams.

About the Nodemcu ESP8266 and Reyax Lora Power Supply PCB boards:

For the easy interfacing, I designed PCB boards for the Reyax Lora Module and Nodemcu ESP8266 Wifi module.

ESP8266 Lora

ESP8266 Lora
DIY IoT Weighing Scale using HX711 Load Cell, Nodemcu ESP8266, & Arduino

High quality & Only 24 Hours Build time

The PCB boards used in this project are sponsored by the PCBWay Company. PCBWay is quite professional in the field of PCB manufacturing; you can try their services at extremely low prices, Only 5 dollars for 10 PCBs and 30 dollars in total for 20 PCBs assembly, besides this the new members also get a 5 Dollars bonus. The Gerber files of the PCB boards used in this project can be downloaded from the PCBWay official website, the download links are given below.

As you can see the quality is really great. The silkscreen is quite clear and the blue and black solder mask looks amazing. I am 100% satisfied with their work.

Nodemcu ESP8266 Power supply PCB board Gerber files:

Lora Module Power Supply PCB board Gerber files:


ESP8266 Lora

I completed the soldering very carefully, and in the end I tested all the connections and luckily there were no short circuits.

Finally, I connected everything as per the circuit diagram already explained.

Transmitter side:

ESP8266 Lora

Receiver Side:

ESP8266 Lora

Now, let’s make the Blynk application.

ESP8266 Lora based IoT Smart Irrigation System Blynk Application Designing:

I always first start with the Blynk application designing, this way I know which digital and virtual pins I have to use in the programming. Moreover this also helps me in checking my code, as I keep testing my project. Make sure you have downloaded and installed the Blynk application.

  • First of all open the blynk application.
  • Click on the new project and enter the project name as “ESP8266 LORA”. If you want you can select any other name. Later you can also modify the name.
  • Click on the choose device and select Nodemcu.
  • Make sure the connection type is set to WIFI.
  • Finally, click on the create button, an authentication token will be sent on your email id, which later will be used in the Nodemcu programming.
  • Click anywhere on the screen and search for the Gauge widget and add it.
  • Click on the gauge, enter the name as Soil Moisture, then click on the input and select virtual pin V2, change the font size if you want. Now, click on the back button to go to the main screen.
  • Again click on the screen and this time search for the notification widget and add it. That’s it. Our Blynk application is read. Your application should look like the one you can see in the picture below.

ESP8266 Lora

ESP8266 Lora based IoT Smart Irrigation System Transmitter and Receiver programming:

The IoT smart irrigation system project is based on two programs. One program is written for the Transmitter side, while the other program is written for the Receiver side. Let’s first start with the transmitter side programming.

ESP8266 Lora based IoT Smart Irrigation System, Transmitter programming:

Iot Smart Irrigation system transmitter code explanation:

I started off by defining a pin for the capacitive soil moisture sensor, the analog output pin of the moisture sensor is connected with the Arduino’s analog pin A1. I also defined a variable of the type integer for storing the moisture sensor value.

Then I defined two variables data_length and sensorsdata of the type integers.

Inside the void setup() function, I activated the serial communication and selected 115200 as the baud rate, and finally set the capacitive soil moisture sensor as in the input using the pinMode() function.

Inside the void loop() function, we have only two user-defined functions which are the multiplesensors() and send_data() functions.

The MultipleSensors() function is used to read the capacitive soil moisture sensor, and to make a complete string message using percent sign as the delimiter and to find the data length.

While the send_data functions is used to send the complete message consisting of the data length and sensor value. So, that’s all about the transmitter programming. Now, let’s have a look at the receiver programming.

ESP8266 Lora based IoT Smart Irrigation System, Receiver programming:

IoT smart irrigation project receiver code explanation:

On the receiver side, before you start the programming first of all, make sure you download all the necessary libraries.

char auth[] = “LnMZlB1ZiT1kgYW1uGgc-yiPflg6BRav”;

This is the authentication code which was sent while making the blynk application. I simply copied and paste it over here.

char ssid[] = “AndroidAP7DF8”; // name of the Wifi Router

char pass[] = “electronic_clinic”; // password

Defined a timer, some variables of the type string, char and integer. I also defined a pin for the relay and a flag to stop the unnecessary repetition of code.

As usual inside the void setup() function, I activated the serial communication, set relay as the output. Blynk.begin() function takes three arguments as the input, the authorization code, the ssid, and the password.sensorvalue1 and Receivedata are two user-defined functions which are executed after every 1 second.

Inside the void loop() function we have only two functions which are the and functions.

Receivedata() function is a user defined function, it has no return type and does not take any arguments as the input. the purpose of this function is to check if the Arduino has received any data from the Lora Module. Split the entire string message, the different parameters are stored in different variables.

Finally, the capacitive soil moisture sensor value is stored in variable q which is of the type string which is then converted into integer.

The conditions are used to check the sensor value received from the transmitter and turn ON and Turn OFF the relay connected with D0 pin of the Nodemcu Module.

Currently, I am using 20 and 30 as the predefined values. You can change these values as per your requirement.

The purpose of the relayf is to stop the repetition of code.

sensorvlaue1() is also a user-defined function, it has no return type and does not take any arguments as the input. The purpose of this function is to send the capacitive soil moisture sensor value to the Blynk application Gauge widget, the two conditions are used to send the notification messages as the soil moisture decreases or increases above the pre-defined values.

Finally, the getValue() function is used to split the string message using any character as the delimiter.

So that’s all about the programming.

In the end, I successfully monitored the soil moisture value in real-time, below are the some images which explains everything.

ESP8266 Lora

ESP8266 Lora

This ESP8266 LORA based IoT smart irrigation system was a great success. You can easily modified this project. New sensors can be added. You can power the transmitter side using a Solar Panel. For the step by step explanation and practical demonstration watch video given below.

If you have any questions regarding this project or any other project, let me know in a comment. Don’t forget to subscribe to my website and YouTube channel “Electronic Clinic”.

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...


  1. hi . engr. Its great idea since i was the soil scientist, and im already doing the same thing, but i store it to thingspeak.
    I managed 3 sensors on 1 wemos mini. it result send via ESPNOW (TTGO LORA v1 – field) and it send to TTGO LORA (home). I need data from LORA (home) publish to thingspeak, but i have nothing in thingspeak. Its because ‘LoRa receiver’ show all LoRaData (LoRa.parsePacket), meanwhile thingspeak need to split it into 3 fields.
    Would u help me , please : what ‘s code that we can use to split LoRaData in receiver side ?
    best regards


Leave a Reply