From 0c685ada9b7d9ab534918c43ecd357abe883dc2a Mon Sep 17 00:00:00 2001 From: overkillfpv Date: Thu, 15 Jan 2026 00:24:52 +1100 Subject: [PATCH 1/2] Added in an rssi offset for nodes with an LNA such as a heltec v4. This will correct the noise floor and recieved rssi values --- src/helpers/radiolib/CustomSX1262Wrapper.h | 10 ++++++++-- variants/heltec_v4/platformio.ini | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/helpers/radiolib/CustomSX1262Wrapper.h b/src/helpers/radiolib/CustomSX1262Wrapper.h index 1afee5e8b..87377ceb9 100644 --- a/src/helpers/radiolib/CustomSX1262Wrapper.h +++ b/src/helpers/radiolib/CustomSX1262Wrapper.h @@ -3,6 +3,12 @@ #include "CustomSX1262.h" #include "RadioLibWrappers.h" +// RSSI_OFFSET is used to compensate for external LNA gain (e.g.Heltec V4) +// Set to a negative value equal to the LNA gain to get true RSSI values +#ifndef RSSI_OFFSET + #define RSSI_OFFSET 0 +#endif + class CustomSX1262Wrapper : public RadioLibWrapper { public: CustomSX1262Wrapper(CustomSX1262& radio, mesh::MainBoard& board) : RadioLibWrapper(radio, board) { } @@ -10,9 +16,9 @@ class CustomSX1262Wrapper : public RadioLibWrapper { return ((CustomSX1262 *)_radio)->isReceiving(); } float getCurrentRSSI() override { - return ((CustomSX1262 *)_radio)->getRSSI(false); + return ((CustomSX1262 *)_radio)->getRSSI(false) + RSSI_OFFSET; } - float getLastRSSI() const override { return ((CustomSX1262 *)_radio)->getRSSI(); } + float getLastRSSI() const override { return ((CustomSX1262 *)_radio)->getRSSI() + RSSI_OFFSET; } float getLastSNR() const override { return ((CustomSX1262 *)_radio)->getSNR(); } float packetScore(float snr, int packet_len) override { diff --git a/variants/heltec_v4/platformio.ini b/variants/heltec_v4/platformio.ini index ecfd7889b..5f784a876 100644 --- a/variants/heltec_v4/platformio.ini +++ b/variants/heltec_v4/platformio.ini @@ -31,6 +31,7 @@ build_flags = -D SX126X_DIO3_TCXO_VOLTAGE=1.8 -D SX126X_CURRENT_LIMIT=140 -D SX126X_RX_BOOSTED_GAIN=1 + -D RSSI_OFFSET=-17 ; GC1109 LNA gain compensation (17dB) - subtract to get true RSSI -D PIN_GPS_RX=38 -D PIN_GPS_TX=39 -D PIN_GPS_RESET=42 From 81b8f720dafcb52a62b028c1cda9b2d73f3004f9 Mon Sep 17 00:00:00 2001 From: OverkillFPV Date: Thu, 15 Jan 2026 00:39:00 +1100 Subject: [PATCH 2/2] Update src/helpers/radiolib/CustomSX1262Wrapper.h Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/helpers/radiolib/CustomSX1262Wrapper.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helpers/radiolib/CustomSX1262Wrapper.h b/src/helpers/radiolib/CustomSX1262Wrapper.h index 87377ceb9..c4192e875 100644 --- a/src/helpers/radiolib/CustomSX1262Wrapper.h +++ b/src/helpers/radiolib/CustomSX1262Wrapper.h @@ -3,7 +3,7 @@ #include "CustomSX1262.h" #include "RadioLibWrappers.h" -// RSSI_OFFSET is used to compensate for external LNA gain (e.g.Heltec V4) +// RSSI_OFFSET is used to compensate for external LNA gain (e.g. Heltec V4) // Set to a negative value equal to the LNA gain to get true RSSI values #ifndef RSSI_OFFSET #define RSSI_OFFSET 0