Quote of the Day
Something I wish I’d been reminded of when I was learning to code – just watching coding tutorials is like going to the gym just to watch someone else lift weights. It’s valuable to see how experts do it, but to actually build your coding skills—you’ve got to code!
— Madison Kanna, software developer. I am a huge fan of her twitter feed and blog. I see many people watch Youtube videos and think that simply watching videos will make them proficient at complex tasks. Unfortunately, there is a huge gap between watching and doing.
Introduction
I recently have been working on Bluetooth Low Energy (BLE) systems and estimating the distance between two devices based on the Received Signal Strength Indicator (RSSI) value is one of my tasks. There are all sorts of uses for this distance information in wireless systems. A few years ago, I worked on one wireless product for department stores that would use customer distance and angle information to determine where a customer was in the store and where they lingered while they were shopping. This information can be used to assess the ‘stickiness’ of displays and to send messages to the customer’s phone about nearby products they may be interested in.
These types of calculations are also performed in other applications. For example, I have done similar calculations with cell phone systems. While cell towers normally use GPS to determine phone positions, if GPS is not available they can use powerbased range estimates to locate phone positions (example). This certainly is part of the E911 standard, which specifies emergency cell services in the US.
All these applications estimate range using some form of Equation 1.
Eq. 1 
where
 R is estimate range between the two radios (in meters).
 N is the pathloss exponent (unitless, value of 24, with 2 being for free space). At most frequencies, N=2. In the case of 2.4 GHz, losses can be higher (link, link).
 RSSI_{TdB} is received signal power level (in dBm) at 1 meter from the antenna.
 RSSI_{RdB} is received signal power level (in dBm) at R meters range.
This post will present a derivation of Equation 1.
Analysis
Equation 1 is nothing more than the inverse squarelaw for electromagnetic waves with signal powers expressed in dB and the signal losses modeled with range powers from 2 to 4. We begin the derivation by restating the inverse square law for electromagnetic waves (Equation 2).
Eq. 2 
where

 K is a constant that will cancel out in further work.
 RSSI_{R} is the received power (W).
 P_{T} is the transmit power (W).
The range calculations do not normally use the actual transmitted power, but use the received transmit power at a reference distance (usually 1 meter), which is modeled by Equation 3.
Eq. 3 
Let’s now construct the ratio of Equation 3 to Equation 2 (Equation 4).
Eq. 4 
We can convert Equation 4 to dB as shown in Equation 5.
Eq. 5  
This derivation shows that Equation 1 is really just a slight reworking of the inverse square law.
Hi Mark, hope you are well in these COVID times.
I believe you have some typos.
– In Eq 5, in the first line, you have log(R^2). It should probably be log(R^N)
– Not sure how you go from 10*log(RSSI_T/RSSI_R) to RSSI_T – RSSI_R in the second line.
As usual, your articles are fun to read
Hi Ronan,
As always, you are a great reviewer! I hope you are doing well. As far as COVID goes, I can only shake my head in disgust as I look at the disaster in the US compared to the superb job Canada has done.
It has been a tough time. I have been staying isolated at my cabin in northern Minnesota and have been able to work with no issues. I do miss being around people (my neighbors are bears and wolves). Sadly, one of my brothers died on Memorial day. Cancer took him. He was my Irish twin. The remaining siblings, 3 brothers and a sister, are heartbroken.
Adding to the trouble, my wife contracted COVID. It was not fun and I almost needed to take her to the hospital. It has been two months since she contracted COVID and she is still not 100%. I did not catch COVID from her because we followed rigorous cleanliness practices.
Sorry to be a bit of a downer. I am lucky to be healthy and working on designing hearing aids (very interesting). My kids are both working and safe. I have been reading some Stoic philosophy and that has been helpful.
Mark, we’ve been lucky. We don’t have children except for cats and all of us are doing well. Sorry about your brother. We’ve also lost some aunts and uncles to cancer. I’m glad that your wife is in recovery and I understand that can take a while. We live in a city in southern California, so our neighbors are not bears and wolves, but sometime coyotes.
This COVID time has been a challenge. I used to go swing dancing a few times a week for fun socialization with exercise benefits. Now all such activities are shut down. It will probably take at least a year for life to go back to normal. I also think of Great Britain in WWII — a war that lasted six years. At least, we don’t have to worry about bombs falling on us.
Regarding Stoics, at some point, I’ll finish reading Meditations by Marcus Aurelius. It’s interesting reading words from 2,000 years ago that are applicable to today.
The words of Marcus Aurelius and Epictetus really speak to me. I love seeing that wisdom from the past can still be relevant and comforting thousands of years later.