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
- The rain sensor detects rainfall onset and wakes the controller from its idle monitoring loop.
- The drain-route valve opens and the first flush (configurable minutes/volume, design target) is sent to drain; the LCD counts down the flush.
- The turbidity sensor samples the incoming flow; once clarity passes the configured threshold, the controller switches the valves to the tank route.
- If turbidity stays poor beyond the configured window, the controller holds drain routing and logs a poor-quality event.
- 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.
- 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.