SOS I am harmful in arduino. My objective so far is to retrieve the RSSI (Received Signal Strength Indication) of an Xbee3.0 (denoted Xb1 thereafter and in API mode) connected to an Arduino Mega. The latter is connected to the computer by cable. Xb1 receives a signal from another Xbee3.0 (denoted Xb2 - also in API mode). Xb2 is connected directly to the computer and sends information via XCTU.
From what I see, Xb1 is receiving information from Xb2. The problem is that I can’t display on Arduino the RSSI of the Xb1.
Xb1 is connected via PWM 10 of the arduino mega and via Tx and Rx (and is of course powered and grounded). I tried several codes, including this one:
#include <XBee.h>
#include <SoftwareSerial.h>
// 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(100);
if (xbee.getResponse().isAvailable())
{
Serial.println(“available”);
if(xbee.getResponse().getApiId() == RX_64_RESPONSE || xbee.getResponse().getApiId() == RX_16_RESPONSE)
{
Serial.println(“16”);
if (xbee.getResponse().getApiId() == RX_16_RESPONSE)
{
Serial.println(“16”);
xbee.getResponse().getRx16Response(rx16);
//option = rx16.getOption();
//data = rx16.getData(0);
int rssi = rx16.getRssi();
Serial.print("data: ");Serial.println(data);
Serial.print("option: ");Serial.println(option);
Serial.print("RSSI: ");
Serial.println(rssi);
}
else
{
Serial.println(“64”);
xbee.getResponse().getRx64Response(rx64);
//option = rx64.getOption();
//data = rx64.getData(0);
int rssi = rx64.getRssi();
Serial.print("RSSI: ");
Serial.println(rssi);
}
}
}
}
…which unfortunately did not give me satisfaction. The conditions would obviously not be verified. Do you have any idea why this is not working? Thanks in advance, Cordialy