Project: a Bluetooth Low Energy asset tracker
In short: Bluetooth Low Energy tags broadcast short advertisements that nearby scanners can hear. By placing an ESP32 scanner in each room and comparing signal strength, you can tell roughly which room a tagged item is in. Signal strength is noisy and tags can be spoofed or used to track people, so accuracy, security and privacy all need care.
What you will build and what you need
You will build a system that shows which room a tagged item, such as a toolbox, test laptop or equipment case, was last seen in. It gives room-level presence, not exact position. The same idea is used for tracking equipment in hospitals, warehouses and schools.
| Part | Notes |
|---|---|
| BLE tags or beacons | Choose tags with a fixed (static) address or a configurable identifier |
| One ESP32 per room | Mains powered by USB, mounted at a similar height in each room |
| MQTT broker | From the dashboard project |
| Small locator script or Node-RED flow | Decides the room for each tag |
How BLE advertising and RSSI work
Bluetooth Low Energy (BLE) devices send short advertising packets on three channels several times a second, without pairing. A scanner records the sender's address, the payload and the received signal strength indicator (RSSI) in dBm, where values closer to zero mean a stronger signal: around -50 dBm is close, around -90 dBm is far.
RSSI is a poor ruler. Walls, bodies, metal shelves and antenna direction change it by 10 dB or more, and readings jump around from second to second. That is why this design compares rooms rather than trying to calculate distance, and smooths readings over time.
Build steps and code
- Note each tag's address with a phone BLE scanner app and give it a friendly name.
- Flash MicroPython to each ESP32 and set a room name in its
secrets.py. - Upload the scanner code, which scans for 10 seconds, smooths RSSI and publishes known tags.
- Write the locator: for each tag, pick the room with the strongest recent RSSI, and require it to win by a few dB before moving the tag (hysteresis).
- Walk each tag through the building and adjust thresholds.
import bluetooth, time, json
from micropython import const
from net import publish # Wi-Fi + MQTT/TLS helper
import secrets # ROOM
_IRQ_SCAN_RESULT = const(5)
TAGS = {"c1a2b3c4d5e6": "toolbox", "c1a2b3c4d5e7": "test-laptop"} # placeholders
seen = {}
def on_ble(event, data):
if event == _IRQ_SCAN_RESULT:
addr_type, addr, adv_type, rssi, adv_data = data
mac = bytes(addr).hex()
if mac in TAGS:
old = seen.get(mac, rssi)
seen[mac] = round(0.7 * old + 0.3 * rssi) # smooth noisy RSSI
ble = bluetooth.BLE()
ble.active(True)
ble.irq(on_ble)
while True:
seen.clear()
ble.gap_scan(10000, 30000, 30000) # scan for 10 s
time.sleep(11)
for mac, rssi in seen.items():
msg = {"tag": TAGS[mac], "room": secrets.ROOM, "rssi": rssi}
publish("tracker/" + secrets.ROOM + "/" + TAGS[mac], json.dumps(msg))
Security and privacy checklist
| Risk | Mitigation |
|---|---|
| Spoofed tags: anyone can advertise the same address | Do not use for high-value security decisions; prefer tags that sign or rotate identifiers with a shared key |
| Tracking people without consent | Track equipment, not staff; if people carry tags, get informed consent and follow data protection law |
| Fake scanner messages | Per-scanner MQTT credentials, TLS and ACLs limiting each scanner to its room topic |
| Location history as personal data | Short retention and restricted dashboard access |
| Scanner tampering | Mount out of reach and alert when a scanner stops reporting |
Phones and many wearables use random private addresses that change regularly, precisely to stop this kind of tracking. Respect that design: do not try to defeat it, and do not log devices that are not your own tags.
Practice
Why does the tracker compare rooms instead of calculating exact distance?
What is hysteresis in the locator and why is it useful?
Why should a BLE tag not be used as proof of identity for a door lock?
Key takeaways
- BLE tags advertise without pairing; scanners record address and RSSI.
- RSSI is noisy, so compare rooms and smooth readings instead of measuring distance.
- Publish tag, room and RSSI over authenticated MQTT and decide centrally.
- Basic tags can be spoofed; do not use them for access control.
- Track equipment, not people, unless you have consent and a lawful basis.
Original content written by Mohamed Fayas for FM TecHub. © 2026 FM TecHub. You're welcome to share a link to this page; please don't copy the text elsewhere without permission.