arduino-dra818
arduino-dra818 copied to clipboard
Is the rssi functionality really implemented?
I don't see that the rssi() function returns anything useful (the "rssi" value). It seems that the return value is simply a success or failure indication, not the numerical value for the measured received signal strength indication. I ended up implementing the following on my Arduino loop() function to get the value outside of this library's class code:
#define TIMEOUT 500 char buf[5];
dra_serial->print(F("RSSI?\r\n"));
long start = millis(); do { if (dra_serial->available()){ buf[0] = buf[1]; buf[1] = buf[2]; buf[2] = buf[3]; buf[3] = buf[4]; buf[4] = dra_serial->read(); } } while (buf[4] != 0xa && (millis() - start) < TIMEOUT);
if ((buf[4] == 0xA)) { s = ( (buf[0]-'0')*100 + (buf[1]-'0')*10 + (buf[2]-'0') ); // convert RSSI measurement to int sMeter(s); // update the signal meter with new RSSI }
This works on my ESP32 with a SA818. Btw, in 'setup()' I have "dra_serial = new HardwareSerial(2);". Ideally, it seems like the return value from a call to the library function "int rssi()" might return -1 if it fails (timeout) and if successful it would return the positive value of the rssi returned from the radio module.
Note that despite the poor documentation of the SA818 indicating that the value is 0 to 255, in actuality it appears to be 0 to 127 with a "no antenna connected" noise floor that rests around 20.