Hackathon 2026 Project | IoT + AI + Smart City Dashboard
| File | Purpose |
|---|---|
server.py |
FastAPI backend — receives ESP32 data, stores to SQLite |
dashboard.py |
Streamlit smart dashboard — live metrics, gauges, AI prediction |
esp32_code.ino |
Arduino/ESP32 firmware — reads sensors, sends data via WiFi |
simulate_data.py |
Testing tool — sends fake data so dashboard works without hardware |
requirements.txt |
Python dependencies |
pip3 install -r requirements.txtuvicorn server:app --reloadBackend runs at → http://127.0.0.1:8000
API docs at → http://127.0.0.1:8000/docs
python3 -m streamlit run dashboard.pyDashboard runs at → http://localhost:8501
python3 simulate_data.py- Open
esp32_code.inoin Arduino IDE - Edit these lines with your details:
const char* WIFI_SSID = "YOUR_WIFI_NAME"; const char* WIFI_PASSWORD = "YOUR_WIFI_PASSWORD"; const char* SERVER_URL = "http://YOUR_LAPTOP_IP:8000/energy";
- Find your laptop IP:
- Mac:
ifconfig | grep 'inet ' - Windows:
ipconfig | findstr IPv4
- Mac:
- Install Arduino libraries: WiFi, HTTPClient, ArduinoJson
- Select: Tools → Board → ESP32 Dev Module
- Upload!
| Sensor | ESP32 Pin |
|---|---|
| Voltage Sensor (0–25V module) | GPIO 34 |
| ACS712 Current Sensor | GPIO 35 |
| IR Obstacle Sensor | GPIO 27 |
| Battery Voltage Divider | GPIO 32 |
| LED Indicator | GPIO 2 (onboard) |
- SDG 7 — Affordable and Clean Energy
- SDG 9 — Industry, Innovation and Infrastructure
- SDG 11 — Sustainable Cities and Communities
- SDG 13 — Climate Action
| Method | Endpoint | Description |
|---|---|---|
| GET | / |
Health check |
| POST | /energy |
Receive ESP32 data |
| GET | /energy |
Get all readings |
| GET | /energy/latest |
Get most recent reading |
| GET | /energy/stats |
Aggregated statistics |
| GET | /traffic |
Hourly traffic breakdown |
| DELETE | /energy/reset |
Clear all data (testing only) |