Arduino-XBee S2 to retrieve the RSSI value using AT commands

Good day to you!

I am doing a project to track an object using Arduino-XBee S2 pairs and I am trying to retrieve the RSSI value. I have found a code to get the RSSI value using AT commands as below. One XBee S2 have been set as Coordinator AT and the other have been set as Router AT. I am using one Arduino Uno and one Arduino Nano. Here is the code for the transmitter and receiver:

Transmitter:
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

void setup()
{

Serial.begin(9600);
lcd.begin(16, 2);
lcd.println("I am Porky, ");

}

int second;
int minute = 0;
int hour = 0;
void loop()
{
for (int second=0; second<=59; second++) // count 60 seconds
{

Serial.println("\n I am Porky, ");
lcd.setCursor(0, 1);
lcd.print(hour);
Serial.print(hour);

lcd.print(":");
Serial.print(":");

lcd.print(minute);
Serial.print(minute);

lcd.print(":");
Serial.print(":");
lcd.print(second);
Serial.print(second);

second++;
second++;
second++;
second++;
delay(4999);

}
second = 0; // 60 seconds later reset to zero
minute ++; // add 1 minute

if (minute>=59) // if 60 minutes has passed
{
minute=0; // reset minutes to zero
hour++; // increment one hour

}
if (hour>=24) // if 24 hours has passed
{
hour=0; // reset to zero hour and start over

}
}

Receiver:
char incomingByte; // for incoming serial data

void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
}

void loop() {
delay(4000);
Serial.print(“Router x\n”);

}

//When there is serial data it reads and sends whatever is received. No data, only router x will be transmitted.
void serialEvent(){
// send data only when you receive data:

if (Serial.available() > 0) {
// read the incoming byte:
incomingByte = Serial.read();
}

delay(2000);
Serial.print("+++");
delay(1000);
Serial.print("\n");
Serial.println(“ATDB”);
delay(100);

while (Serial.available() > 0) {
Serial.write(Serial.read());
Serial.setTimeout(2000);
}

Serial.println();
Serial.println("\n");
Serial.println(“ATCN”);
delay(100);
while (Serial.available() > 0) {
Serial.write(Serial.read());
Serial.setTimeout(2000);
}
Serial.println();
Serial.flush();
}

When I sketched these two codes, I could not get the RSSI value on the serial monitor as supposed. I am thinking of the mistake about the serial connection as I do not have any Arduino-XBee shield. I only connected them by wiring. Could you please help me clarify this. Much appreciated.

I only connected them by wiring.

Which you couldn't be bothered to describe.

I am doing a project to track an object using Arduino-XBee S2 pairs

Which you couldn't be bothered to tell us how they are configured.

Here is the code

Which you couldn't be bothered to post properly (or format correctly before mis-posting).

Could you please help me

I don't think so.

PaulS:

I only connected them by wiring.

Which you couldn't be bothered to describe.

I am doing a project to track an object using Arduino-XBee S2 pairs

Which you couldn't be bothered to tell us how they are configured.

Here is the code

Which you couldn't be bothered to post properly (or format correctly before mis-posting).

Could you please help me

I don't think so.

Sorry for not giving you detailed information. Honestly I am new to the forum hence I do not know how to post it properly. Please forgive my fault. I will try to improve it over time.

Let me describe the wiring of the Arduino-XBee first. I connected the 3.3V of the Arduino to the Vin of the XBee, the ground of the Arduino to the ground of the XBee, the Rx pin of the Arduino to the Tx pin of the XBee and vice versa, the Tx pin of the Arduino to the Rx pin of the XBee. Please find attached the picture of this setup. Note that the other Arduino-XBee pair I wired the same thing.

For my project, it is hard to explain in here because it will take much time. I can briefly describe one objective is to retrieve the RSSI value from two pairs of Arduino-XBee (one will transmit a message and the other one will receive it and display the RSSI value).

For the format of the code, as I said, I am new to this forum and I do not know how to post it in a correct format. Can you please give me a guidance and I will make it.

Thank you very much for your patience and please forgive my fault.

WP_20131211_18_48_00_Pro[1].jpg|3552x2000

For the format of the code, as I said, I am new to this forum and I do not know how to post it in a correct format. Can you please give me a guidance and I will make it.

http://forum.arduino.cc/index.php?topic=149014.0 http://forum.arduino.cc/index.php?topic=97455.0

Thank you very much for your patience and please forgive my fault.

Done. Now, how did you configure the XBees?