Overview
Spatial estimates bus crowd density in real time so transit riders know how full a bus is before boarding. Instead of using cameras or collecting personal data, the system measures passenger counts by scanning Bluetooth signals from rider devices using edge hardware installed on the vehicle.
Architecture
The system runs in three parts:
- Edge hardware. A Raspberry Pi 3 mounted inside the bus runs an asynchronous Python daemon with
Bleak. It detects nearby Bluetooth Low Energy advertisements from phones and wearable devices inside the cabin. A rolling median filter removes weak or momentary signals so pedestrians waiting at bus stops are not counted. - Backend analytics. The onboard Pi batches device counts, route IDs, and timestamps, then sends them to a Flask API. The backend compares raw signal counts with bus seating capacity to calculate realistic seat and standing room availability.
- Storage and dashboard. Supabase stores time-series records and replicates updates directly to a Next.js web app. Riders and transit operators see live bus coordinates, line congestion flags, and historical ridership trends.
Key considerations
- Privacy. The edge daemon hashes MAC addresses in memory using a rotating daily salt. Raw identifiers never touch disk and are dropped before data leaves the bus.
- Offline reliability. When a bus drives through tunnels or dead zones, the Pi buffers records into a local SQLite database and syncs them automatically once cellular connectivity returns.