ESP8266-Based Smart Irrigation System with Soil Moisture and Environmental Monitoring
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit is a crop monitoring system that utilizes various sensors to measure environmental parameters such as temperature, humidity, soil moisture, and air pressure. The system is controlled by an ESP8266 NodeMCU microcontroller, which processes the sensor data and controls a water pump via a relay module. The data is displayed on an I2C LCD screen.
Component List
ESP8266 NodeMCU
- Description: A microcontroller with built-in Wi-Fi capabilities.
- Pins: D0, D1, D2, D3, D4, 3V3, GND, D5, D6, D7, D8, RX, TX, A0, RSV, SD3, SD2, SD1, CMD, SD0, CLK, EN, RST, VIN
7.4V Battery
- Description: A power source for the circuit.
- Pins: +, -
Buck Converter
- Description: A DC-DC converter that steps down voltage from 7.4V to 5V.
- Pins: IN+, IN-, OUT+, OUT-
5V Mini Water Pump
- Description: A small water pump used for irrigation.
- Pins: Positive pin, Negative pin
5V Relay
- Description: A relay module used to control the water pump.
- Pins: Normally Open, Common terminal, Normally Closed, In, GND, VCC
9V Battery
- Description: An additional power source for the water pump.
- Pins: -, +
LDR Module 3 Pin
- Description: A light-dependent resistor module.
- Pins: VCC, GND, DO
DHT11
- Description: A temperature and humidity sensor.
- Pins: VCC, GND, DATA
ADS1115
- Description: A 16-bit ADC for reading analog sensor data.
- Pins: VDD, GND, SCL, SDA, ADDR, ALRT, A0, A1, A2, A3
Soil Moisture Sensor
- Description: A sensor to measure soil moisture levels.
- Pins: VCC, GND, SIG
BMP180
- Description: A barometric pressure sensor.
- Pins: 3.3, SDA, SCL, GND, VCC
PIR Sensor
- Description: A passive infrared sensor for motion detection.
- Pins: VDD, SIG, GND
MQ135
- Description: A gas sensor for air quality monitoring.
- Pins: VCC, GND, A0, D0
I2C Module
- Description: An I2C interface module for the LCD.
- Pins: SCL, SDA, VCC, GND
Wiring Details
ESP8266 NodeMCU
- GND: Connected to the GND pins of LDR Module, DHT11, PIR Sensor, MQ135, I2C Module, ADS1115, BMP180, 5V Relay, Soil Moisture Sensor, and Buck Converter (OUT-).
- 3V3: Connected to the VCC pins of LDR Module, DHT11, Soil Moisture Sensor, BMP180, and ADS1115 (VDD).
- VIN: Connected to the OUT+ pin of the Buck Converter.
- D1: Connected to the DATA pin of DHT11 and SCL pins of BMP180, I2C Module, and ADS1115.
- D2: Connected to the SDA pins of BMP180, I2C Module, and ADS1115.
- D3: Connected to the In pin of the 5V Relay.
- D5: Connected to the DO pin of the LDR Module.
- D6: Connected to the SIG pin of the PIR Sensor.
7.4V Battery
- +: Connected to the IN+ pin of the Buck Converter.
- -: Connected to the IN- pin of the Buck Converter.
Buck Converter
- IN+: Connected to the + pin of the 7.4V Battery.
- IN-: Connected to the - pin of the 7.4V Battery.
- OUT+: Connected to the VIN pin of the ESP8266 NodeMCU.
- OUT-: Connected to the GND pin of the ESP8266 NodeMCU.
5V Mini Water Pump
- Positive pin: Connected to the Common terminal of the 5V Relay.
- Negative pin: Connected to the - pin of the 9V Battery.
5V Relay
- GND: Connected to the GND pin of the ESP8266 NodeMCU.
- VCC: Connected to the OUT+ pin of the Buck Converter.
- In: Connected to the D3 pin of the ESP8266 NodeMCU.
- Common terminal: Connected to the Positive pin of the 5V Mini Water Pump.
- Normally Open: Connected to the + pin of the 9V Battery.
9V Battery
- +: Connected to the Normally Open pin of the 5V Relay.
- -: Connected to the Negative pin of the 5V Mini Water Pump.
LDR Module 3 Pin
- GND: Connected to the GND pin of the ESP8266 NodeMCU.
- VCC: Connected to the 3V3 pin of the ESP8266 NodeMCU.
- DO: Connected to the D5 pin of the ESP8266 NodeMCU.
DHT11
- GND: Connected to the GND pin of the ESP8266 NodeMCU.
- VCC: Connected to the 3V3 pin of the ESP8266 NodeMCU.
- DATA: Connected to the D1 pin of the ESP8266 NodeMCU.
ADS1115
- GND: Connected to the GND pin of the ESP8266 NodeMCU.
- VDD: Connected to the 3V3 pin of the ESP8266 NodeMCU.
- SCL: Connected to the D1 pin of the ESP8266 NodeMCU.
- SDA: Connected to the D2 pin of the ESP8266 NodeMCU.
- A0: Connected to the SIG pin of the Soil Moisture Sensor.
- A1: Connected to the A0 pin of the MQ135.
Soil Moisture Sensor
- GND: Connected to the GND pin of the ESP8266 NodeMCU.
- VCC: Connected to the 3V3 pin of the ESP8266 NodeMCU.
- SIG: Connected to the A0 pin of the ADS1115.
BMP180
- GND: Connected to the GND pin of the ESP8266 NodeMCU.
- VCC: Connected to the 3V3 pin of the ESP8266 NodeMCU.
- SCL: Connected to the D1 pin of the ESP8266 NodeMCU.
- SDA: Connected to the D2 pin of the ESP8266 NodeMCU.
PIR Sensor
- GND: Connected to the GND pin of the ESP8266 NodeMCU.
- VDD: Connected to the OUT+ pin of the Buck Converter.
- SIG: Connected to the D6 pin of the ESP8266 NodeMCU.
MQ135
- GND: Connected to the GND pin of the ESP8266 NodeMCU.
- VCC: Connected to the OUT+ pin of the Buck Converter.
- A0: Connected to the A1 pin of the ADS1115.
I2C Module
- GND: Connected to the GND pin of the ESP8266 NodeMCU.
- VCC: Connected to the OUT+ pin of the Buck Converter.
- SCL: Connected to the D1 pin of the ESP8266 NodeMCU.
- SDA: Connected to the D2 pin of the ESP8266 NodeMCU.
Code Documentation
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BMP085.h> // Library for BMP180
#include <LiquidCrystal_I2C.h> // Library for I2C LCD
#include <DHT.h> // Library for DHT11
// Pin definitions
#define DHTPIN D2 // Pin for DHT11 data
#define DHTTYPE DHT11 // DHT11 sensor type
#define RELAY_PIN D1 // Pin for relay module
#define MOISTURE_THRESHOLD 300 // Soil moisture threshold
// Initialize objects
DHT dht(DHTPIN, DHTTYPE);
Adafruit_BMP085 bmp;
LiquidCrystal_I2C lcd(0x27, 16, 2); // Set LCD address and size
// Soil moisture sensor connected to ADS1115 A0
int soilMoisturePin =