How to Build a Soil and Plant Monitoring System
Share
A soil and plant monitoring system takes the guesswork out of watering and is genuinely useful whether you keep a balcony herb garden in Bengaluru or a row of pots on a sunny windowsill. This guide builds a complete monitor end to end. If you would rather not match the right sensors to a board, Compoden's AI build assistant can ship the whole kit with sample code ready to flash.
What you'll build
A battery-friendly plant monitor that reads soil moisture, air temperature and humidity, and light level, then shows the values on your phone or a small display. When the soil dries below a threshold, it alerts you, and an optional pump can water the plant automatically. The ESP32 version pushes readings to a dashboard you can check from anywhere.
Parts you need (rough BOM)
- ESP32 development board (Wi-Fi for the dashboard)
- Capacitive soil moisture sensor (resists corrosion better than resistive)
- DHT22 temperature and humidity sensor
- LDR or a BH1750 light sensor
- Optional: small 5V water pump and a relay or MOSFET to drive it
- 0.96-inch OLED display (optional, for local readout)
- Battery pack or USB supply, jumper wires, breadboard
How it works
The capacitive soil sensor outputs a voltage that varies with moisture; the ESP32 reads it on an analog pin. The DHT22 reports temperature and humidity over a single data line, and the light sensor reports brightness. The ESP32 reads all three on a schedule, compares moisture against a threshold, and either alerts you or triggers the pump. Between readings it can sleep to save battery.
Wiring overview
Connect the soil sensor's analog output to an ADC-capable GPIO and power it from 3.3V. The DHT22 data pin goes to a digital GPIO with a pull-up resistor. A BH1750 light sensor uses I2C (SDA and SCL), shared with the OLED if you add one. If you include a pump, drive it through a relay or MOSFET from a separate supply, never directly from a GPIO. Keep all grounds common.
Build steps
- Read the soil sensor alone and note its values in dry air and in a glass of water.
- Add the DHT22 and confirm sensible temperature and humidity readings.
- Add the light sensor and the optional OLED to show all values.
- Set a moisture threshold based on your dry and wet readings.
- Connect the ESP32 to Wi-Fi and push readings to a dashboard or Blynk.
- Add an alert when moisture drops below the threshold.
- Optionally wire the pump through a relay and trigger a short watering burst.
- Move to deep sleep between readings, then house the electronics away from water.
Code outline
- Initialise the sensors, display, and Wi-Fi in setup().
- Read the analog soil value and map it to a moisture percentage.
- Read temperature, humidity, and light.
- If moisture is below the threshold, send an alert or run the pump briefly.
- Publish all readings to the dashboard.
- Enter deep sleep for a set interval, then wake and repeat.
Troubleshooting
If moisture readings jump around, average several samples and keep the sensor wiring short. If the DHT22 returns NaN, check the pull-up resistor and add a short delay between reads. Corroded probes mean you are using a resistive sensor; switch to capacitive. If the ESP32 will not deep-sleep and wake, confirm the wake source and that the sensor power is gated so it does not drain the battery while sleeping.
Going further
Log readings over weeks to learn each plant's pattern, add multiple soil probes for several pots, or trigger watering only in the early morning. You can graph trends, send a weekly summary, or add a solar panel so the unit runs unattended on a balcony.
Build it with Compoden's AI
Tell Compoden's AI build assistant you want a plant monitor and it matches a kit with a capacitive soil sensor, the DHT22, a light sensor, and the ESP32, then ships sample code that already maps moisture to a percentage. You skip the corrosion and calibration headaches and start from a working monitor. Find sensors and boards at /collections/all.
Tired of guessing when to water? Describe your garden to Compoden's AI and build a monitor that tells you exactly when.
FAQ
Capacitive or resistive soil sensor? Capacitive. Resistive probes corrode quickly because current passes through the soil, while capacitive sensors last far longer and give steadier readings.
How long will it run on a battery? With deep sleep between readings and sensor power gated, a small pack can last weeks. Add a solar panel for an unattended outdoor unit.
Can it water the plant by itself? Yes. Add a small 5V pump driven through a relay or MOSFET, and trigger a short burst when moisture drops below your threshold.