BLE RSSI Filter Simulator
Try Leave Number of Devices at 8 and Scan Duration (s) at 15, then raise RSSI Threshold (dBm) from -70 to -60.
Observe At the defaults, 5 of 8 devices pass and their rows are green. Raising RSSI Threshold (dBm) to -60 leaves 4 passing devices.
Explain A device passes when its signal is greater than or equal to RSSI Threshold (dBm). Number of Devices and Scan Duration (s) determine the generated signal values.
Check passing devices
Reset
Technical boundaries. The simulation generates repeatable readings from device count and duration; Scan Duration (s) changes the generated data without running a timed scan. Each distance estimate assumes a calibration of -59 dBm and a path loss exponent of 2.5 in d = 10^((-59 - RSSI)/(10 × 2.5)).
Adjust the RSSI threshold and observe which simulated BLE devices pass the filter. Devices with RSSI below the threshold are filtered out as too distant.
viewof rssiThreshold = Inputs. range ([- 100 , - 30 ], {value : - 70 , step : 1 , label : "RSSI Threshold (dBm)" })
viewof numDevices = Inputs. range ([3 , 15 ], {value : 8 , step : 1 , label : "Number of Devices" })
viewof scanDuration = Inputs. range ([5 , 30 ], {value : 15 , step : 1 , label : "Scan Duration (s)" })
rssiFilterResult = {
const seed = numDevices * 7 + scanDuration;
const devices = [];
const names = ["ESP32-Sensor" , "ESP32-Beacon" , "Arduino-BLE" , "RaspPi-Gateway" , "nRF52-Tag" , "CC2650-Node" , "STM32-WB" , "Dialog-DA14" , "Silicon-BGM" , "Cypress-PSoC" , "Nordic-Thingy" , "TI-SensorTag" , "Xiaomi-Mi" , "Estimote-Beacon" , "Kontakt-IO" ];
for (let i = 0 ; i < numDevices; i++ ) {
const rssi = - 30 - Math . floor (((seed * (i + 1 ) * 13 + i * 37 ) % 70 ));
const name = names[i % names. length ];
const addr = ` ${ ((i * 23 + 0xA4 ) % 256 ). toString (16 ). toUpperCase (). padStart (2 , "0" )} :CF: ${ ((i * 17 + 0x12 ) % 256 ). toString (16 ). toUpperCase (). padStart (2 , "0" )} : ${ ((i * 31 + 0x34 ) % 256 ). toString (16 ). toUpperCase (). padStart (2 , "0" )} : ${ ((i * 41 + 0x56 ) % 256 ). toString (16 ). toUpperCase (). padStart (2 , "0" )} : ${ ((i * 53 + 0x78 ) % 256 ). toString (16 ). toUpperCase (). padStart (2 , "0" )} ` ;
const distance = Math . pow (10 , (- 59 - rssi) / (10 * 2.5 ));
const passed = rssi >= rssiThreshold;
devices. push ({name, addr, rssi, distance, passed});
}
devices. sort ((a, b) => b. rssi - a. rssi );
const passed = devices. filter (d => d. passed );
const filtered = devices. filter (d => ! d. passed );
const barMax = 100 ;
return html `<div style="font-family: Arial, sans-serif; background: #f8f9fa; border-radius: 8px; padding: 16px;">
<div style="display: flex; justify-content: space-between; margin-bottom: 12px;">
<span style="font-size: 14px; color: #2C3E50; font-weight: bold;">Scanning for ${ scanDuration} .0s (RSSI > ${ rssiThreshold} dBm)...</span>
<span style="font-size: 14px; color: #16A085; font-weight: bold;"> ${ passed. length } of ${ devices. length } devices passed</span>
</div>
${ devices. map (d => {
const pct = Math . max (0 , Math . min (100 , (d. rssi + 100 ) / 70 * 100 ));
const color = d. passed ? "#16A085" : "#E74C3C" ;
const bgColor = d. passed ? "#e8f8f5" : "#fde8e8" ;
return html `<div style="margin-bottom: 6px; padding: 8px; background: ${ bgColor} ; border-radius: 4px; border-left: 4px solid ${ color} ;">
<div style="display: flex; justify-content: space-between; align-items: center;">
<span style="font-size: 13px; font-weight: bold; color: #2C3E50;"> ${ d. name } <span style="color: #7F8C8D; font-weight: normal;">( ${ d. addr } )</span></span>
<span style="font-size: 12px; color: ${ color} ; font-weight: bold;"> ${ d. passed ? "PASS" : "FILTERED" } </span>
</div>
<div style="display: flex; align-items: center; gap: 8px; margin-top: 4px;">
<span style="font-size: 12px; color: #7F8C8D; min-width: 80px;"> ${ d. rssi } dBm</span>
<div style="flex: 1; height: 8px; background: #ddd; border-radius: 4px; overflow: hidden;">
<div style="width: ${ pct} %; height: 100%; background: ${ color} ; border-radius: 4px;"></div>
</div>
<span style="font-size: 12px; color: #7F8C8D; min-width: 60px;">~ ${ d. distance . toFixed (1 )} m</span>
</div>
</div>` ;
})}
<div style="margin-top: 10px; padding: 8px; background: #eaf2f8; border-radius: 4px; font-size: 12px; color: #2C3E50;">
<strong>Threshold line at ${ rssiThreshold} dBm</strong> — devices with weaker signals (more negative) are filtered out to focus on nearby targets.
</div>
</div>` ;
}
Back to the chapter