IoT Systems Agricultural Tech Tanzania 2026

SMART IRRIGATION SYSTEM

Automated soil moisture monitoring & intelligent pump control for water-efficient farming

Sensors Used 4
Response Time <2s
Water Savings ~40%
Power Solar-ready
Smart Irrigation System side view
Side view — sensor housing and pump relay unit
Smart Irrigation System top view
Top view — PCB layout and wiring organization
Field deployment — real-world installation
System diagram — wiring overview

OVERVIEW

What is the Smart Irrigation System?

The Smart Irrigation System is a fully automated watering solution built at Msoka IoT Lab. It monitors soil moisture levels in real time using capacitive sensors and automatically activates a water pump when moisture drops below a set threshold.

The system eliminates the need for manual watering schedules and prevents both over-watering and under-watering — two of the biggest causes of crop failure in small-scale Tanzanian farming.

The entire system runs on an ESP32 microcontroller and communicates with a web dashboard, allowing remote monitoring from a phone.

Microcontroller ESP32 DevKit v1
Sensors Capacitive Soil Moisture × 4
Actuator 5V Relay Module → Water Pump
Power 5V USB / Solar panel input
Connectivity WiFi (2.4GHz)
Platform Supabase real-time dashboard
Status ✓ Deployed & tested

THE PROBLEM

What challenge does this solve?

Small-scale farming in Tanzania faces a critical water management challenge. Manual watering is time-consuming, inconsistent, and often leads to crop loss from either drought stress or root rot caused by overwatering.

Farmers working multiple plots simultaneously cannot monitor every bed continuously. The goal was to build a low-cost, reliable system that removes the guesswork from irrigation — letting the soil itself tell the system when water is needed.

60% of small farms rely on manual irrigation
30% crop loss from inconsistent watering
$50 total build cost

PARTS LIST

Every component used to build the system.

# Component Quantity Purpose
1 ESP32 DevKit v1 ×1 Main controller + WiFi
2 Capacitive Soil Moisture Sensor ×4 Soil moisture reading (analog)
3 5V Single-Channel Relay Module ×1 Pump switch control
4 Submersible Mini Water Pump (5V) ×1 Water delivery
5 Silicone Irrigation Tubing ×1m Water routing
6 18650 LiPo Battery + TP4056 charger ×1 Portable power
7 Jumper wires + Breadboard assorted Prototyping connections
8 USB Power supply (5V 2A) ×1 Primary power source
Total estimated cost: $45–55 USD (sourced locally in Tanzania + AliExpress).

HOW IT WORKS

The four-step control loop, from sensor to action.

  1. SENSE

    Four capacitive soil moisture sensors are embedded in the soil at different depths. Every 30 seconds, the ESP32 reads an analog voltage from each sensor. Capacitive sensors measure the dielectric constant of soil — wetter soil has a higher dielectric constant, producing a lower analog output voltage.

  2. DECIDE

    The readings are averaged and compared against a calibrated threshold (set during setup for each soil type). If the average moisture level falls below the threshold, the system flags an irrigation event. A hysteresis band prevents rapid on/off cycling.

  3. ACT

    The ESP32 triggers the relay module, completing the circuit for the water pump. The pump runs for a configurable duration (default: 30 seconds) then pauses, allowing the soil moisture to equalize before re-reading.

  4. REPORT

    All sensor readings, pump events, and timestamps are logged to the Supabase database via WiFi. The web dashboard displays live charts, historical data, and allows remote threshold adjustment.

WIRING & FIRMWARE

Pin connections and simplified core logic.

// Simplified core logic — Smart Irrigation System
// Full source: github.com/alexcosmasmsoka

#define SENSOR_PIN_1 34
#define SENSOR_PIN_2 35
#define RELAY_PIN    26
#define DRY_THRESHOLD 2800  // calibrate for your soil
#define PUMP_DURATION 30000 // 30 seconds

void loop() {
  int avg = readAverageMoisture();

  if (avg > DRY_THRESHOLD) {
    activatePump(PUMP_DURATION);
    logToSupabase("pump_on", avg);
  }

  logToSupabase("reading", avg);
  delay(30000); // read every 30s
}

Full source code available on request or GitHub.

LESSONS LEARNED

What I discovered building and testing this system.

Sensor Calibration is Everything

Each capacitive sensor has a slightly different output range. I spent two days building individual calibration curves for each one. A single shared threshold was producing 30% false readings. Lesson: always calibrate individually.

Hysteresis Prevents Pump Cycling

My first version had the pump switching on/off every 30 seconds as moisture hovered near the threshold. Adding a ±5% hysteresis band (pump on at <40%, off at >50%) completely eliminated this.

WiFi Reliability on 3.3V

The ESP32 WiFi stack is power-hungry. When powering from a weak source, reconnections caused random resets. Adding a 100µF decoupling capacitor on the 3.3V rail and implementing auto-reconnect logic fixed it.

RESULTS

3 weeks of real-world deployment data.

After 3 weeks of deployment in a test garden bed, the Smart Irrigation System delivered consistent results.

~40% reduction in water usage vs. manual watering
Zero crop loss during test period
99.2% uptime over 3 weeks of operation
<2 seconds sensor-to-pump response time

BUILD YOUR OWN?

Commission a custom system or follow the build.

Commission a Custom System

Need an irrigation system for your farm or garden? I'll build one tailored to your specific requirements.

Start a Project →

Follow the Build

Watch the next version being built on TikTok and Instagram.

@msokaalex on TikTok →
Back to top