This listing is for an ESP32 development board solution and includes a complete, copy-ready example showing a 4-zone garden irrigation controller. The example provides:
This listing is border-free and eBay-safe (no JavaScript / no active content). Hardware sold separately unless bundled option is selected.
ESP32 DEV BOARD Soil Sensor (Analog) Relay Module (IN pins) SSD1306 OLED (I2C) ----------------- ------------------- --------------------- ------------------- 3V3 -----------------> VCC (if sensor uses 3.3V) -- VCC GND -----------------> GND GND GND GPIO32 (ADC1_4) ----> AO Zone 1 - SDA (OLED) GPIO33 (ADC1_5) ----> AO Zone 2 - SCL (OLED) GPIO34 (ADC1_6) ----> AO Zone 3 - - GPIO35 (ADC1_7) ----> AO Zone 4 - - GPIO25 --------------> - IN1 (Relay1) - GPIO26 --------------> - IN2 (Relay2) - GPIO27 --------------> - IN3 (Relay3) - GPIO14 --------------> - IN4 (Relay4) - Relay VCC -> External 5V supply (sized for pump/valve) Relay GND -> Common GND with ESP32 Pump/Valve power -> External supply through relay contacts
Safety: always power pumps/valves from a dedicated supply rated for the load. Tie grounds together. For mains AC loads use correctly rated relays/SSR and follow local electrical codes.
// ESP32 4-Zone Irrigation Controller
// ADC: GPIO32,33,34,35
// Relays: GPIO25,26,27,14 (active HIGH)
// OLED I2C: SDA=21, SCL=22 (SSD1306 128x64)
// Tune thresholds[] (raw ADC 0..4095), wateringDurationMs[], minIntervalMs[]
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_ADDR 0x3C
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1);
const int soilPins[4] = {32, 33, 34, 35};
const int relayPins[4] = {25, 26, 27, 14};
int thresholds[4] = {2000, 2000, 2000, 2000}; // adjust for your sensors
unsigned long wateringDurationMs[4] = {30UL*1000, 30UL*1000, 30UL*1000, 30UL*1000};
unsigned long minIntervalMs[4] = {60UL*60*1000, 60UL*60*1000, 60UL*60*1000, 60UL*60*1000};
int hysteresis = 150;
bool zoneActive[4] = {false,false,false,false};
unsigned long zoneStartTs[4] = {0,0,0,0};
unsigned long zoneLastWaterTs[4] = {0,0,0,0};
const unsigned long UI_UPDATE_MS = 2000;
unsigned long lastUiUpdate = 0;
void setup() {
Serial.begin(115200);
delay(100);
for (int i=0;i<4;i++) {
pinMode(relayPins[i], OUTPUT);
digitalWrite(relayPins[i], LOW);
}
for (int i=0;i<4;i++) pinMode(soilPins[i], INPUT);
Wire.begin(21,22);
if (!display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR)) {
Serial.println("OLED init failed - continuing without display");
} else {
display.clearDisplay();
display.setTextColor(SSD1306_WHITE);
display.setTextSize(1);
display.setCursor(0,0);
display.println("ESP32 4-Zone Irrigation");
display.display();
delay(800);
}
}
int readSoilRaw(int zoneIndex) {
return analogRead(soilPins[zoneIndex]); // 0..4095 (12-bit)
}
void startZone(int z) {
zoneActive[z] = true;
zoneStartTs[z] = millis();
zoneLastWaterTs[z] = millis();
digitalWrite(relayPins[z], HIGH);
Serial.printf("Zone %d START\n", z+1);
}
void stopZone(int z) {
zoneActive[z] = false;
digitalWrite(relayPins[z], LOW);
Serial.printf("Zone %d STOP\n", z+1);
}
void loop() {
unsigned long now = millis();
for (int z=0; z<4; z++) {
int raw = readSoilRaw(z);
bool needsWater = (raw > thresholds[z]);
if (zoneActive[z]) {
if (now - zoneStartTs[z] >= wateringDurationMs[z]) stopZone(z);
} else {
if (needsWater && (now - zoneLastWaterTs[z] >= minIntervalMs[z])) {
if (raw > thresholds[z] + hysteresis) startZone(z);
}
}
}
if (now - lastUiUpdate >= UI_UPDATE_MS) {
lastUiUpdate = now;
if (display.getPtr() != nullptr) {
display.clearDisplay();
display.setTextSize(1);
display.setCursor(0,0);
display.println("4-Zone Irrigation");
for (int z=0; z<4; z++) {
int raw = readSoilRaw(z);
display.printf("Z%d: %4d %s\n", z+1, raw, zoneActive[z]? "WATER":"OK ");
}
display.display();
}
for (int z=0; z<4; z++) {
int raw = readSoilRaw(z);
Serial.printf("Zone %d: raw=%d state=%s\n", z+1, raw, zoneActive[z] ? "WATERING":"idle");
}
}
delay(10);
}
Calibration: use Serial Monitor to observe wet/dry ADC values and set thresholds[] per zone. Typical dry values vary by sensor and soil.
esphome:
name: esp32_irrigation_4zone
platform: ESP32
board: esp32dev
wifi:
ssid: "YOUR_SSID"
password: "YOUR_PASS"
logger:
i2c:
sda: 21
scl: 22
scan: true
sensor:
- platform: adc
pin: GPIO32
name: "Soil Zone 1"
id: soil_z1
update_interval: 10s
- platform: adc
pin: GPIO33
name: "Soil Zone 2"
id: soil_z2
update_interval: 10s
- platform: adc
pin: GPIO34
name: "Soil Zone 3"
id: soil_z3
update_interval: 10s
- platform: adc
pin: GPIO35
name: "Soil Zone 4"
id: soil_z4
update_interval: 10s
switch:
- platform: gpio
pin: GPIO25
id: valve1
name: "Valve Zone 1"
- platform: gpio
pin: GPIO26
id: valve2
name: "Valve Zone 2"
- platform: gpio
pin: GPIO27
id: valve3
name: "Valve Zone 3"
- platform: gpio
pin: GPIO14
id: valve4
name: "Valve Zone 4"
automation:
- alias: "Auto water zone 1"
trigger:
platform: numeric_state
entity_id: sensor.soil_zone_1
above: 0.7 # tune threshold (0..1)
action:
- switch.turn_on: valve1
- delay: 30s
- switch.turn_off: valve1
- alias: "Auto water zone 2"
trigger:
platform: numeric_state
entity_id: sensor.soil_zone_2
above: 0.7
action:
- switch.turn_on: valve2
- delay: 30s
- switch.turn_off: valve2
- alias: "Auto water zone 3"
trigger:
platform: numeric_state
entity_id: sensor.soil_zone_3
above: 0.7
action:
- switch.turn_on: valve3
- delay: 30s
- switch.turn_off: valve3
- alias: "Auto water zone 4"
trigger:
platform: numeric_state
entity_id: sensor.soil_zone_4
above: 0.7
action:
- switch.turn_on: valve4
- delay: 30s
- switch.turn_off: valve4
display:
- platform: ssd1306_i2c
model: "SSD1306 128x64"
address: 0x3C
lambda: |-
it.printf(0, 0, id(font1), "Z1: %.0f Z2: %.0f", id(soil_z1).state * 4095.0, id(soil_z2).state * 4095.0);
it.printf(0, 16, id(font1), "Z3: %.0f Z4: %.0f", id(soil_z3).state * 4095.0, id(soil_z4).state * 4095.0);
font:
- file: "fonts/arial.ttf"
id: font1
size: 12
ESPHome ADC values are normalized (0..1). Multiply by 4095 to inspect raw ADC-style numbers; tune numeric thresholds to match your sensors.
Ships worldwide from seller location (select at checkout). Handling time: 1 business day. Returns accepted within 30 days
ESP32 irrigation, 4 zone irrigation, garden controller, soil moisture, relay valve, ESPHome, Home Assistant, Arduino ESP32, SSD1306 OLED.
β¨ Fast Shipping β’ π Secure Checkout