How to Build a Plant Disco Guardian with ESP32

A plant monitor that celebrates watering with lights and sound

ESP32GardenBeginner35 minutes3 components

Updated

How to Build a Plant Disco Guardian with ESP32
For illustrative purposes only
On this page

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

Interactive wiring diagram

Components needed

ComponentTypeQtyBuy
Soil Moisture Sensorsensor1€7.40
WS2812B LED Ringactuator1
Piezo Buzzeractuator1€4.75

Prices and availability are indicative and may have been updated by the supplier. Schematik may earn a commission from purchases made through affiliate links.

Assembly

1

Connect moisture sensing

Wire soil sensor output to GPIO34 for analog dryness readings.

2

Add disco feedback

Wire LED ring to GPIO4 and buzzer to GPIO26 for status effects.

Pin assignments

PinConnectionType
GPIO 34soil-sensor-1 SIGANALOG
GPIO 4plant-led-ring-1 DINDATA
GPIO 26plant-buzzer-1 SIGPWM

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.io
Libraries: FastLED