Every BLE scanner observes the raw MAC addresses broadcast by nearby devices. Left unprocessed, those addresses can be linked back to individual people and tracked over time. The BLE People Counter eliminates that risk on-device: raw MAC addresses are hashed before any data is sent to the cloud, and the hash is one-way — you cannot recover the original address from it.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/AngelAmoSanchez/TFG-RaspberryPi-BLE/llms.txt
Use this file to discover all available pages before exploring further.
Why BLE scanning raises privacy concerns
Bluetooth Low Energy devices continuously broadcast advertisement packets that include a hardware identifier called a MAC address. In older devices, this address is static and globally unique, which means it can be used to fingerprint and track an individual across time and space. Even in environments where physical identities are unknown, a persistent MAC address is considered personal data under most privacy regulations, including GDPR. The system processes MAC addresses locally on the Raspberry Pi and never forwards them to the cloud.The anonymize_mac method
The DetectionProcessor class in src/main.py contains the anonymization logic:
- Normalize — strip colons and hyphens, convert to uppercase.
AA:BB:CC:DD:EE:FFbecomesAABBCCDDEEFF. This ensures that the same physical device always produces the same hash regardless of how the OS formats the address string. - Hash — apply SHA-256 to the UTF-8-encoded normalized string.
- Return —
hexdigest()returns a lowercase 64-character hexadecimal string.
Device dataclass:
One-way transformation
SHA-256 is a cryptographic hash function. Given the output hash, it is computationally infeasible to recover the input MAC address. The cloud backend only ever receivesdevice_hash values — it has no mechanism to reverse them into MAC addresses, and no raw address data is written to any log or database.
The anonymization runs inside
process_detections on the Pi, before the HTTPClient or MQTTClient transmits anything. There is no code path that sends a raw MAC address to the backend.What is stored in the database
TheDevice dataclass (defined in src/scanner/detection.py) represents the sanitized record that travels to the cloud:
device_id (the Pi’s identifier) when storing the record. In summary, the database contains:
| Field | Type | Description |
|---|---|---|
device_hash | string (64 chars) | SHA-256 hash of the normalized MAC address |
rssi | integer (dBm) | Signal strength at time of detection |
zone | string | near, medium, or far |
timestamp | ISO 8601 | When the device was detected |
device_id | string | Identifier of the Pi that made the detection |
MAC address randomization on iOS and Android
Modern smartphones (iOS 14+, Android 10+) use randomized MAC addresses that change periodically. From the scanner’s perspective, a single phone may appear as multiple distinct addresses over time. Each randomized address is hashed independently, so one physical device can generate several differentdevice_hash values within a session.
The RSSI values reported alongside randomized addresses are still accurate readings of signal strength; only the identifier changes. Detections for the same zone will still aggregate correctly for people-counting purposes.
GDPR considerations
No PII stored
The database contains only SHA-256 hashes, RSSI values, zones, and timestamps. None of these individually identify a natural person.
Aggregated output only
The dashboard displays estimated people counts per zone, not individual device histories. The raw detection table is an operational log, not a user profile.
On-device processing
Anonymization happens on the Raspberry Pi before any network transmission. Raw MAC addresses never leave the local device.
No retention of identifiers
Because hashes are one-way, there is no way to associate a stored record with a specific person or device after the fact — even with access to the database.