Re: Reading RSSI of XBee Series 2 Problem

Dear all,

I am currently doing a project that requires me to read the RSSI of the XBee Series 2 but I am unable to read the RSSI after trying loads of “solutions” I read online.

I hope someone can explain or guide me through a simple setup where I can read the RSSI values programmed in Arduino.

For a start, I have 1 XBee Series 2 in Coordinator API and 1 XBee Series 2 in Router AT mode. Different solutions online have different ways but none of them have worked for me yet.

What I have done and understand from it so far is that my Router has its AD3/DIO3 set as ADC[2] and the IR sampling rate at 0x64 x 100ms (4secs).

Currently the main line of codes that I use is this,

for(int i = 0; i < 21; i++) {
byte discardByte = Serial3.read();
rssiDur = pulseIn(digitalPin, LOW, 200); // get’s the RSSI Value
Serial.println(rssiDur); //for debbuging and first setup.
}

Basically, it reads the API frame that the Router sends to the Coordinator and I use the pulseIn function to get the presumed RSSI value.

But, the results varies. The values ranges from 0-70 from distances 1m-40m.

Some questions that I have is that is this really the RSSI value? I doubt so myself as RSSI will not have 0s.

I hope to get a simple setup and code for me to start with by getting the RSSI value.

What I have as a setup is:
XBee series 2 (Coordinator API is hooked onto a Wireless Shield and then onto an Arduino MEGA)
XBee series 2 (Router AT is hooked onto a Wireless Shield and then onto an Arduino UNO)
Wires are connects the Rx to Tx and Tx to Rx for both Shield and Arduino boards.
The Coordinator API XBee have its Pin 6 connected to pin 10 on the Arduino board.

Any help would be greatly appreciated.

Thanks in advance!!

J.Y.

RSSI values are nearly useless in almost every situation and have little, if anything, to do with distance between transmitter and receiver. What do you want to do with them?

Currently the main line of codes that I use is this,

Look at that code, and see if you can understand what it is doing.

What pin are you reading a pulse from? What is connected to that pin? Why do you do that in the middle of reading an API packet? Why do you do it 21 times?

Hi Jremington,

It is true that RSSI values defers from hops from router to router before reaching its destination. But I am only doing a simple setup which I dont see the impact of the wrong readings yet. Yes, I will use the RSSI to determine a rough location of where my Router is, there can be a range as I dont need it to be exact but I cant seem to read the RSSI values.

Hi PaulS,

Thanks for replying, I am a newbie at this but I did a lot of readup and research before diving into this. To be honest, I think I have done too much research that I found different answers everywhere. That is why I resort to this by coming to forums and posting what I am doing in hopes that someone will correct me.

Firstly, for my Coordinator API, I connect a wire from XBee pin 6 (RSSI pin) to pin 10 (RSSI/PWM) of the Arduino MEGA (through the wireless PROTO shield).

I have done it after the for loop (after the whole API packet which consist of 21 bytes from start byte 7E to checksum) and it still reads 0 (supposed to be RSSI) but at near range it should read at least -30dbm. 21 times is for the 21 bytes that I am getting from the Router AT which consist of this,

7E,0,12,92,0,13,A2,0,40,D5,95,80,7C,E,1,1,0,0,8,2,8,F0,

Basically, I did not print out 7E cause my Arduino codes checked for byte 0x7E before going to an if loop, so technically it prints out from 0, 12 (Frame length) all the way to the Checksum F0.

Before the Checksum, there is a reading of 8, 2, 8 which from my understanding is that the first “8” is 1000 therefore it means I did enable the AD3/DIO3 pin of the Router AT to ADC[2]. The next two bytes “2, 8” consist of a data which from another forum that it should contain the RSSI value.

As I have experimented on this, I have doubts that it is the RSSI value. I will post the entire codes that I am using below:

/*
Author: Cédric Portmann (cedric.portmann@gmail.com.)
Copyright (C) 2013 Cédric Portmann
*/

int digitalPin = 10; // the RSSI pin 6 of Xbee is connected to this PWM Pin. (Digital Pin 10)
int rssiDur; // Variable for RSSI
int led = 15; // LED connected to Pin 13

