Introduction: ESP8266 Smart Plant Irrigation System
In this tutorial we will show how to build plant irrigation system with ESP8266 and EasyIoT Cloud. With web interface we can control water pump and soil moisture remotely. Now you can go on holiday and irrigate plant with your phone.
Step 1: Introduction
Irrigation system features:
- remotely controlled water pump
- automatic irrigation if soil moisture is low
- automatic / manual mode
- soil moisture and water pump status display
- log soil moisture historical values
Irrigation can be triggered in WEB user interface. It this case pump will start for 10s. You can also use automatic mode. In this case you set threshold soil moisture in WEB interface. If soil moisture drops below this value pump will switch on for 10s. After 10 min will again check soil moisture and switch pump on if needed.
Step 2: Materials
- ESP8266 module
- water pump
- soil moisture sensor module
- regulator module 0-30V
- 12V power supply
- 2N2222 NPN transistor
- 5K resistor
Step 3: EasyIoT Cloud Configuration
Register to EasyIoT Cloud service. We will need custom module type for irrigation system. Follow EasyIoT Cloud module configuration tutorial to add new ZMT_IRRIGATOR module type.
Step 4: Program
Program is written in ESP8266 Arduino IDE. It uses ESP8266 MQTT EasyIoT Cloud library to communicate and configure EasyIoT Cloud. Program can be downloaded from our GitHub.
In program change following lines:
#define AP_SSID "xxx"
#define AP_PASSWORD "xxx"
#define EIOTCLOUD_USERNAME "xxx"
#define EIOTCLOUD_PASSWORD "xxx"
In first two lines set access point name and password, then set EasyIoT Cloud username and password. Then upload program to ESP8266 NodeMCU. You can also use different type of ESP8266 - then you need additional power supply and FDTI USB adapter.
Step 5: Hardware
For the sake of simplicity we will use ESP8266 NodeMCU. You can user any other ESP8266 type with additional 3.3V power supply.
Connecting soil moisture sensor
Use ESP8266 3.3 V power supply to power soil moisture sensor module. This means that you connect ESP8266 3.3V to VCC on sensor and ESP8266 GND with sensor GND. Then connect soil moisture sensor analog output (mark AO) to analog input on ESP8266 board A0. Leve DO on soil moisture sensor unconnected.
Connecting water pump motor to ESP8266
To connect water pump motor we will need relay module. Because relay module uses 5V power supply and ESP8266 uses 3.3V power supply we will add transistor to drive 5V relay with 3.3V. Transistor is connected to ESP8266 D0 pin trough resistor. If you connect relay directly to ESP8266 you will fry ESP8266. Other side of relay is connected to motor pump and adjustable power supply. Set voltage of motor pump between 6 and 9V.
Connecting manual button
If you are using ESP8266 NodeMCU you can use on board flash button to manually switch on and off motor pump. If you are using other type of ESP8266 then use 10K resistor one side connected to 3.3V and other side to D3 pin. Then connect D3 to GND trough push button.

Participated in the
Internet of Things Contest 2017
13 Comments
1 year ago
I would like to add the ability to set the time between waterings as well as the pump on time in the web interface. Can someone help me out with this please? Thx.
Question 3 years ago
What is the name if the transistor you used ?
3 years ago
Hey,
Can you post the schematic diagram? So that at least we know how to assemble parts and connect each circuit.
3 years ago
Why show MQTT error...any one solve this??please reply in comment box...
#advance_thanks
Reply 3 years ago
connection error.
4 years ago on Introduction
Can you please send me the full connection setup
5 years ago
am getting an error in the code downloaded at line
MQTT myMqtt("", EIOT_CLOUD_ADDRESS, 1883);
It is saying that 'MQTT' does not name a type
Can you please help me?
Thanks in advance
Awaiting for reply
Question 5 years ago
hello, I want to know how to connect the regulator module connections and can we use any regulator module?
thank u
Question 5 years ago on Step 5
Hello,I want to know that I cannot upload the program to the NodeMcu,.It show #include ESP8266wifi.h and EEPROM.h are orange colour. But MQTT.h is black .What missing of its.Thank !
The error message as follow:
C:\Users\Philip\Documents\Arduino\libraries\CMMC_MQTT_Connector\src\MqttConnector.h:7:25: fatal error: ArduinoJson.h: No such file or directory
6 years ago
Thanks for posting. But may i ask you a question.
If this project use web interface to control and monitor the system based on easyiot cloud platform, can i build an android app for control and monitor the system ? Maybe using the same or different cloud platform. And i can't see how you create web interface with some icon above just like step 1.
Thanks..
6 years ago
Could you link to which water pump you used? Thanks.
Reply 6 years ago
Here is list of materials with buying links:
http://iot-playground.com/blog/2-uncategorised/94-esp8266-smart-plant-irrigation-system#materials
Reply 6 years ago
Awesome - thanks!