Built to order

Smart Rainwater Harvesting Controller using ESP32

This project automates a rainwater harvesting setup the way it should actually be done: an ESP32 watches a rain sensor, diverts the dirty first flush to drain, checks turbidity before routing water to the storage tank, and manages tank levels with ultrasonic sensing — all with valves, a filter-status indicator and an LCD event log. It turns a plumbing chore into an instrumentation project. Suitable for B.E./B.Tech final-year projects in IoT and Embedded Systems.

Smart Rainwater Harvesting Controller using ESP32 — project thumbnail preview
More project photos (2)

The problem

Rainwater harvesting fails in practice for boring reasons: nobody diverts the first flush, the filter clogs silently, and the tank overflows or runs dry because nobody watches it. This controller handles all three automatically. A rain sensor detects the onset of rain; a motorized ball valve first routes the first flush (design target: first few minutes or a set volume) to drain, then a turbidity sensor gates the clean flow into the storage tank — if the water stays dirty, the controller holds the drain route and logs the event. An ultrasonic sensor tracks tank level, stops inflow at full, and a second valve tops up from the mains only below a reserve level. A filter-clog proxy (flow-time vs level-rise comparison) drives a "clean filter" indicator. Every routing decision appears on the LCD and in an SD-card event log.

How it works

  1. The rain sensor detects rainfall onset and wakes the controller from its idle monitoring loop.
  2. The drain-route valve opens and the first flush (configurable minutes/volume, design target) is sent to drain; the LCD counts down the flush.
  3. The turbidity sensor samples the incoming flow; once clarity passes the configured threshold, the controller switches the valves to the tank route.
  4. If turbidity stays poor beyond the configured window, the controller holds drain routing and logs a poor-quality event.
  5. The ultrasonic sensor tracks tank level continuously; at full it closes the tank route, and below the reserve level it opens the optional mains top-up valve.
  6. The firmware cross-checks flow time against level rise; a sustained mismatch raises the filter-clean indicator, and all events are written to the SD log.

Tech stack:

  • ESP32 development board
  • Rain sensor module (conductive plate)
  • Turbidity sensor (analog optical)
  • Ultrasonic level sensor (JSN-SR04T waterproof class)
  • 2× motorized ball valves (5 V) + relay/H-bridge drivers
  • MicroSD card module (event logging)
  • 16x2 character LCD
  • Arduino IDE (C/C++ firmware)
Parameter Value
Controller ESP32, rain/turbidity/level sensing, valve state machine
First flush Configurable duration/volume (design target: initial minutes of rainfall); drain-route valve
Turbidity gating Analog optical sensor; threshold configurable in firmware; drain-hold on poor quality
Level sensing Waterproof ultrasonic sensor, non-contact; full-stop and reserve top-up levels buyer-set
Valves 2× 5 V motorized ball valves, position by timed drive with stall guard
Filter indication Flow-time vs level-rise mismatch → "clean filter" indicator
Logging SD card event log + LCD live status
Power 5 V DC logic + valve supply; demo rig uses scaled tank models

Project features

  • [Automatic first-flush diversion] A rain sensor triggers a motorized ball valve that sends the initial dirty runoff to drain for a configurable volume/time before opening the tank route.
  • [Turbidity gating] A turbidity sensor checks incoming water clarity; if it stays above the configured threshold, the controller holds the drain route and logs a poor-quality event.
  • [Ultrasonic tank level management] Non-contact level sensing stops inflow at full, and optionally tops up from mains below a reserve level — no overflow, no dry pump.
  • [Filter-clog indication] The firmware compares expected level rise against flow time; a persistent mismatch lights the "clean filter" indicator instead of failing silently.
  • [Motorized ball valves] Two 5 V motorized ball valves (drain route and tank route) driven through relay/H-bridge outputs with position feedback by timing.
  • [LCD + SD event log] Every routing decision, turbidity reading and valve action is shown on the LCD and written to an SD card for the report's data section.
  • [Manual override] Panel buttons force drain or tank routing for demonstration and maintenance, with the LCD reflecting the override state.

What is included

  • Working harvesting-controller prototype (ESP32, rain sensor, turbidity sensor, ultrasonic level sensor, 2 motorized valves, LCD, SD module)
  • Complete firmware source code (rain detection, first-flush logic, turbidity gating, level management, logging)
  • Circuit and wiring documentation with valve-driver notes
  • Component list with ratings
  • Threshold configuration and demo procedure guide
  • Project report PDF (rainwater harvesting background, first-flush and turbidity theory, methodology, test procedure)
  • PPT presentation for final review
  • Viva Q&A preparation document (turbidity sensing, valve control, level measurement)
  • Setup and demonstration guide