void setup()
{
pinMode(led, OUTPUT);
pinMode(digitalPin, INPUT);
Serial.begin(9600);
Serial3.begin(9600); // this is the connection of your Xbee to your Arduino MEGA!!
}
void loop()
{
if(Serial3.available()) { //checks for signal
if(Serial3.read() == 0x7E) { //checks if the signal contains start byte 0x7E
// Serial.print("7E, “);
}
for(int i = 0; i < 21; i++) {
// Serial.print(Serial3.read(), HEX); //prints out the whole API frame
// Serial.print(”, ");
byte discardByte = Serial3.read();
rssiDur = pulseIn(digitalPin, LOW, 200); // get’s the RSSI Value
Serial.println(rssiDur); //for debbuging and first setup.
if(rssiDur < 40 && rssiDur != 0) {
Serial.println(“Zone 1”);
Serial.print("RSSI: ");
Serial.println(rssiDur);
}
if(rssiDur > 40 && rssiDur != 0) {
Serial.println(“Other Zones”);
Serial.print("RSSI: ");
Serial.println(rssiDur);
}
}
Serial.println();
}
}
//}

Sirs, please correct me if I am understanding something wrong. Thank you again for your time in reading and guiding me.

Yes, I will use the RSSI to determine a rough location of where my Router is

No, you will not be able to do that.

jremington:
No, you will not be able to do that.

Is that really true? Why is it so?

Firstly, for my Coordinator API, I connect a wire from XBee pin 6 (RSSI pin) to pin 10 (RSSI/PWM) of the Arduino MEGA (through the wireless PROTO shield).

Pin 10 on the Mega says nothing about RSSI. It is a PWM pin, but that is an OUTPUT state and has nothing to do with input.

Why is it so?

You really don’t know what the R in RSSI stands for?

PaulS: Pin 10 on the Mega says nothing about RSSI. It is a PWM pin, but that is an OUTPUT state and has nothing to do with input. You really don't know what the R in RSSI stands for?

Sir, perhaps the we can get the RSSI (Relative Signal Strength Indicator) from the PWM pin? From what I have gathered online, most forums/tutorials always claim to connect pin 6 to pin 10.

One of the following tutorial is here: http://letsmakerobots.com/node/37243

I have followed his tutorial but am unable to get the RSSI value unlike he did.

Hmm... to be honest, I need to find the distance (may not be that accurate, could be a range) between the 2 XBees Series 2. Isn't RSSI the best way to do it (without any other hardware help)? With x-CTU I can see the RSSI and LQI too. But I am unsure about LQI so I am working on RSSI instead.

Maybe you could introduce me another way? Or is this RSSI is something that I cannot get from the XBees?

Isn't RSSI the best way to do it

As just a few minutes of experimentation will convince you, it is [u]not even possible[/u] to use RSSI to calculate distance between transmitter and receiver, except in very rare, tightly controlled circumstances.

Antenna orientation and environment have much larger influence on the RSSI value than distance.

Hi jremington,

I am really not sure as there are some who says it is possible and one of the ways to calculate distance. I did a range test with X-CTU and the signal is quite stable for where my XBees will be. I always see a -30dbm for <5m, -50dbm for 10m to 15m, -55dbm for 15m to 20m etc.

Sorry am still a newbie here, reading almost everything I can. The XBee manual says this:

“The XBee module features an RSSI/PWM pin (pin 6) that, if enabled, will adjust the PWM output to indicate the
signal strength of the last received packet. The P0 (P-zero) command is used to enable the RSSI pulse width
modulation (PWM) output on the pin. If P0 is set to 1, the RSSI/PWM pin will output a pulse width modulated
signal where the frequency is adjusted based on the received signal strength of the last packet. Otherwise, for all
other P0 settings, the pin can be used for general purpose IO.
When a data packet is received, if P0 is set to enable the RSSI/PWM feature, the RSSI PWM output is adjusted
based on the RSSI of the last packet. The RSSI/PWM output will be enabled for a time based on the RP command.
Each time an RF packet is received, the RSSI/PWM output is adjusted based on the RSSI of the new packet, and
the RSSI timer is reset. If the RSSI timer expires, the RSSI/PWM pin is driven low. RP is measured in 100 ms units
and defaults to a value of 40 (four seconds).
The RSSI PWM runs at 12 MHz and has 2400 total counts (200 us period).
RSSI (in dBm) is converted to PWM counts using the following equation:
PWM counts = (41 * RSSI_Unsigned) - 5928”

From: http://ftp1.digi.com/support/documentation/90000976.pdf

Sorry, hope to get some guidance here.

