Hi.
I’m trying to read RSSI of received signal from xBee.
I wrote this code for Arduino:
#include ;
SoftwareSerial mySerial(10, 11); // RX, TX
int rssi;
void serialFlush()
{
while(mySerial.available() > 0)
char t = mySerial.read();
}
void setup()
{
Serial.begin(9600);
mySerial.begin(9600);
}
void loop()
{
rssi=0;
if(mySerial.available())
{
serialFlush();
mySerial.print(“+++”);
while(!mySerial.available());
serialFlush();
mySerial.println(“ATDB”);
while(mySerial.available())
{
rssi = mySerial.read();
Serial.print(rssi);
Serial.print(" ");
}
Serial.println("");
mySerial.print("ATCN");
}
delay(1000);
}
And i see these output from serial monitor:
26 57 13
13 156 195
26 156 13
26 78 195
26 57 13
26 57 13
26 80 195
26 156 13
26 57 13
26 50 68 13
26 50 67 13
26 153 81 195
26 50 65 13
26 50 56 13
26 50 56 13
26 50 57 13
26 51 48 13
26 49 57 13
26 76
26 49 65 13
Which is absolute non-sense. It should return only one byte (usually negative integer)
On other xbee i’m just posting “hi” messege to the air and also i’m changing the module’s position but i could not find any sequance (during the experiment, the distance is always increased.).
and als ATCN command is not working. I need to wait about 3-5 (no sure) seconds to receive another message.
can anyone help me?