RadioHead rf95.lastRssi() to String

I use the RadioHead Library for the Adruino LoRa Shield and I’m heaving problems with the conversion of the rf95.lastRssi() to an Integer or String.

Serial.print(rf95.lastRssi(), DEC); 

gives me for example correctly -20

int iRssi = (rf95.lastRssi(), DEC);

gives me however 10 at the same time.

String sRssi = String((rf95.lastRssi(), DEC));

gives me also 10 at the same time.

What is going wrong with the conversion?

Serial.print(rf95.lastRssi(), DEC);

prints the value returned by the rf95.lastRssi() function

int iRssi = (rf95.lastRssi(), DEC);

prints a variable, the origin of which you do not say. Is it any surprise that they are different ?

What variable type does the rf95.lastRssi() return and why do you want to convert it to a String ?

Actually I‘d like to print this RSSI value on an OLED Display. For that I need this value as a String.

Serial.print(rf95.lastRssi(), DEC);  // -20

Int iRssi = (rf95.lastRssi(), DEC);   
String sRssi = String((rf95.lastRssi(), DEC));

Serial.println(iRssi);   // 10
Serial.println(sRssi);   // 10

do {  
  u8g2.drawStr(0, 15, sRssi.c_str());    // 10
} while (u8g2.nextPage());

That sounds very unlikely
What does


print, for example ?

I can assure you that you dont need to convert the RSSI reading to a String to display it on an OLED. From one of my own programs;

disp.setCursor(0, 1);
disp.print(F("RSSI "));

Where PacketRSSI is an int16_t

Now, I've got it.

The problem was:

Int iRssi = (rf95.lastRssi(), DEC); 

It should have been:

int16_t iRssi = rf95.lastRssi();

Now the value of RSSI are correct. Thanx for the hints!

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.