How can I measure the RSSI value using an Xbee Series 1?

This is my first question ever on Arduino Forums so bear with me if I've done/said anything that is not of this site's "ethics". Moving on to the matter at hand...

I'm graduating in 1 week with a Bachelor's Degree in Electronics, Electrical, and Comms engineering. My only course this semester is Undergraduate Research and the topic is getting the RSSI value as well as the distance -both wirelessly using a battery attached to the Arduino- from an Xbee Series 1 attached to an Xbee Shield mounted on an Arduino Uno R3 and a second Xbee Series 1 attached to an Xbee Explorer Dongle connected to my Windows PC, (no breadboards are used). I've been able to have both Xbees talk to each other on XCTU but that's about it, unfortunately.

I've got the connections figured out, but I just can't seem to be able to figure out a proper code to upload onto the Arduino IDE since this is my first time ever using an Arduino. (And even if I do have a proper code, I don't know how to check if it works or not).

I'd appreciate everyone helping me graduate and become an engineer :). This thread is literally my final hope in passing this course.

Any further info/details/pictures shall be provided upon request.

Thanks in advance,

Aj

I’m graduating in 1 week with a Bachelor’s Degree in Electronics, Electrical, and Comms engineering.

the topic is getting the RSSI value as well as the distance

Have you thought of checking the data sheet ?

RSSI will only provide a measure of distance in very special circumstances.

You will have a tough time starting from scratch to learn enough about Ardunio to be able to read RSSI\Distance from the Xbee in a week, so I would guess you will fail, you should have thought about the project a long time ago.

srnet:
Have you thought of checking the data sheet ?

RSSI will only provide a measure of distance in very special circumstances.

You will have a tough time starting from scratch to learn enough about Ardunio to be able to read RSSI\Distance from the Xbee in a week, so I would guess you will fail, you should have thought about the project a long time ago.

Thanks for the reply. If I’m able to get the RSSI, I will use a formula to get the distance from the RSSI. Anyway, this is the code I’m using:

#include <XBee.h>
#include <SoftwareSerial.h>
#include <LiquidCrystal.h>

LiquidCrystal lcd(12,11,5,4,3,2);

// XBee’s DOUT (TX) is connected to pin 8 (Arduino’s Software RX)
// XBee’s DIN (RX) is connected to pin 9 (Arduino’s Software TX)
SoftwareSerial serial1(8, 9); // RX, TX

XBee xbee=XBee();
XBeeResponse response = XBeeResponse();
Rx16Response rx16 = Rx16Response();
Rx64Response rx64 = Rx64Response();

uint8_t option = 0;
uint8_t data = 0;
uint8_t rssi = 0;

void setup()
{
Serial.begin(9600);
serial1.begin(9600);
xbee.setSerial(serial1);
lcd.begin(16,2);
lcd.clear();
}

void loop()
{
xbee.readPacket(100);
if (xbee.getResponse().isAvailable())
{
Serial.println(“available”);
if(xbee.getResponse().getApiId() == RX_64_RESPONSE || xbee.getResponse().getApiId() == RX_16_RESPONSE)
{
Serial.println(“16”);
if (xbee.getResponse().getApiId() == RX_16_RESPONSE)
{
Serial.println(“16”);
xbee.getResponse().getRx16Response(rx16);
//option = rx16.getOption();
//data = rx16.getData(0);
rssi = rx16.getRssi();
//Serial.print("data: ");Serial.println(data);
//Serial.print("option: ");Serial.println(option);
lcd.clear();
lcd.print(rssi);
Serial.println(rssi);
}
else
{
Serial.println(“64”);
xbee.getResponse().getRx64Response(rx64);
//option = rx64.getOption();
//data = rx64.getData(0);
rssi = rx64.getRssi();
lcd.clear();
lcd.print(rssi);
Serial.println(rssi);
}
}
}
}

The above code works as it should be, but no readings are showing up on the IDE serial monitor even though the RSSI LED on the XBee Shield lights up when I start a loop (infinite sequence) of 16-bit messages on XCTU then it turns off when I stop the said loop. What are your thoughts?

Also posted at:
https://arduino.stackexchange.com/q/58637

I will use a formula to get the distance from the RSSI.

What formula would that be? Do you even have a clue what the R stands for? The I?

pert:
Also posted at:
https://arduino.stackexchange.com/q/58637

Correct! But since I didn't get any useful info over there, I thought I'd try here.

PaulS:
What formula would that be? Do you even have a clue what the R stands for? The I?

Yes, I do know what RSSI stands for. The formulae that I'm talking about are:

1- RSSI (dBm)=-10n log_10⁡(d)+A, where (n) is the propagation constant, (d) is the distance in meters, and (A) is received signal strength in dBm at 1 meter.

OR

2- d= 10^[(Po-Fm-Pr-10nlog_10(f)+30n-32.44)/10n], where (Fm) is the fade margin, (Po) is the signal power at 0 distance, (Pr) is the signal power at a given distance, (F) is the signal frequency in Hz, and (n) is the path-loss exponent.

Anyway, my Arduino serial monitor still shows no readings whatsoever. Is it possible that it might only show the RSSI readings on an LCD screen?

Any help would be greatly appreciated!

Is it possible that it might only show the RSSI readings on an LCD screen?

No. A value is a value. You can send it to an LCD, or the serial port.

Where IS your code? How is the XBee connected to the Arduino?

PaulS:
No. A value is a value. You can send it to an LCD, or the serial port.

Where IS your code? How is the XBee connected to the Arduino?

This is the code I’ve uploaded onto the Arduino Uno:

#include <XBee.h>
#include <SoftwareSerial.h>
#include <LiquidCrystal.h>

LiquidCrystal lcd(12,11,5,4,3,2);

// XBee’s DOUT (TX) is connected to pin 8 (Arduino’s Software RX)
// XBee’s DIN (RX) is connected to pin 9 (Arduino’s Software TX)
SoftwareSerial serial1(2, 3); // RX, TX

XBee xbee=XBee();
XBeeResponse response = XBeeResponse();
Rx16Response rx16 = Rx16Response();
Rx64Response rx64 = Rx64Response();

uint8_t option = 0;
uint8_t data = 0;
uint8_t rssi = 0;

void setup()
{
Serial.begin(9600);
serial1.begin(9600);
xbee.setSerial(serial1);
lcd.begin(16,2);
lcd.clear();
}

void loop()
{
xbee.readPacket(100);
if (xbee.getResponse().isAvailable())
{
Serial.println(“available”);
if(xbee.getResponse().getApiId() == RX_64_RESPONSE || xbee.getResponse().getApiId() == RX_16_RESPONSE)
{
Serial.println(“16”);
if (xbee.getResponse().getApiId() == RX_16_RESPONSE)
{
Serial.println(“16”);
xbee.getResponse().getRx16Response(rx16);
//option = rx16.getOption();
//data = rx16.getData(0);
rssi = rx16.getRssi();
//Serial.print("data: ");Serial.println(data);
//Serial.print("option: ");Serial.println(option);
lcd.clear();
lcd.print(rssi);
Serial.println(rssi);
}
else
{
Serial.println(“64”);
xbee.getResponse().getRx64Response(rx64);
//option = rx64.getOption();
//data = rx64.getData(0);
rssi = rx64.getRssi();
lcd.clear();
lcd.print(rssi);
Serial.println(rssi);
}
}
}
}

I’ve got 2 Xbees Series 1. One is connected to the Xbee Explorer USB and is directly connected to my PC, the other Xbee is connected to an Xbee (SparkFun) Shield mounted on top of the Uno which is connected to the PC through a USB cable. When I upload the code and start sending (TX Request 16-bit Address) messages from the XCTU, the Shield’s RSSI LED lights up and then it goes off when I stop sending any message. Could this be a connection error?

madAj:
Correct! But since I didn't get any useful info over there, I thought I'd try here.

If you're going to do that, you should post links from one to the other so that the people trying to help you or others with the same question can easily find all the information on the topic. It's possible someone could write a good answer to the SE question at any time in the future.

madAj:
This is the code I’ve uploaded onto the Arduino Uno:

Please use code tags (</> button on the toolbar) when you post code or warning/error messages. The reason is that the forum software can interpret parts of your code as markup, leading to confusion, wasted time, and a reduced chance for you to get help with your problem. This will also make it easier to read your code and to copy it to the IDE or editor. If your browser doesn’t show the posting toolbar then you can just manually add the code tags:

[code]

[color=blue]// your code is here[/color]

[/code]

Using code tags and other important information is explained in the How to use this forum post. Please read it.

pert:
Please use code tags (</> button on the toolbar) when you post code or warning/error messages. The reason is that the forum software can interpret parts of your code as markup, leading to confusion, wasted time, and a reduced chance for you to get help with your problem. This will also make it easier to read your code and to copy it to the IDE or editor. If your browser doesn’t show the posting toolbar then you can just manually add the code tags:

[code]

[color=blue]// your code is here[/color]

[/code]

Using code tags and other important information is explained in the How to use this forum post. Please read it.

Oh, I see. Thank you very much for the tips!!

1- RSSI (dBm)=-10n log_10⁡(d)+A, where (n) is the propagation constant, (d) is the distance in meters, and (A) is received signal strength in dBm at 1 meter.

OR

2- d= 10^[(Po-Fm-Pr-10nlog_10(f)+30n-32.44)/10n], where (Fm) is the fade margin, (Po) is the signal power at 0 distance, (Pr) is the signal power at a given distance, (F) is the signal frequency in Hz, and (n) is the path-loss exponent.

Which formula will you be using, and what values will be used for the "propagation constant", the "path loss exponent", the "fade margin", etc.?

How will you handle the environmental effects not included in either formula, like relative antenna orientation, multipath propagation and constructive/destructive interference?

This thread is literally my final hope in passing this course.

Sorry to hear that you are doing so poorly, one week from graduation.

jremington:
Which formula will you be using, and what values will be used for the "propagation constant", the "path loss exponent", the "fade margin", etc.?

How will you handle the environmental effects not included in either formula, like relative antenna orientation, multipath propagation and constructive/destructive interference?
Sorry to hear that you are doing so poorly, one week from graduation.

If I have been unable to figure out the distance, I'll just ask my supervisor. He's ought to help me with this. Though I do need to come up with a way on my own to get the readings showing on the serial monitor of the Arduino.

When I upload the code and start sending (TX Request 16-bit Address) messages from the XCTU, the Shield's RSSI LED lights up and then it goes off when I stop sending any message.

How, exactly, are you sending the messages?

You can configure the XBee, which is both a radio and a microcontroller, to read pins and generate packets, and transmit them to other XBees. Those packets WILL contain RSSI data.

If you are manually generating packets, you must include the RSSI value. The XBee will NOT add it.

PaulS:
How, exactly, are you sending the messages?

You can configure the XBee, which is both a radio and a microcontroller, to read pins and generate packets, and transmit them to other XBees. Those packets WILL contain RSSI data.

If you are manually generating packets, you must include the RSSI value. The XBee will NOT add it.

This is how I send the messages. Through the Xbee connected to the PC (the one connected to the dongle) via XCTU where I manually generate frames and set them to a loop.

where I manually generate frames

Do you know what all the values in the frames mean?
7E is the start of a frame.
The next two bytes define the size of the frame.
The rest of the data is the frame data. The RSSI value is the 3rd value in the frame. So, you are ALWAYS sending 00 as the RSSI value. No wonder that is all you read.

The XBee CAN, if properly configured, make the RSSI value that it measures, available to you, but you have to connect the pin that it outputs that value on to an Arduino pin, of the right type, and have the Arduino read the value.

Or, you configure the XBee to generate and send a packet, containing the value of some digital pin whose value you don't give a rat's ass about. THAT packet will contain real RSSI data though.

Relative signal strength Indicator means just that, though. The Indication that you get, of the Relative signal strength, is NOT a good indicator of distance. At best, you've come up with close, not to far, far, and out-of-range, where far means that the signal strength has diminished because of a hard journey. Whether that is because the signal traveled a long ways, bulled through three concrete walls, or bounced around like a pinball in a youtube video running at 10 times the recorded rate does not matter.

PaulS:
The XBee CAN, if properly configured, make the RSSI value that it measures, available to you, but you have to connect the pin that it outputs that value on to an Arduino pin, of the right type, and have the Arduino read the value.

Or, you configure the XBee to generate and send a packet, containing the value of some digital pin whose value you don't give a rat's ass about. THAT packet will contain real RSSI data though.

I legit have no idea what all this means. I thought that the Shield-Arduino connection is like an "inclusive" connection where I just connect the two together and voila! everything would work the way I wanted it. But I guess not... Anyway, according to what you wrote, I think I'm F'd.

Thank you all for trying to help. This truly is a good forum! Buuuuut.. guess who WON'T be graduating in a week..

I thought that the Shield-Arduino connection is like an "inclusive" connection where I just connect the two together and voila! everything would work the way I wanted it.

The only 4 pins that the shield connects to the XBee are RX, TX, 3V, and Gnd. If you want to use the microcontroller on the radio, you have to make additional connections yourself. I believe that it is pin 9 of the XBee that supplies RSSI data.