sandeepmistry / arduino-LoRa

An Arduino library for sending and receiving data using LoRa radios.
MIT License
1.64k stars 627 forks source link

fix mid band threshold and add function to get current RSSI value #288

Closed sergio303 closed 3 years ago

sergio303 commented 4 years ago

Mid band threshold used for RSSI calculation is wrong, causing incorrect RSSI values for frequencies on the HF band but below 868 MHz . Semtech reference code uses 525 MHz as threshold for RSSI calculation:

/*!
 * Constant values need to compute the RSSI value
 */
#define RSSI_OFFSET_LF                              -164.0
#define RSSI_OFFSET_HF                              -157.0
#define RF_MID_BAND_THRESH                          525000000
torntrousers commented 4 years ago

Watching with interest. Update this too? - https://github.com/sandeepmistry/arduino-LoRa/blob/master/API.md

morganrallen commented 4 years ago

Yeah, please add the new rssi method to the API otherwise this looks good to me. @torntrousers or anyone else have thoughts? I'll read through the datasheet again the merge this if there are no concerns.

torntrousers commented 4 years ago

LGTM

sergio303 commented 4 years ago

API updated. New rssi method can be used to watch channel activity. I'm also looking at packet rssi calculation in Semtech datasheet and code, it looks like some adjustment is needed when packets are received below the noise floor (snr <0), will submit a separate PR when I sort things out...

IoTThinks commented 3 years ago

@morganrallen @sandeepmistry I realized I reinvented the wheel today by doing the same code for rssi() Could you help to review and to push this to your repository?

Yes, the threshhold for LF and HF should be 525Mhz instead of 868Mhz. image

sandeepmistry commented 3 years ago

@IoTThinks thanks for nudging this PR :)

IoTThinks commented 3 years ago

Later, I will test on the merged code.

Thanks a lot for your effort.