Let's Make Robots! | RobotShop

How to get the RSSI of an Xbee using Arduino!

This tutorial shows you How to get the RSSI of an Xbee using Arduino!
XbeeRSSI.zip1.12 KB

It took so much time to get this working. But know everything works fine. Using RSSI you can make many funny projects, like object detection and so on. Check out the link below for more information about RSSI. 




XBee modules have an RSSI (Received Signal Strength Indicator) pin that outputs a PWM signal representing this value.  But how do you turn that PWM duty cycle into a useable integer on your microcontroller?  Luckily Arduino has a function made for just this application:pulseIn.

  1. Connect the RSSI pin (pin 6) to a digital pin on your microcontroller.
  2. Use this line of code in your Arduino loop:
    rssiDur = pulseIn(digitalPin, LOW, 200);

pulseIn returns the duration of a pulse (specified HIGH or LOW) in microseconds (µs).  The 200 is a timeout value in µs—it waits this long to see if there’s going to be a pulse.  Since the XBee’s RSSI PWM period is 200µs, we want to wait at most that long to see if there’s a pulse at all.

Since this function gives you a duration, it’s up to you to map that to a value relevant to your program.  Since the maximum duration of the pulse would be 200µs, you could map that to your logical maximum.

Keep in mind that if you were planning on using API Mode anyway, every API Mode packet has the latest RSSI within it.



Feel free to ask me questions.




Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Posting your code listing from the video you posted with explanation like you did in the video would appease the OB character above. :P

I made an explanation and i've posted the code :)

Wikipedia does not have an article...

Here is the correct link but from my mobile (you should be re directed)- http://en.m.wikipedia.org/wiki/Received_signal_strength_indication and this should work- http://en.wikipedia.org/wiki/Received_signal_strength_indication

Now the link works.

I wrote the below code on arduino Uno, but it does not measure anything, please help

The uno will send letter 'a', another Xbee will bounce it back.=, on reception, I try to measure rssi Pin, but nothing happens


char c;
int rssiDur;
int digitalPin=10;
int count=0;
void setup()


void loop()
   // rssiDur = pulseIn(digitalPin, LOW, 200);
      rssiDur = pulseIn(digitalPin, LOW, 200);
      Serial.print("rssiDur:= \t \t");
  //    Serial.print("\n Count");
  //    Serial.print(count);
//    count=0;
//  else
//   {
//      count+=1;
//   }


output I get:



Hey Mike,

First of all, its very difficult for me to solve your problem because i need your setup information. Show me a picture of your hardwaresetup, so I can have a look.




Hi, Just a couple of questions.

I am using an Arduino Due and IDE 1.5.4 with two xbee pro series 2. The router in AT mode you set Digital pin 3 as A/D config which is physical pin 17. What is this pin used for? I didn't see anything connected to pin 17 in your tutorial? I have configured the two xbees as per your tutorial but I had to wire the xbee tx to the arduino rx (Serial3) and visa versa, to get a readout on my serial monitor. Could you please explain why you connedted tx to tx and rx to rx? The serial monitor only displays zoros and no RSSI values. The led on pin 13 stays on even if I swap the HIGH and LOW in the code? Do you know why any of this is happening?

I am trying to build a unlock/lock remote for my car triggered at a certain distance.

Any feedback would be greatly appreciated!




Hi Mathew,

The router Xbee has to get data. This means you have to set A/D number 3 to enabled and set the sampling rate. You dont have to connect any wire to this pin 17, because it works with dummydata too (It works even if pin 3 of your xbee reads zero). Actually I dont know why I connected them TX TX, but it worked for me. If you only get zeros try my arduino sketch and change the setup afterwards, so you can make sure everything is set up correctly. So first use my sketch! ;)

As requested, here is my setup.

Router xbee in AT mode with digital pin 3 set to A/DC and power to it.

Coordinator xbee in API mode with power to it, tx to Arduino rx and rx to Arduino tx. PWM pin 6 on xbee to digital pin 10 on Arduino Due.

I have been using your code with this setup but I still just get zeros on the serial monitor and the led on pin 13 stays on. I can't figure out why I am not readiong the rssi? I hope the pics are clear enough for you.