Limitations & prerequisites

  • The prototype is demonstrated on a scaled tank model with a hose-fed "rain" source; full rooftop plumbing is the buyer's deployment, not part of the build.
  • Turbidity thresholds are configurable design values — the sensor needs the buyer's own two-point check (clear vs dirty water) during setup; no lab-grade water-quality claims.
  • Motorized ball valves are timed-drive with stall guard, not encoder-positioned; exact intermediate positions are not guaranteed.
  • The filter-clog indicator is a proxy metric (flow vs level rise), not a differential-pressure measurement.
  • Rain-sensor response depends on droplet contact; very light drizzle may register late.

Frequently Asked Questions

What does the controller actually automate?

Rain detection, first-flush diversion to drain, turbidity-gated routing to the storage tank, overflow-safe level management with optional mains top-up, and a filter-clog indicator — the full harvesting loop.

How is water quality checked?

An optical turbidity sensor samples the incoming flow; if clarity stays below the configured threshold after the first flush, the controller holds the drain route and logs the event. Thresholds are set during the buyer's own clear-vs-dirty water check.

Is this a full rooftop installation?

No — the prototype demonstrates the complete control logic on a scaled tank model. Real rooftop plumbing is the buyer's deployment.

What powers the valves?

5 V motorized ball valves driven through relay/H-bridge outputs from the ESP32, with timed positioning and stall guard.

What are the main limitations?

Scaled demo rig, buyer-calibrated turbidity thresholds, timed (not encoder) valve positioning, and the clog indicator is a proxy metric.

Is this project suitable for a final-year project?

Yes — for IoT and Embedded Systems programs. It combines multi-sensor fusion, state-machine control, water-quality reasoning and honest calibration, all strong viva material. Suitable for B.E./B.Tech final-year projects in IoT and Embedded Systems.

Components & software requirements
  • ESP32 development board
  • Rain sensor module (conductive plate)
  • Turbidity sensor (analog optical)
  • Ultrasonic level sensor (JSN-SR04T waterproof class)
  • 2× motorized ball valves (5 V) + relay/H-bridge drivers
  • MicroSD card module (event logging)
  • 16x2 character LCD
  • Arduino IDE (C/C++ firmware)
Delivery information

Built-to-order project. Delivery timeline is shared after order confirmation based on current queue.

Support terms

Complete documentation, setup guide, and viva preparation included. Support for setup and explanation provided.

Download abstract (PDF)

Related guides

All guides
Blueprint-style technical illustration of an ESP32 development board at the centre, with sensor nodes, data-flow arrows and a circuit-brain motif representing an AI agent reasoning and sending decisions back.Engineering students building IoT or embedded final-year projects who want to add local AI agent behaviour with ESP32, MQTT and a small language model.

AI Agents on ESP32: Agentic IoT Final-Year Projects

An agentic IoT system observes, reasons, acts, remembers and explains. On ESP32 that means a split architecture: the chip senses and acts while a small local model (Ollama on your laptop) reasons over MQTT — a full LLM needs gigabytes of RAM the chip doesn't have. This guide covers three working patterns (host-reasoned agent, on-device tinyML on ESP32-S3, and a hybrid of both), plus Wi-Fi CSI presence sensing, parts and budget for India, code shapes, and honest limits to state in your report.

Read guide
Technical illustration of three electronic control units linked by a twisted-pair CAN bus cable carrying signal pulses between them.Electronics, E&TC, IoT and robotics students who keep hearing “CAN bus” in EV, automotive and industrial project ideas and want to understand it properly before wiring anything

CAN Bus Basics for Students: How ECUs Communicate

CAN bus is the shared network that lets dozens of controllers in a car, EV or robot communicate over two wires. This guide explains message IDs, arbitration, the physical layer, frame structure, error handling and CAN FD, then walks through building a working two-node bench network with an ESP32 and a transceiver.

Read guide
Illustration of a quadcopter drone build showing labeled parts including frame, motors, propellers, ESCs, flight controller, and battery.B.E./B.Tech Electronics, Mechanical, and Computer Science students planning to build a quadcopter drone who need to select compatible parts without wasting money on mismatched

Drone Build: Parts Selection Guide

Picking drone parts that actually work together is a sizing problem, not a shopping problem. This guide walks the compatibility chain — frame to props to motors to ESCs to battery — with the thrust math, firmware choices, LiPo safety, and the bench-test order that prevents disasters.

Read guide
Get a quotation