Inspiration
As students in East Lansing, we are all too familiar with the high rates of bike theft on campus. While traditional locks provide a physical barrier, they offer no real-time protection or owner notification once a theft is in progress. We were inspired to create a device that bridges the gap between traditional security and modern IoT, giving owners the ability to monitor and respond to threats remotely.
How We Built It
The project is a full-stack IoT application that integrates hardware sensors with a cloud-based communication layer: Hardware Layer: We utilized an ESP32 microcontroller paired with an MPU6050 accelerometer. The device is mounted to the bike frame to monitor movement in three-dimensional space. Logic and Backend: We developed a FastAPI server in Python to act as the central hub. The ESP32 communicates with this server via HTTP POST requests when movement is detected. User Interface: We integrated a Telegram Bot using the pyTelegramBotAPI library. This allows the user to receive instant alerts and interact with the system via inline buttons.The Alarm Loop: The system follows a logic flow: Movement detected Alert sent to Backend.Backend sends a Telegram message with "Arm" and "Disarm" options.A 30-second window is initiated on the hardware.If the status remains "Armed" after 30 seconds, a physical piezo buzzer is triggered on the bike.
Challenges We Faced
The most significant hurdle was navigating the network security of a large-scale event. SSL/TLS Handshakes: We initially faced Error -1 when attempting to connect the ESP32 to a secure ngrok tunnel. This required us to implement WiFiClientSecure and use setInsecure() to bypass certificate validation on the local hardware.Captive Portals: University Wi-Fi (MSU Guest) uses redirects that caused Error 307, blocking our device's automated requests. We solved this by adding specific headers like ngrok-skip-browser-warning and ultimately pivoting to a local hotspot configuration to ensure the demo's reliability. Network Latency: Slow mobile data meant our Telegram Bot sometimes lagged. To solve this, we built a local web dashboard directly into the FastAPI backend as a fail-safe override.
What We Learned
This project was a deep dive into asynchronous programming and network protocols. We learned how to manage multiple threads in Python so that our web server could listen for hardware alerts while the Telegram bot simultaneously listened for user commands. We also gained practical experience in troubleshooting hardware-to-cloud communication and the importance of creating redundant "offline" modes for IoT devices.
Built With
- c++
- esp32
- fastapi
- html5
- javascript
- mpu6050
- python
Log in or sign up for Devpost to join the conversation.