ronlat
1
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);
Serial.println(sRssi);
gives me however 10 at the same time.
String sRssi = String((rf95.lastRssi(), DEC));
Serial.println(sRssi);
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);
Serial.println(sRssi);
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 ?
ronlat
3
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
u8g2.firstPage();
do {
u8g2.setFont(u8g2_font_7x14_mf);
u8g2.drawStr(0, 15, sRssi.c_str()); // 10
} while (u8g2.nextPage());
That sounds very unlikely
What does
u8g2.print(123);
print, for example ?
srnet
5
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.clearLine(1);
disp.setCursor(0, 1);
disp.print(F("RSSI "));
disp.print(PacketRSSI);
disp.print(F("dBm"));
Where PacketRSSI is an int16_t
ronlat
6
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!
system
Closed
7
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.