Smart irrigation with soil moisture and weather check
Small farmers often water by habit, wasting water and power in some weeks and stressing crops in others. A low-cost controller that waters only when the soil is dry and skips watering before rain can cut both.
- Parts
- ₹4,470
- Build
- 12 weeks
- Board
- ESP32
- Objectives
- 6
Block diagram
- Soil moisture sensorsMeasure how wet the soil is at root depth
- Temperature and humidityAdds weather context
- Rain sensorSkips watering when it rains
- ESP32 controllerDecides when to water
- 12 V supplyPowers pump and board
- Solar power unitPanel, charger and cell that keep the node running+
- Relay and pumpSwitches the 12 V pump
- OLED displayShows moisture and pump state
- 4G modemSends SMS alerts and calls over the mobile network+
Objectives
- To measure soil moisture at root depth with capacitive sensors and calibrate them for the field soil.
- To switch a pump automatically between set dry and wet levels, with hysteresis.
- To skip a watering cycle when rain is detected.
- To measure the water saved compared with fixed-time watering over two weeks.
- To send SMS alerts through a 4G modem where no Wi-Fi is available.
- To power the system from a solar-charged battery and measure its energy budget.
Parts and specifications
- ESP32 DevKit V1Dual-core 240 MHz, 520 KB SRAM, Wi-Fi + Bluetooth, 3.3 V logic, 12-bit ADC (use ADC1 pins when Wi-Fi is on)₹450Buy
- Capacitive soil moisture sensor v1.2Analog output about 1.2 V (wet) to 2.5 V (dry), no exposed copper so it does not corrode₹240Buy
- DHT22 temperature and humidity sensor−40 to 80 °C ±0.5 °C, 0 to 100% RH ±2%, one reading every 2 s, single-wire₹250Buy
- Rain drop sensor moduleCopper comb plate with LM393, analog and digital out; power it only when reading to slow corrosion₹60Buy
- 5 V relay module (1 channel)10 A 250 V AC contacts, coil 70 to 80 mA, optocoupled input; many trigger at 3.3 V, check yours₹70Buy
- LM2596 buck converter (12 V to 5 V for the board)4 to 40 V in, 1.25 to 37 V out, up to 2 A continuous (3 A peak), about 85% efficient₹90Buy
- Tube, wires and enclosure box₹250
- A7670C 4G LTE module4G Cat-1 with 2G fallback, SMS, calls and data, works with any Indian SIM including Jio; 3.4 to 4.2 V, 2 A peaks₹1,500Buy
- LM2596 buck converter (set to 4.0 V for the modem)4 to 40 V in, 1.25 to 37 V out, up to 2 A continuous (3 A peak), about 85% efficient₹90Buy
- TP4056 charger with protection1 A CC/CV Li-ion charging to 4.2 V, DW01 protection cuts at about 2.5 V₹40Buy
- MT3608 boost converter (3.7 V to 5 V)2 to 24 V in, up to 28 V out, 2 A switch, for 3.7 V to 5 V₹50Buy
Total about ₹4,470 at typical online prices. Tap a part for its pinout and datasheet notes.
Design calculations
Calibrate each probe: read ADC in dry air (about 2900) and in water (about 1300). Moisture % = (ADCdry − ADC) / (ADCdry − ADCwet) × 100. A reading of 2100 gives (2900 − 2100) / 1600 × 100 = 50%.
Start the pump below 35% and stop above 60%. The 25-point band stops the pump from chattering as water spreads through the soil.
A 1.8 L/min pump and a 4 L target per bed need 4 / 1.8 = 2.2 minutes. Cap each run at 5 minutes as a fail-safe if a sensor fails dry.
Pump 12 V × 0.8 A = 9.6 W while running. ESP32 about 0.5 W. A 12 V 2 A (24 W) adapter leaves margin for the pump's start surge.
Pin map
| Signal | Pin or connection |
|---|---|
| Soil sensor 1 / 2 (analog) | GPIO 34 / 35 (ADC1, input only) |
| DHT22 data | GPIO 4 (10 kΩ pull-up to 3.3 V) |
| Rain sensor DO | GPIO 27 |
| Relay IN | GPIO 26 (active-low) |
| OLED SDA / SCL | GPIO 21 / 22 |
| Pump | Relay NO contact in the 12 V line |
Firmware outline
- Read each soil probe 10 times and take the median, every 30 s.
- Convert to percent with the stored dry and wet calibration values.
- If rain is detected or it rained in the last 6 h, skip watering.
- State machine: IDLE → WATERING when below 35%, WATERING → SOAK when above 60% or 5 min passed, SOAK waits 10 min before checking again.
- Drive the relay pin and show moisture, state and last watering time on the OLED.
- Count litres from run time and keep a daily total for the water-saving study.
Test plan
| Test | Expected result |
|---|---|
| Probe in dry soil, then watered | Reading moves from below 30% to above 60% |
| Soil below 35% | Pump starts within 30 s |
| Rain sensor wetted | Watering skipped and shown on the display |
| Pump runs 5 minutes without reaching 60% | Pump stops and shows a sensor fault |
| Two weeks against a fixed-time bed | Litres used compared in a table |
These rows start your results table when you plan the project.
Viva practice
Say your answer out loud first, then check. The first 2 answers are free; Maker opens all 6.
Make it yours
One or two upgrades for a mini project, two to four for a major one.
Build these first
Datasheets and sources to cite
- DFRobot capacitive soil moisture sensor v1.2 notes
- Aosong DHT22 (AM2302) datasheet
- Espressif ESP32 technical reference manual
- FAO Irrigation and Drainage Paper 56 (crop water needs)
About this project
How much does the smart irrigation with soil moisture and weather check project cost?
About ₹2,270 for the parts in the base list: ESP32 DevKit V1, Capacitive soil moisture sensor v1.2 × 2, DHT22 temperature and humidity sensor, Rain drop sensor module, 5 V relay module (1 channel), 12 V diaphragm water pump, 12 V 2 A DC adapter, LM2596 buck converter (12 V to 5 V for the board), 0.96 inch OLED (SSD1306, I²C), Breadboard 830 points, Tube, wires and enclosure box.
How long does it take?
About 8 weeks for the base project, built on an ESP32. Each upgrade adds time.
Which branches is it suitable for?
Electronics and Communication, Electrical and Electronics, Instrumentation, Computer Science / IT (IoT, AI), Diploma (any electronics branch), as a mini or major project.
Which pins and design calculations does it use?
Soil sensor 1 / 2 (analog) on GPIO 34 / 35 (ADC1, input only); DHT22 data on GPIO 4 (10 kΩ pull-up to 3.3 V); Rain sensor DO on GPIO 27. Worked calculations on this page: moisture in percent, hysteresis band, pump run time, power budget.
How do I test it?
Probe in dry soil, then watered: Reading moves from below 30% to above 60%. Soil below 35%: Pump starts within 30 s. Rain sensor wetted: Watering skipped and shown on the display. Pump runs 5 minutes without reaching 60%: Pump stops and shows a sensor fault. Two weeks against a fixed-time bed: Litres used compared in a table.
What are the objectives?
To measure soil moisture at root depth with capacitive sensors and calibrate them for the field soil. To switch a pump automatically between set dry and wet levels, with hysteresis. To skip a watering cycle when rain is detected. To measure the water saved compared with fixed-time watering over two weeks.
