Hey everyone!
First off, I would like to thank Valen for his constant replies in trying to solve my question.
I may have found a solution to my problem but I have encountered more questions.
I have found out that my codes and hardware actually works to get RSSI values from 2 XBee Series 2. The only problem was that when I was working with them, both of the XBees were connected to my laptop so they were approx <2m away from one another. This is the reason that it always spark the 0 readings for the RSSI.
Accidentally, I moved 1 of the XBee away when I was using an oscilloscope to try and see if I can get the PWM pulse and VOILA! I actually saw readings of the RSSI! BUT!!!
Here, it spark a few question:
-
Why is it that when the XBees are closed to one another, the RSSI values produced are always 0? I read on so many articles and tutorials where RSSI values are never 0 even at close range.
-
There is a fluctuation of the range of RSSI values (like from 4 to 28) even when both XBees are rooted at one location (no change in distance, height or orientation), why is this so?
-
Even at the same distance, there will be readings of 0, and from 4 to 28. Sometimes there may occur a period of long readings of 0s and I may touch the Arduino boards (moving it a little up and down, left and right or turning it around orientation wise) and it spark a little reading of RSSI values (also from 4 to 28).
-
And lastly, I am still unsure of what the HEX numbers are telling me. It dosent start with 0x7E (start byte) and I read from this link: http://www.digi.com/support/forum/35318 … ignal-rssi
that the RSSI values can be read from the HEX bytes frame. Could someone also tell me how to get the correct byte frame?
I will attach some pictures of my results. Basically I have only tested from 1m(readings of 0) to <4m (readings of 0 - 28).
I will also copy and paste the current codes that I am playing with. I will update regularly on the RSSI readings and experiments.
Cheers!
Codes:
/*
XbeeRSSI.pde
This is a sketch for RSSI-Measurements. The sketch reads the incoming RSSI Value and turns on a LED if the Signal is strong enough.
Please note that the used Value (40) depends on your project environement.
ATTENTION!!!
YOU HAVE TO USE AN ARDUINO WITH AT LEAST TWO SERIAL PORTS!
I am using an Arduino MEGA!
Connect your Xbee RX to Arduino RX!
Connect your Xbee TX to Arduino TX!
And don’t forget the power supply!
RSSI Pin on Xbee → 6
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 = 13; // LED connected to Pin 13
void setup()
{
pinMode(led, OUTPUT);
pinMode(digitalPin, INPUT);
Serial.begin(9600); // this is the connection for your Arduino to your PC/MAC
Serial3.begin(9600); // this is the connection of your Xbee to your Arduino MEGA!!
}
void loop()
{
if(Serial3.available() >= 21) { // This isn’t important. You can do here whatever you want.
if(Serial3.read() == 0x7E) { // Reads the start byte
for(int i = 1; i < 22; i++) {
// byte discardByte = Serial3.read();
Serial.print(Serial3.read(), HEX);
Serial.print(“,”);
}
Serial.println();
for(int j = 1; j < 19; j++) {
byte discardByte = Serial3.read();
rssiDur = pulseIn(digitalPin, LOW, 200); // get’s the RSSI Value
Serial.println(rssiDur); //for debbuging and first setup.
}
// if(Serial3.available() > 21) {
// if(Serial3.read() == 0x7E){
// for(int i=0; i<21; i++) {
// Serial.print(Serial3.read(),HEX);
// Serial.print(“,”);
// }
// delay(1000);
// Serial.println();
// }
if(rssiDur < 40 && rssiDur != 0){ //turns Led on if RSSI is less then 40
// digitalWrite(led, HIGH);
Serial.print(“Zone 1”);
Serial.println();
}
if(rssiDur > 40 && rssiDur != 0){ //turns Led off if RSSI is bigger then 40
// digitalWrite(led, LOW);
Serial.print(“Other Zones”);
Serial.println();
}
}
}
}
//}