Read the original article:Estimating Distance to BLE Beacons Using RSSI and TxPower in HarmonyOS
Requirement Description
The developer needs to estimate the proximity between the user's device and a nearby BLE beacon to enable location-based behaviors (e.g., showing contextual ads, triggering entry/exit events, or indoor positioning). Since GPS is not suitable for short-range indoor detection, the distance must be calculated based on BLE signal strength using RSSI (Received Signal Strength Indicator) and TxPower (transmission power at 1 meter).
Background Knowledge
BLE beacons (especially iBeacon) include a TxPower field in their advertising payloads, representing the expected RSSI value at 1-meter distance. By comparing the actual measured RSSI with the known TxPower, we can estimate how far away the beacon is from the device.














