Introduction
In this post, lets learn how to measure distance using the ESP-01 (ESP8266) module with Wi-Fi RSSI techniques. Full circuit, code, calibration method, accuracy improvement tips, and practical IoT applications.
What is RSSI and How ESP-01 Measures Distance
RSSI stands for Received Signal Strength Indication. It is a measurement of the power level that a radio receives from a transmitting device, such as a Wi-Fi router or access point. It is a standard feature in most wireless networking hardware, including the ESP-01 module, to help determine the quality and proximity of a connection. RSSI values are typically expressed as a negative number measured in decibels per milliwatt (dBm). A value closer to 0 dBm indicates a stronger signal (e.g., -30 dBm is very strong), while a value further from zero indicates a weaker signal (e.g., -80 dBm is weak).
While the ESP-01 does not have a dedicated distance-measuring sensor like an ultrasonic module, it can leverage its built-in Wi-Fi capability and RSSI data to estimate distance. The core principle is simple: as the distance between the ESP-01 (receiver) and a Wi-Fi source (transmitter) increases, the signal strength (RSSI) decreases.
However, translating an RSSI value into an accurate distance in meters is a complex task. Radio waves are easily affected by environmental factors, a phenomenon known as multi path propagation. Walls, metal objects, furniture, and even people can absorb, reflect, or obstruct the signal, causing the RSSI value to fluctuate even when the physical distance hasn't changed.
Note that this is the least efficient method of measuring distance. For reliable distance measurement, dedicated hardware like LiDAR, ultrasonic sensors, or Ultra-Wideband (UWB) modules are recommended
We can get the RSSI using the AT commands from the ESP-01 module. We can get RSI using the library as well.
int rssi = WiFi.RSSI();
Once signal strength is received, we can calculate the distance using the below formula.
d = 10 ^ ((RSSI_at_1m - RSSI) / (10 * n))
d = distance from Access point
RSSI_at_1m = -45dBm (This depends on router and we need to edit the value based on environment, what this basically means is at 1m distance from Access point or a router, what is RSSI value?)
n = 2 to 3.5 (This depends on the environment in which we have router and ESP-01, walls, metal surfaces, etc.,)
The below graph shows distance measured using the RSSI. ESP-01 module we have been talking in the blog is used for these tests.
0 Comments