SparkFun Forums 

Where electronics enthusiasts find answers.

All things pertaining to wireless and RF links
By jysgymg
#188303
And yes, when I change my for loop to the normal 19,20,21,22, it gives FFFFFFFF, FFFFFFFF

It is like it deleted the bytes at the end which is absurd.

When I program the XBees Series 2 to this:
void setup()
{
Serial.begin(9600);
Serial3.begin(9600);
}
void loop()
{
if (Serial3.available()>=21){
for(int i=0;i<22;i++){
Serial.print(Serial3.read(),HEX);
Serial.print(",");
}
Serial.println();
}
}

It reads all 22 api frames from start delimiter to checksum.

Its like the code discarded half of the frames. Like the even half of the frames leaving only the odd half behide.

22-byte frames:
7E,0,12,92,0,13,A2,0,40,E7,79,DB,70,9E,1,1,0,0,8,2,9,1A
My byte frames:
7E,12,0,A2,40,79,70,1,0,8,9,FFFFFFFF,FFFFFFFF,FFFFFFFF,FFFFFFFF,FFFFFFFF,FFFFFFFF,FFFFFFFF,FFFFFFFF,FFFFFFFF,FFFFFFFF,FFFFFFFF,FFFFFFFF,

See how the "even" bytes are taken out?

I dont know if its the cause of the weird RSSI readings, but I am not going to do a distance test with what I have. I am doubting alot on the values though. Will screenshot and update ASAP.
By jysgymg
#188304
Hi just to update,

it seems that the distance may or may not affect the "RSSI" values that are printed onto the Serial Log. (yup, the open inverted commas as I am still unsure if its really the RSSI values).

Another experiment I did is that when I actually blocked the Line of Sight(LOS) of the 2 XBees, there were actually values. I also did hook it up to an oscilloscope and it showed a PWM signal. So, I did many funny things like using my body to block LOS, used my hand to block the antenna at touching distance, using my hands to block the LOS etc... and all of these actually resulted in values shown onto the Serial Log.

And its always random, it ranges from 8 to 110! But mostly the numbers are between 8 to 21.

I am certain this is not the RSSI signal? Or I am reading something wrong or coding something wrong.

Going to continue researching and experimenting now. Wish me luck.
By Valen
#188321
Have you read the Xbee manual? It explains how the API packets are structured. I already said what needs to be done with the bytes following '7E'. They make up the length. That tells you how long the for loop should read bytes of the packet. But it should not dumb read the data. It should look what those bytes are and check if they are the specific values that are important for it.

There are a few libraries for Arduino that interpret Xbee API packets. I suggest you use them. If you are serious in wanting to learn how to program you also try to learn the basics about if-statements and for- or while-loops. Without them you'll not get very far. Learn what the code does by taking each line step-by-step and do in your mind (or better on paper) what the arduino is doing. That is how I started and what I am still doing when I am trying to help people here.
By jysgymg
#188655
Hi Valen and all,

First of all, I have gotten the RSSI values with range experiments. They seem to fluctuate a lot.
Valen wrote:Have you read the Xbee manual? It explains how the API packets are structured. I already said what needs to be done with the bytes following '7E'. They make up the length. That tells you how long the for loop should read bytes of the packet. But it should not dumb read the data. It should look what those bytes are and check if they are the specific values that are important for it.

There are a few libraries for Arduino that interpret Xbee API packets. I suggest you use them. If you are serious in wanting to learn how to program you also try to learn the basics about if-statements and for- or while-loops. Without them you'll not get very far. Learn what the code does by taking each line step-by-step and do in your mind (or better on paper) what the arduino is doing. That is how I started and what I am still doing when I am trying to help people here.
I think after reading other forums as well as more thesis and tutorials, after doing some experiments with RSSI values, the RSSI is either:

1. Not very accurate, as the results fluctuates in that specific distance. For example, for 5m, it fluctuates from 4 to 28. 10m would be around 8 to 36 and so on. There are overlaps of the RSSI values.

2. I could be reading something else entirely! For now I am only using the pulseIn() function so I am not sure if this is really RSSI. There are formulas to calculate the RSSI but I just got the experimental results so I have not conclude this part yet. For now, what the results show is that these RSSI values do increase when distance increase and if the XBee (Router AT) is blocked by a wall or anything.

3. Wrongly read. In this case, maybe I have made some wrong connections here and there. The manual do states that there will be RSSI value in the API frame but I cant seem to get that specific frame. Also the XBee library is not helping me as I am stuck at calling the functions out (no idea why, maybe someone can enlighten me on this), like for example if I were to type
//
if(xbee.getResponse().isAvailable()){
Serial.print("I am here");
}
//
This dosent work but if i type
//
if(Serial3.available() > 21) {
if(Serial3.read() == 0x7E){
Serial.print("I am here");
}}
//
and it does work.

Just an update for everyone and also if anyone has any recommendations or comments, do feel free to post them. I may be coming to the end of my Project soon.

Cheers!
By jremington
#188657
Other things being equal, the RSSI value depends much more strongly on relative antenna orientation and absorption or interference effects than it does on distance, so it is nearly useless as a distance measure.

There are exceptions under very carefully controlled circumstances, of course.
By jysgymg
#188669
jremington wrote:Other things being equal, the RSSI value depends much more strongly on relative antenna orientation and absorption or interference effects than it does on distance, so it is nearly useless as a distance measure.

There are exceptions under very carefully controlled circumstances, of course.
Its a project requirement though, and I usually do the experiments in the same place (the only controlled constant I can do). I will keep updating on my work before my project comes to an end.

Thanks to all that have given me guidance and feedbacks!