An IoT-based smart irrigation system that automatically monitors soil moisture and controls a water pump using ESP32 and relay logic.
The Automated Irrigation Controller is designed to reduce water wastage by automatically irrigating plants only when the soil becomes dry.
The ESP32 continuously reads the analog value from the soil moisture sensor. Based on a predefined threshold, it decides whether to activate or deactivate the relay, which simulates the operation of a water pump.
This project demonstrates the implementation of:
- Analog-to-Digital Conversion (ADC)
- Closed-loop control system
- Threshold-based decision making
- Relay interfacing
- Non-blocking programming using
millis()
- Read real-time soil moisture values.
- Process analog sensor data using ESP32 ADC.
- Automatically control a relay module.
- Simulate an automatic irrigation system.
- Implement efficient timing using
millis()instead ofdelay().
| Component | Quantity |
|---|---|
| ESP32 DevKit V1 | 1 |
| Soil Moisture Sensor (Simulated using Potentiometer) | 1 |
| Relay Module (5V) | 1 |
| LED (Pump Indicator) | 1 |
| 220Ω Resistor | 1 |
- Arduino IDE
- Wokwi Simulator
- Git & GitHub
-
ESP32 reads the analog value from the soil moisture sensor.
-
The measured value is compared with a predefined threshold.
-
If the soil is dry:
- Relay turns ON
- Pump starts
-
If the soil is sufficiently wet:
- Relay turns OFF
- Pump stops
-
The system continuously repeats this process every second using
millis()without blocking the processor.
Start
│
▼
Read Soil Moisture
│
▼
Compare with Threshold
│
┌─┴──────────────┐
│ │
▼ ▼
Dry Soil Wet Soil
│ │
▼ ▼
Relay ON Relay OFF
│ │
▼ ▼
Pump ON Pump OFF
- ESP32 based IoT project
- Automatic irrigation control
- Analog sensor interfacing
- Relay control logic
- Serial Monitor debugging
- Non-blocking code using
millis() - Easy to expand for cloud-based IoT applications
- Wi-Fi monitoring using ESP32
- Mobile app integration
- MQTT communication
- Blynk dashboard
- Automatic notifications
- Weather-based irrigation scheduling
- OLED/LCD display support
Through this project, I gained practical experience in:
- ESP32 Programming
- Analog-to-Digital Conversion (ADC)
- Embedded C / Arduino Programming
- Relay Interfacing
- Sensor Data Processing
- Closed-Loop Automation
- IoT System Design
- GitHub Project Management
M Raza
IoT & Embedded Systems, PCB designer Enthusiast If this project helped you learn something new, consider giving it a ⭐ to support the project.