the signal is quite stable for where my XBees will be.

It is possible that you have [u]created[/u] one of those rare circumstances where RSSI can be a reasonable measure of distance.

If you put the XBees in most other positions or locations, or someone walks between them, it will not be.

If RSSI was reliable for relative position determination, you would already see thousands of projects using that method. Use the forum search box in the upper right of this page and search for RSSI to see previous similar discussions.

The XBee module features an RSSI/PWM pin (pin 6) that, if enabled, will adjust the PWM output to indicate the

OP: You've said nothing about having enabled RSSI.

jremington: It is possible that you have [u]created[/u] one of those rare circumstances where RSSI can be a reasonable measure of distance.

If you put the XBees in most other positions or locations, or someone walks between them, it will not be.

Haha, well it is x-CTU so ya, the experiment is basically a range test with LOS between the 2 XBees. just moving it to different distances at 5 to 90m at a step size of 10m and sending a packet every 1sec.

I dont know if it is possible to recreate the results on Arduino though. :/

zoomkat: If RSSI was reliable for relative position determination, you would already see thousands of projects using that method. Use the forum search box in the upper right of this page and search for RSSI to see previous similar discussions.

Hi zoomkat, yes I know, you are not one of the first in the forums to have said that. For me, I read on many different sites and forums and technically some said RSSI can be found with the XBees Series 1 and 2 (I am working on Series 2). But I have tried and am not sure where I am going wrong.

I dont need to have an exact location on where my Router is, if it is possible just a way to program both the Router to send a packet and the Coordinator API to receive it. Once received, I hope to work out a code to find a way to calculate if it is within 30m or out of 30m? Something like that. There are thesis on Triangulation and Tri-lateration but I am currently working on just Zoning.

Could you recommend me a way? If it is really impossible to read RSSI. Thanks!

PaulS: OP: You've said nothing about having enabled RSSI.

Sorry, I forgot to mention that I used x-CTU to configure my XBees. Erm, yes I enabled my P0 to output RSSI. From what I understand, the Router Serial Log prints Hello World. From there, the Arduino board sends it to the XBee through the wireless shield through the Tx -> Rx and Rx -> Tx wire. The Router XBee then transmit this information to the Coordinator XBee (DH and DL set to 0) and the Coordinator XBee receives this packet of bytes.

This is how I am understanding the way they are working now. As mentioned above, is there any way to just state whether the Router AT XBee is in range of 30m within the Coordinator API?

yes I enabled my P0 to output RSSI.

Your Post Office outputs RSSI?

From what I understand, the Router Serial Log prints Hello World.

What is a Router Serial Log? Why would it print Hello World? A Router might print Hello World, though that is unlikely. The Arduino that an XBee, configured as a Router, might print Hello World.

is there any way to just state whether the Router AT XBee is in range of 30m within the Coordinator API?

It does not make sense to have the Router in AT mode and the Coordinator in API mode. Both should be using AT mode or API mode.

If you use API mode on both, the API packet contains an RSSI value.

PaulS: Your Post Office outputs RSSI?

Oh my, my typo sorry. It is P0 not PO. P0 is the pin 6 of the XBee. Haha.

PaulS: What is a Router Serial Log? Why would it print Hello World? A Router might print Hello World, though that is unlikely. The Arduino that an XBee, configured as a Router, might print Hello World.

Sorry, I meant that the Router, when connected to the Laptop, has an arduino prog that prints Hello World on its on arduino board. Just wanted everyone to understand that my Router is sending an API packet frame to the Coordinator API with "Hello World" as an example.

PaulS: It does not make sense to have the Router in AT mode and the Coordinator in API mode. Both should be using AT mode or API mode. If you use API mode on both, the API packet contains an RSSI value.

Thanks for this tip Paul, the reason why I tried Router in AT and Coordinator in API was that many tutorials out there showed this. Since I am still learning, I followed the example thoroughly. However, this is not working very well for me. I am currently still trying both in API modes. I will update what I have gotten.

Thanks Paul and everyone for the prompt replies! I really appreciate the guidance you guys are giving me.

Technically my end goal is to do Zoning, I will have a Coordinator API as a "Reader" and I need another 3 "Readers" which I may use Routers (API or AT, I have not confirmed yet as I am still trying) to read another 3 "Tokens" (either Routers or End devices, not confirmed yet as I am still trying).

This will be my end goal.

Any recommendations?