ESP32 - AirTag Documentation
|
Implementation of RSSI averaging and distance estimation utilities. More...
Functions | |
void | updateRssiAvg (int rssi) |
Updates the running average of the received signal strength indicator (RSSI). | |
float | estimateDistanceMeters (float rssi, float txPower, float n) |
Estimates the distance (in meters) from RSSI using the log-distance path loss model. |
Variables | |
bool | hasAvg = false |
Flag to indicate whether the RSSI average has been initialized. | |
float | rssiAvg = 0.0f |
Stores the current smoothed RSSI average. | |
float | txPower = -52.0f |
Transmitter power at 1 meter (in dBm). | |
float | nFactor = 2.5f |
Path-loss exponent (environmental factor). |
Implementation of RSSI averaging and distance estimation utilities.
This file provides definitions for global parameters and functions that help smooth RSSI (Received Signal Strength Indicator) values and estimate distance based on the log-distance path loss model.
The algorithm uses exponential smoothing for RSSI and applies the following formula for distance estimation:
where:
float estimateDistanceMeters | ( | float | rssi, |
float | txPower, | ||
float | n ) |
Estimates the distance (in meters) from RSSI using the log-distance path loss model.
Estimate distance from RSSI using the log-distance path loss model.
Computes an approximate distance to the transmitter based on the difference between the measured RSSI and the known transmit power at 1 meter.
[in] | rssi | Received signal strength indicator (in dBm). |
[in] | txPower | Transmitter power at 1 meter (in dBm). |
[in] | n | Path-loss exponent (environmental factor). |
void updateRssiAvg | ( | int | rssi | ) |
Updates the running average of the received signal strength indicator (RSSI).
Update the exponential moving average of the RSSI.
Applies exponential smoothing with a fixed factor
[in] | rssi | Current measured RSSI value (in dBm). |
bool hasAvg = false |
Flag to indicate whether the RSSI average has been initialized.
Flag indicating whether an RSSI average has been initialized.
float nFactor = 2.5f |
Path-loss exponent (environmental factor).
Typical values:
Should be tuned experimentally for best accuracy.
float rssiAvg = 0.0f |
Stores the current smoothed RSSI average.
Exponential moving average of the RSSI value.
float txPower = -52.0f |
Transmitter power at 1 meter (in dBm).
Reference transmit power (measured RSSI at 1 meter distance).
This value should be tuned based on calibration measurements.