Free tech learning for everyone, from basics to pro

IoT ProjectsIoT SecurityAdvanced

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.

PartNotes
BLE tags or beaconsChoose tags with a fixed (static) address or a configurable identifier
One ESP32 per roomMains powered by USB, mounted at a similar height in each room
MQTT brokerFrom the dashboard project
Small locator script or Node-RED flowDecides 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.

BLE asset tracker designBLE tagsadvertise IDESP32scannersone per roomRSSI filtersmooth signalMQTTtag, room,RSSILocatorstrongest room
Figure 1. Tags broadcast, room scanners measure signal strength, and a central service picks the most likely room.

Build steps and code

  1. Note each tag's address with a phone BLE scanner app and give it a friendly name.
  2. Flash MicroPython to each ESP32 and set a room name in its secrets.py.
  3. Upload the scanner code, which scans for 10 seconds, smooths RSSI and publishes known tags.
  4. 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).
  5. 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

RiskMitigation
Spoofed tags: anyone can advertise the same addressDo not use for high-value security decisions; prefer tags that sign or rotate identifiers with a shared key
Tracking people without consentTrack equipment, not staff; if people carry tags, get informed consent and follow data protection law
Fake scanner messagesPer-scanner MQTT credentials, TLS and ACLs limiting each scanner to its room topic
Location history as personal dataShort retention and restricted dashboard access
Scanner tamperingMount 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?
RSSI varies a lot with walls, bodies, metal and orientation, so distance estimates are unreliable. Comparing which room hears the tag most strongly gives a more dependable room-level answer.
What is hysteresis in the locator and why is it useful?
Requiring a new room to be stronger by a margin before moving the tag. It stops the location flapping between rooms when readings are similar.
Why should a BLE tag not be used as proof of identity for a door lock?
Basic tags broadcast a fixed identifier that anyone can record and replay or copy, so it does not prove the real tag is present.

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.
Tracks your learning on this device only. See your progress on the learning paths.

About the author

Mohamed Fayas

Founder of FM TecHub. CCNA certified, with a BTEC HND in Network Engineering, and BEng (Hons) in Computer Networking and Cloud Security. He writes practical, plain-English guides on networking, security and cloud.

More about the author

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.

Stay up to date by email

New notes, tools and security news from FM TecHub, explained simply. Free.

We only use your email to send these updates. See our privacy policy.