Inspiration ​We all know the struggle: dormitory showers are a war zone. But it’s not just about finding a shower—it’s about getting The One. The specific cubicle with the perfect water pressure, the working lock, and the least amount of "mystery hair" on the wall. ​Walking all the way to the bathroom only to find your favorite throne occupied is a tragedy. We wanted to end this injustice. We built The Cubicle Cop to stake out the crime scene (the bathroom) so you don't have to. ​What it does ​The Cubicle Cop is an IoT surveillance system for your favorite shower stall. ​Stakeout Mode: It uses sensors (simulated via buttons/distance sensors) to monitor if the cubicle is "Occupied" or "Vacant." ​The Raid: When the "suspect" (the current user) leaves, the system instantly triggers. ​Dispatch: It sends a high-priority Telegram alert to your phone: "Suspect has fled! Cubicle 1 is secure. Breach and clear!" ​Visual Status: An RGB LED indicates the threat level (Red = Occupied, Green = Go, Go, Go!). ​How we built it ​We engineered this solution using the ESP32-S3 microcontroller as the brains of the operation. ​Firmware: We flashed the board with MicroPython for rapid prototyping and real-time control. ​Connectivity: We utilized the utelegram library to interface directly with the Telegram Bot API over WiFi. ​Logic: The code runs a continuous loop checking sensor states while maintaining a persistent socket connection to the Telegram servers to listen for the /start command. ​Hardware: We used the built-in NeoPixel RGB LED for status indication and handled hardware interrupts to detect occupancy changes. ​Challenges we ran into ​The interrogation room (debugging) was tough. ​The "Zombie Code" Issue: We faced a critical bug where the ESP32 would refuse to update its code, running an old "zombie" version from internal memory despite our saves. We had to perform a "hard wipe" of the filesystem to fix it. ​Library Mismatches: The utelegram library was sending two arguments (topic, msg) to our handler function, but our code only expected one. This caused immediate crashes upon receiving a message. We had to reverse-engineer the library call and write a "bulletproof" *args handler to make it crash-proof. ​The "Device Busy" Loop: Our WiFi connection loop was so aggressive it locked up the USB serial port, preventing us from stopping the code. We had to master the timing of the physical "Boot/Reset" buttons to break the loop. ​Accomplishments that we're proud of ​"Bulletproof" Polling: We wrote a robust message handler that can accept any number of arguments, making the bot resilient to library updates or API changes. ​Zero Latency: The alert moves from the hardware trigger to the Telegram notification in under 2 seconds—faster than anyone can walk down the hall. ​Recovering from a Brick: We successfully unbricked the ESP32-S3 after it got stuck in a boot loop, proving we can handle low-level hardware debugging. ​What we learned ​MicroPython Interrupts: We learned that time.sleep() blocks the processor, so we had to structure our main loop carefully to keep the bot responsive. ​Serial Communication: We gained a deep understanding of UART/COM ports and how the ESP32 handles USB serial connections during soft reboots. ​API Limits: We learned how to manage Telegram's polling limits to avoid getting "rate limited" (kicked off the force). ​What's next for The Cubicle Cop ​Heat Mapping: Logging data to find the "peak hours" so you can schedule your shower strategically. ​Multi-Stall Support: expanding the precinct to monitor an entire bathroom row. ​The "Siren": Adding a piezo buzzer that plays a police siren when you successfully claim the spot.

Built With

Share this project:

Updates