RSSI values from XBees reported as hex absolute values, but only numbers.

I'm measuring RSSI values from data packages sent between two XBees in API mode.
From what I've read, the RSSI values are reported as an absolute value in hex (For example: 0x58 = -88 dBm), which is accurate most of the time, for example when I have values fluctuating between 52 and 54 for a set distance.

But the reported values are always numbers and never letters (like 5A), so for one distance I can get 58,58,59,58,59,60,60,59 etc. But since this is in hex there is a gap from -89 to -96 dBm.
Is it suppose to be like this? Is it really in hex? What can I do about it?

"Hex" is one representation of a binary number, stored in the computer. "Decimal" is another. They are exactly equivalent in terms of the quantity that they represent. Using Arduino Serial.print(), you can print either representation.

jremington:
“Hex” is one representation of a binary number, stored in the computer. “Decimal” is another. They are exactly equivalent in terms of the quantity that they represent. Using Arduino Serial.print(), you can print either representation.

Yes, I know, but the question was why I don’t receive RSSI values like 5A etc. I think I found the mistake in my code though, because I declare “rssi” to be an int.

#include <XBee.h>
XBee xbee = XBee();
Rx16Response rx16 = Rx16Response();
Tx16Request tx16;
int rssi;

void setup() {
  Serial.begin(9600);
  xbee.begin(Serial);
}

void loop() {
  xbee.readPacket(100);
  if (xbee.getResponse().isAvailable()){
    if (xbee.getResponse().getApiId() == RX_16_RESPONSE) {
      xbee.getResponse().getRx16Response(rx16);
      rssi = rx16.getRssi();
      Serial.println(rssi);
      tx16=Tx16Request(0xFFFF, rssi ,sizeof(rssi));
      xbee.send(tx16);
     // delay(50);
    }
  }
}

How should I declare rssi in order to send the value back to the other XBee?

the question was why I don't receive RSSI values like 5A etc.

You do, but you do not yet understand that you are actually receiving binary values.

If you never see numbers like "5A" or "2F", that is because you are printing out the decimal representation of the binary value.

jremington:
You do, but you do not yet understand that you are actually receiving binary values.

If you never see numbers like "5A" or "2F", that is because you are printing out the decimal representation of the binary value.

So I receive binary numbers and if I print it like Serial.println(rssi) it will print out that number as a decimal representation? I don't think so because those numbers are way off if they are in decimal.
I should get -54 dBm at 1m ish and if I print it like I do above I get 36 which is -54 dBm if I go from hex to decimal.

I can print it in HEX and instead of 36 I get 24, but this is not the value I want. It says on XBees website that the RSSI is in hex already.

Serial.println(rssi) it will print out that number as a decimal representation?

That is the default.

Serial.println(rssi, HEX);
it only prints 0 all the time..

Then rssi = 0.

This is getting tiresome. Please read "How to use this forum" and post your ALL your code, using code tags.

jremington:
That is the default.
Then rssi = 0.

This is getting tiresome. Please read "How to use this forum" and post your ALL your code, using code tags.

I edited my response, it is not 0 all the time. I did post all my code above using code tags.

I can print it in HEX and instead of 36 I get 24

The HEX representation of DECIMAL 36 is 24. Both correspond to BINARY value 0b100100, stored in the computer.

jremington:
The HEX representation of DECIMAL 36 is 24. Both correspond to BINARY value 0b100100, stored in the computer.

I KNOW. You don't understand what I'm trying to say. The thing is that 36 is in HEX already, because I should receive 54 in DEC at 1m. According to XBee datasheet, getRssi() gives you the value in HEX.

According to XBee datasheet, getRssi() gives you the value in HEX.

This is nonsense.

jremington:
This is nonsense.

It’s not nonsense because you should get a signal strength of -54 dBm at 1m (36 in HEX) and not -36 dBm (24 in HEX).

Good luck with your project!

jremington:
This is nonsense.