RSSI to Distance With RF Modules (Xbees)

by RileyZito in Circuits > Microcontrollers

3114 Views, 4 Favorites, 0 Comments

RSSI to Distance With RF Modules (Xbees)

xbee_unassembled.PNG

Xbees are small Radio Frequency modules which can be useful for sending information back and forth, and some other more specific uses. For this project, I am using them to get Received Signal Strength Indicator (RSSI) values in order to estimate distance between the two Xbee modules. I wanted to share my work on this project because I have seen very few full tutorials on getting RSSI with Xbees. I found that one easy way to read the RSSI values of an Xbee and interpret them is an Arduino. For this tutorial, you will need a small amount of Arduino knowledge, in order to be able to upload the given code, and edit it if need be. The in-built serial monitor on the Arduino can show the RSSI values, and then, if you wish to go further, you can attach an LED or LCD screen to interpret them without a computer.

This specific tutorial uses one "transmitter" Xbee3 module which is programmed in Micropython and one "receiver" xbee3 which is attached to an Arduino Uno through an Xbee shield. It is also possible to send packets by having both of them connected to their own Arduino Uno, which is covered in someone else's online tutorial here. Xbee3 modules are required because they are the only Xbee modules that run Micropython, and they are one of the few Xbees to offer the 802.15.4 protocol, which includes RSSI values in sent packets.

Supplies

Note: It may be good to get two adapters so that both Xbees can be configured at the same time, and its also good for debugging because you can send packets through XCTU as well.

To Make it a Self-Contained System (Optional):

Hardware Set-up

67334610_358286968180532_7371765949982048256_n.jpg
IMG_8205.jpg

Physical set-up is pretty easy. Solder some connector pins to the Xbee shield (along the bottom on the outside, where the holes are) and then push it into place on top of the Arduino. DIRECTION MATTERS - Line up each Xbee with the white PCB trace on top of the shield ("receiver") or the adapter ("transmitter"). To connect the u.FL antennas, I suggest this guide by Sparkfun.

Configuration

xbee_firmware.PNG
transmit_config.PNG
receive_config.PNG

Computer set-up can be a bit more tricky. First, download XCTU. This program is used to configure the Xbees. The Xbee3 documentation is an invaluable resource for XCTU and configuration. Then go through the following steps with each Xbee plugged into the computer on the adapter (PWR LED on adapter should light up).

In XCTU, click "Discover radio modules..." (icon is an Xbee with a magnifying glass in top left corner) and click next and then finish. Then wait until the Xbee appears in the search, click it, and click "Add selected devices". Click the Xbee that appears on the left side of the screen, and wait for the settings to load, before clicking "Update firmware". Follow the first picture above and set the firmware version to 802.15.4 and the newest version. Then configure the "transmit" Xbee to match the "transmit" settings in the second picture, and do the same for the "receive" Xbee. You will also need to put the "receive" Xbee in API mode 2, in order to interface with the Arduino (this is very easy to google if you have a hard time finding it).

Code

For the Arduino, you will need to download the first attached file on the "receiver" Xbee. You will also need to download the Xbee-Arduino library, which is here. Arduino is a simple and well documented language, so if there are any issues you run into, the Arduino website is your friend.

The Micropython code is the second attached file. Follow this Instructable to download the code onto the "transmitter" Xbee.

Test It Out!

Getting RSSI values from Xbees

Now that all the necessary pieces are in place, you can finally send packets. Make sure the "transmitter" Xbee has the code running and then plug it into a power source (keeping plugged into the computer works fine as well). For the "receiver" Xbee, keep the Arduino plugged into the computer first, and once the code is downloaded, open the serial monitor. The serial monitor should then show values (from 20-70 roughly).

From my own testing, I have found that in wide open spaces the RSSI values correlate with distance up to 15 ft and in smaller spaces up to 5 ft. This is because of multipathing, a common issue when it comes to radio frequency signals. I hope this tutorial was helpful and thanks for reading.

Sources: Other RSSI instructable, RSSI with two arduinos/xbees, and Xbee and Arduino documentation