Hi,
I am trying to display the signal strength of the LoRa receiver on the Oled display but when I compile I get the following error:
no matching function for call to 'drawStr(int, int, int)'
for the line:
u8g.drawStr( 0, 35, LoRa.packetRssi());
but it outputs to serial ok.
That's where I'm stuck at the moment. The next hurdle will be to also display the first 6 or so characters of the received packet and then the project will be complete.
Any ideas?
Thank you
#include <SPI.h>
#include <LoRa.h>
#include "U8glib.h"
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE | U8G_I2C_OPT_DEV_0); // I2C / TWI
void setup() {
Serial.begin(115200);
delay(10000); // I added this to give me time to open serial monitor.
while (!Serial);
Serial.println("LoRa Receiver");
if (!LoRa.begin(433E6)) {
Serial.println("Starting LoRa failed!");
while (1);
}
}
void loop() {
// try to parse packet
int packetSize = LoRa.parsePacket();
if (packetSize) {
// received a packet
Serial.print("Received packet '");
// read packet
while (LoRa.available()) {
Serial.print((char)LoRa.read());
}
// print RSSI of packet
Serial.print("' with RSSI ");
Serial.println(LoRa.packetRssi());
}
u8g.firstPage();
u8g.setFont(u8g_font_unifont);
do {
u8g.drawStr( 0, 22, "Hello J"); // Just a test to make sure I can display anything
u8g.drawStr( 0, 35, LoRa.packetRssi());
}
while( u8g.nextPage() );
}
You need to know where to look, there is a reference page for U8glib (I found it via a Google search);
And its clear in the format for u8g.drawStr is;
u8g_uint_t U8GLIB::drawStr(u8g_uint_t x, u8g_uint_t y, const char *s)
So the firast two parameters are integers, the last is a pointer to a character array.
If you find the LoRa.h file you included in your sketch, its somewhere on your PC, you will see inside it that packetRssi() returns an integer, not a pointer;
int packetRssi();
So no wonder you get an error.
Just postion the cursor, and do a;
u8g.print(LoRa.packetRssi());
I would add that the packetSnr() (signal to noise ratio) is a better indicator of how far away the LoRa signal is from failure than RSSI. RSSI becomes inconsitent at around half the range\distance you are getting.
There is a worked example of a LoRa RSSI and SNR meter, using the SSD1306 here;
Re: u8g.drawStr( 0, 22, "Hello J");
The 1st digit is for the horizontal position on the display, The 2nd is vertical, and the 3rd is the displayed string.
If you don't put in the x & Y start point it will not display.
I thought that by replacing "Hello J" with variable LoRa.packetRssi() would work. After all it does work for the serial output, where the command:
Serial.println(LoRa.packetRssi());
Gives a serial output of:
Received packet '39.37,29.21,100849,2644,-1800,15744,-5424,668,-5424,1397942' with RSSI -23
In this case it's the "-23" I'm after
srnet:
I did look at the links you provided before posting and after your reply, but could not find anything that would work. I am not that good at coding to understand it all. I tried setting the cursor but got compile errors for that too. The example of a working LoRa meter seems to output to serial which I already have working and not to a display, or am I missing something.
Thank you for the SNR tip, but first I have to get either.
RedeyePete:
I did look at the links you provided before posting and after your reply, but could not find anything that would work. I am not that good at coding to understand it all.
The example of a working LoRa meter seems to output to serial which I already have working and not to a display, or am I missing something.