Garden · ESP32 DevKit
Thirsty Plant Rescue
A ESP32 DevKit build with 5 components. Reads: Soil sensor, Potentiometer. Drives: Relay, LED, OLED. When the soil reads dry, switch the pump relay on until it recovers.
5 parts · 15 connections · 10 steps
Wiring
Parts
| Part | Refs | Qty | Est. |
|---|---|---|---|
| Capacitive soil moisture sensor | SoilSensor | 1 | $1.80 |
| 1-channel relay module (5 V) | Relay | 1 | $1.20 |
| LED (5 mm) + 220 Ω resistor | LED | 1 | $0.15 |
| SSD1306 OLED display (128×64, I²C) | OLED | 1 | $3.20 |
| 10 kΩ potentiometer | Potentiometer | 1 | $0.50 |
| Plus: breadboard, jumper wires, USB cable | ≈ $6.85 | ||
Prices are rough hobby-market estimates. Click a part for wiring notes and specs.
Firmware
1// Plant Waterer2// Generated by Wirecraft for the ESP32 DevKit (ESP32-WROOM-32)3// Prompt: A plant waterer that reads soil moisture and runs a small pump through a relay when the pot gets dry, with a display sho4//5// Wiring, parts and step-by-step assembly live alongside this file.67#include <Arduino.h>8#include <Wire.h>9#include <Adafruit_GFX.h>10#include <Adafruit_SSD1306.h>1112#define SOILSENSOR_PIN 3213#define RELAY_PIN 414#define LED_PIN 515#define POTENTIOMETER_PIN 331617int soilSensorMoisture = 0;18Adafruit_SSD1306 oLED(128, 64, &Wire, -1);19int potentiometerValue = 0;2021void setup() {22 Serial.begin(115200);23 pinMode(RELAY_PIN, OUTPUT);24 digitalWrite(RELAY_PIN, LOW);25 pinMode(LED_PIN, OUTPUT);26 if (!oLED.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { Serial.println(F("OLED not found")); }27 oLED.clearDisplay();28 oLED.setTextColor(SSD1306_WHITE);29 oLED.setTextSize(1);30 Serial.println(F("Plant Waterer ready."));31}3233void loop() {34 // --- Read sensors ---35 soilSensorMoisture = analogRead(SOILSENSOR_PIN);36 potentiometerValue = analogRead(POTENTIOMETER_PIN);3738 // --- React ---39 // When the soil reads dry, switch the pump relay on until it recovers.40 if (soilSensorMoisture < 1400) {41 digitalWrite(RELAY_PIN, HIGH);42 } else {43 digitalWrite(RELAY_PIN, LOW);44 }4546 // Refresh the display with live readings47 oLED.clearDisplay();48 oLED.setCursor(0, 0);49 oLED.setCursor(0, 0);50 oLED.print("Soil sensor: "); oLED.println(soilSensorMoisture);51 oLED.setCursor(0, 12);52 oLED.print("Potentiometer: "); oLED.println(potentiometerValue);53 oLED.display();5455 delay(50);56}571; PlatformIO project for Plant Waterer2[env:esp32dev]3platform = espressif324board = esp32dev5framework = arduino6monitor_speed = 1152007lib_deps =8 adafruit/Adafruit SSD1306@^2.5.109 adafruit/Adafruit GFX Library@^1.11.910Assembly
- 1
Lay out your workbench
Gather the ESP32 DevKit, a half-size breadboard, and a bundle of male-to-male jumper wires. Keep the parts list open — every component below gets its own spot on the breadboard. Don't plug in USB power until the last wire is placed.
- 2
Seat the board and power rails
Run a red jumper from the ESP32 DevKit's 3V3 (or VIN for 5 V parts) pin to the breadboard's + rail, and a black jumper from GND to the − rail. Every component's power and ground will tap these rails.
- 3
Wire the Soil sensor
Place the Capacitive soil moisture sensor on the breadboard. Power first: VCC → + rail, GND → − rail. Then signals: AOUT → GPIO32. Tip: Calibrate: note the reading in dry air and in a glass of water — your range lives between them.
- 4
Wire the Relay
Place the 1-channel relay module (5 V) on the breadboard. Power first: VCC → + rail, GND → − rail. Then signals: IN → GPIO4. Tip: Most cheap modules are active-LOW — if yours clicks backwards, swap HIGH/LOW in the code.
- 5
Wire the LED
Place the LED (5 mm) + 220 Ω resistor on the breadboard. Power first: CATHODE → − rail. Then signals: ANODE → GPIO5. Tip: The longer leg is the anode (+). The resistor can go on either leg.
- 6
Wire the OLED
Place the SSD1306 OLED display (128×64, I²C) on the breadboard. Power first: VCC → + rail, GND → − rail. Then signals: SDA → GPIO21, SCL → GPIO22. Tip: If nothing shows up, try I²C address 0x3D — some modules ship with it.
- 7
Wire the Potentiometer
Place the 10 kΩ potentiometer on the breadboard. Power first: VCC → + rail, GND → − rail. Then signals: WIPER → GPIO33. Tip: Outer legs to VCC and GND, middle leg (wiper) to the analog pin.
- 8
Double-check before power
Trace every wire against the diagram once more — 15 connections in total. The classic mistakes: swapped power and ground, and off-by-one rows on the breadboard. Thirty seconds of checking saves a component.
- 9
Flash the firmware
Open the exported folder in VS Code with the PlatformIO extension (free), plug in the ESP32 DevKit over USB, and hit Upload. PlatformIO fetches the libraries listed in platformio.ini automatically. Prefer the Arduino IDE? Copy src/main.cpp into a new sketch and install the same libraries from the Library Manager.
- 10
Bring it to life
Open the Serial Monitor at 115200 baud to watch live readings. When the soil reads dry, switch the pump relay on until it recovers. Adjust the thresholds at the top of the sketch to match your environment.