Currently I have 2 xbee series 2 (S2CTH). I connect one with Arduino Uno and set as Coordinator in API mode. Another one sets as end device in API mode, just put on Dongle and connect to computer. I would like to get RSSI and I understand that for series 2, I cannot get RSSI value directly so I use the firmware of series 1 instead. When I send packet using XCTU from end device and using below code, upload via Arduino IDE to Coordinator, I can receive RSSI value as I want. However, my question is “Can I send any code from coordinator to request end device to send back packet so that I can use below code to receive RSSI without end device sending packet from XCTU?”
I’m not sure what frame type I should use for this case. And what should I set to be mode for end device, Transparent Mode or API Mode?
#include
#include
// 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);
}
void loop()
{
xbee.readPacket(1000);
if (xbee.getResponse().isAvailable())
{
Serial.println(“available”);
if(xbee.getResponse().getApiId() == RX_64_RESPONSE || xbee.getResponse().getApiId() == RX_16_RESPONSE)
{
if (xbee.getResponse().getApiId() == RX_16_RESPONSE)
{
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);
Serial.println(rssi);
}
else
{
// Serial.println(“64”);
xbee.getResponse().getRx64Response(rx64);
option = rx64.getOption();
data = rx64.getData(0);
rssi = rx64.getRssi();
Serial.println(rssi);
}
}
}
}