The problem
Municipal and campus bins overflow for a simple reason: collection trucks run on fixed routes and fixed schedules, while bins fill at unpredictable rates. A canteen bin can be full by noon while the truck only comes in the evening, and the truck still stops at half-empty bins because nobody knows which ones actually need emptying. This project replaces the fixed schedule with measured data. An HC-SR04 ultrasonic sensor mounted under the bin lid pings the trash surface and converts the echo distance into a fill percentage. An ESP32 reads the sensor every few minutes, publishes the level over WiFi using MQTT, and a cloud dashboard turns those readings into a live operations view: per-bin fill bars, alerts the moment a bin crosses roughly 80%, and a suggested collection route ordered by urgency. The build touches the full IoT stack — embedded firmware, wireless telemetry, cloud messaging and a real dashboard — which is exactly why it works well as a student project: every layer is visible and explainable.
HC-SR04 under the lid; 2 cm–400 cm range.
Follow the working sequence
How it works
- The HC-SR04 fires a 40 kHz ultrasonic burst and times the echo; its datasheet range of 2 cm–400 cm easily covers bin depths, with about 3 mm ranging accuracy.
- Firmware takes 5 consecutive readings and keeps the median, filtering out echoes bounced off an oddly stacked box or a swinging bin liner.
- Fill percentage = (calibrated bin depth − measured distance) ÷ calibrated bin depth × 100; calibration is a one-time measurement with an empty bin.
- The ESP32 (dual-core LX6 up to 240 MHz, WiFi 802.11 b/g/n) wakes from deep sleep, reconnects to WiFi, and publishes the reading to the MQTT topic bin/level/<bin_id> every 5 minutes.
- The cloud subscriber stores each reading in a time series and pushes it to the dashboard over a websocket, so fill bars move within seconds of an update.
- When a reading crosses the 80% threshold (configurable), the alert service sends a Telegram bot message naming the bin, its location and its fill level.
- The route planner sorts bins by fill percentage, then applies nearest-first ordering among bins above the threshold, rendering a numbered stop list for the collection team.
Tech stack:
- ESP32-WROOM-32 (Arduino IDE / ESP-IDF firmware)
- HC-SR04 ultrasonic sensor module
- MQTT via Mosquitto broker
- Python backend (subscriber + alert service)
- HTML · CSS · JavaScript dashboard
- Telegram Bot API for alerts
- WiFi 802.11 b/g/n link
- Git
| Parameter | Value |
|---|---|
| Sensor range | 2 cm – 400 cm (HC-SR04 datasheet) |
| Ranging accuracy | Approximately 3 mm (HC-SR04 datasheet) |
| MCU | ESP32 dual-core LX6, up to 240 MHz (datasheet) |
| Wireless | WiFi 802.11 b/g/n (datasheet) |
| Logic / sensor supply | 3.3 V logic, 5 V sensor supply (datasheet) |
| Publish interval | Every 5 min (design target, configurable) |
| Alert threshold | 80% fill (design target, configurable) |
| Readings per publish | Median of 5 (design target) |
| Demo fleet size | 6 bins, BIN-01 to BIN-06 (demo build) |
| Route ordering | Fill-level sort + nearest-first (design) |
Project features
- [Ultrasonic fill sensing] An HC-SR04 module mounted under the lid measures the distance to the trash surface; firmware converts it to a 0–100% fill level using the bin's calibrated depth.
- [ESP32 + MQTT telemetry] The ESP32 wakes from deep sleep every 5 minutes, takes a median of 5 sensor readings to reject stray echoes, and publishes a JSON payload (bin ID, fill %, distance, timestamp) to an MQTT broker over WiFi.
- [~80% fill alerts] A threshold rule fires a Telegram bot message to the facility team the moment any bin crosses 80%, with the bin ID, location and current level.
- [Route dashboard] A live dashboard shows every bin's fill bar and location, and computes a suggested collection route ordered by fill level, then nearest-first — so the truck stops only where it is needed.
- [Multi-bin fleet support] The demo ships with 6 bins (BIN-01 to BIN-06) registered on the dashboard; adding a bin is just flashing one more ESP32 node with a new ID.
- [Alert history log] Every alert is timestamped and listed on the dashboard, so response times and repeat-overflow bins are visible at a glance.
- [Sensor mounting kit] A 3D-printed/foam bracket holds the sensor rigidly under the lid at a fixed height, with a lid-open sensor hole so sound reaches the trash surface cleanly.
What is included
- ESP32 firmware source (sensor read, median filter, MQTT publish, deep sleep)
- Sensor mounting bracket design and wiring diagram
- MQTT broker setup guide and cloud subscriber backend
- Route dashboard (single-file HTML/CSS/JS) with 6 demo bins
- Telegram alert bot setup and threshold configuration
- Calibration procedure and expected reading-accuracy notes
- Project report PDF (architecture, firmware logic, dashboard design, results)
- PPT presentation for final review
- Viva Q&A preparation document (ultrasonics, MQTT, ESP32 power modes)
Limitations & prerequisites
- Uneven trash — leaning cardboard, bulging bags — reflects echoes off-centre and can skew a reading by roughly ±10–15%; median filtering reduces this but cannot eliminate it.
- The node needs WiFi at the bin location; if the network drops, readings queue nowhere and the dashboard shows the last received value with its timestamp.
- The reference build runs on a 5 V USB adapter; a battery-plus-solar variant needs a panel and charge controller sized to the site, costed in the report rather than claimed here.
- Outdoor bins need weatherproofing: the sensor holes and the ESP32 enclosure must be sealed against rain and dust for field use.
- Ultrasound measures volume only — it cannot tell whether the bin holds plastic, food waste or paper, so no segregation analysis is possible.
- The suggested route is a fill-priority, nearest-first heuristic, not a true travelling-salesman optimisation.
Frequently Asked Questions
How accurate is the ultrasonic fill reading?
The HC-SR04 itself resolves distance to about 3 mm (datasheet), but real trash has an uneven surface, so a single reading can be off by several centimetres. The firmware takes the median of 5 readings, which keeps the practical fill error to roughly ±10–15% on irregular loads — fine for "empty / filling / full" decisions, not for precise volume accounting.
What happens if the WiFi at the bin drops?
The ESP32 retries the connection on its next wake cycle and keeps sampling. Readings taken while offline are not backfilled, so the dashboard shows the last received value with its timestamp — the operator can see immediately that a bin has gone stale rather than trusting a frozen number.
Why is the alert threshold 80%?
Eighty percent leaves enough headroom for the collection team to act before the bin overflows, while avoiding constant alerts on bins that sit half-full for days. It is a configurable value in the backend, not hard-wired — a society with fast pickup could set 70%, a hostel block could set 85%.
Can this scale beyond the 6 demo bins?
Yes. Each bin is one ESP32 node publishing to its own MQTT topic, and the broker plus dashboard handle dozens of bins the same way they handle six. Scaling to a campus-wide fleet is a matter of provisioning nodes and registering bin IDs; the report lists the per-node cost breakdown for that planning.
Is this project suitable for a final-year project?
Yes — for Electronics, E&TC, Electrical and IoT programs. It covers embedded firmware, wireless telemetry, cloud messaging and a working dashboard, so a viva can probe any layer, and the student can demo the full loop live with one bin and the dashboard.
Components & software requirements
- ESP32-WROOM-32 (Arduino IDE / ESP-IDF firmware)
- HC-SR04 ultrasonic sensor module
- MQTT via Mosquitto broker
- Python backend (subscriber + alert service)
- HTML · CSS · JavaScript dashboard
- Telegram Bot API for alerts
- WiFi 802.11 b/g/n link
- Git
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 free synopsis (PDF)
Enter your name and email — the synopsis PDF downloads immediately. We may send occasional project updates; no spam, unsubscribe anytime.