
What you'll build
This guide shows you how to build a Plant Disco Guardian -- an ESP32-based soil moisture monitor that not only tells you when your plant is thirsty but throws a full disco celebration when you water it. A capacitive soil moisture sensor continuously reads the hydration level, and when it drops below a configurable threshold, a WS2812B LED ring glows a warning red and the buzzer emits a gentle periodic chirp. The moment you water the plant and the sensor detects rising moisture, the guardian erupts into a disco light show with rainbow chasing patterns, strobing colors, and a triumphant victory melody. It is absurd, it is delightful, and it actually makes you better at remembering to water your plants.
Under the hood you will learn how capacitive soil moisture sensors work and why they are preferred over resistive probes for long-term use, how to read analog values from the ESP32's ADC and smooth them with a running average to avoid false triggers from sensor noise, and how to drive WS2812B LEDs through the FastLED library with buttery-smooth animations. The disco celebration routine teaches you how to chain multiple animation patterns into a sequenced light show using non-blocking timers, while the alert system demonstrates hysteresis-based threshold logic that prevents the guardian from flickering between alert and celebration states when moisture sits near the boundary.
The completed guardian is a conversation starter that sits in any pot and runs for weeks on a USB power supply. The code is structured so you can adjust moisture thresholds for different soil types, customize the disco playlist with your own LED patterns and melodies, or add Wi-Fi to push moisture data to a dashboard or send phone notifications. Pair it with multiple sensors to monitor an entire windowsill garden from a single ESP32. It is the most fun you will ever have learning about analog-to-digital conversion and threshold-based alerting. If you want to explore more WS2812B animation techniques, the gesture-controlled mood lamp builds on the same FastLED skills with hand-wave interaction.
Wiring diagram
Wiring diagram
Components needed
Assembly
Connect moisture sensing
Wire soil sensor output to GPIO34 for analog dryness readings.
- Calibrate dry/wet values with your specific soil and sensor.
Add disco feedback
Wire LED ring to GPIO4 and buzzer to GPIO26 for status effects.
- Use a diffuser around the ring for smoother glow.
Pin assignments
| Pin | Connection | Type |
|---|---|---|
| GPIO 34 | soil-sensor-1 SIG | ANALOG |
| GPIO 4 | plant-led-ring-1 DIN | DATA |
| GPIO 26 | plant-buzzer-1 SIG | PWM |
Code
#include <FastLED.h>
#define SOIL_PIN 34
#define LED_PIN 4
#define NUM_LEDS 12
#define BUZZER_PIN 26
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<NEOPIXEL, LED_PIN>(leds, NUM_LEDS);
FastLED.setBrightness(140);
pinMode(BUZZER_PIN, OUTPUT);
}
void loop() {
int moisture = analogRead(SOIL_PIN);
bool dry = moisture < 1700;
if (dry) {
fill_solid(leds, NUM_LEDS, CRGB::Red);
tone(BUZZER_PIN, 900, 120);
} else {
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CHSV((millis() / 8 + i * 14) % 255, 255, 180);
}
tone(BUZZER_PIN, 1500, 40);
}
FastLED.show();
delay(dry ? 600 : 120);
}
// Run this and build other cool things at schematik.ioReady to build this?
Open this project in Schematik to get the full wiring diagram, pin assignments, and deployable code for the Plant Disco Guardian.
Open in Schematik →Related guides

How to Build a Gesture-Controlled Mood Lamp with ESP32
ESP32 · Beginner

How to Build a Cosmic Critter Pet with Raspberry Pi Pico
Raspberry Pi Pico · Beginner

How to Build a Rocket Launch Alarm Clock with ESP32
ESP32 · Beginner

How to Build a Laser Harp Synth with ESP32
ESP32 · Beginner