
HOW TO LOCATE (ALMOST) ANYTHING 275
Continued from opposite page.
/*
Once you've got a packet, you need to extract the useful data.
This method gets the address of the sender and RSSI.
*/
void parseData(int[] thisPacket) {
// read the address -- a two-byte value, so you
// add the two bytes as follows:
address = thisPacket[5] + thisPacket[4] * 256;
// get RSSI:
rssi = thisPacket[6];
}
Radio signal strength is measured in decibel-
milliwatts (dBm). You might wonder why the
signal reads –65dBm. How can the signal strength be
negative? The relationship between milliwatts of power
and dBm is logarithmic. To get the dBm, take the log of
the milliwatts. So, for example, if you receive 1 milliwatt of
signal strength, you’ve got log 1 dBm. Log 1 = 0, so 1 mW =
0 dBm. When the power drops below 1 mW, the dBm drops
below 0, like so: 0.5 mW = (log 0.5) dBm or –3.01 dBm.
0.25mW = (log 0.25) dBm, or –6.02 dBm. If logarithms
confuse you, just remember that 0 dBm is the maximum
transmission power, which means that signal strength
is going to start at 0 dBm and go down from there. The
minimum signal that the XBee radios can receive is –92
dBm. Bluetooth radios and Wi-Fi radios typically have
a similar range of sensitivity. In a perfect world with no
obstructions to create errors, relationship between signal
strength and distance would be a logarithmic curve.
Figure 8-5
Output of the XBee RSSI ...