From efc05eaffa46f9a15eb1d13ebe6505b9a7dfffdd Mon Sep 17 00:00:00 2001 From: ktobias-dev <346914092+ktobias-dev@users.noreply.github.com> Date: Fri, 23 Oct 2026 09:39:27 -0500 Subject: [PATCH] T-Echo Card: switch GPS LNA with GPS power, enable L76K config - GPS_RF_EN (P0.29) drives the GNSS antenna LNA. It was set HIGH in initVariant() and never released, so the LNA stayed powered while GPS was off. It is now a RefCountedDigitalPin on TechoCardBoard, passed to NmeaGpsDriver as peripheral power: claimed when the driver starts the GPS, released when it stops it (same pattern as heltec_tracker). - Rename PIN_GPS_STANDBY to PIN_GPS_RF_EN to match LilyGo's pin name. - Define GPS_L76K so the driver applies $PCAS04,7 (GPS+BDS+GLONASS) after each reset. LilyGo's reference firmware (T-Echo-Card examples/original_test) turns the GPS on/off by driving GPS_WAKE_UP and GPS_RF_EN together. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Rc3a98a3t3ZankTSKCxwjP --- variants/lilygo_techo_card/TechoCardBoard.cpp | 1 + variants/lilygo_techo_card/TechoCardBoard.h | 5 ++++- variants/lilygo_techo_card/target.cpp | 3 ++- variants/lilygo_techo_card/variant.cpp | 6 +++--- variants/lilygo_techo_card/variant.h | 9 ++++++--- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/variants/lilygo_techo_card/TechoCardBoard.cpp b/variants/lilygo_techo_card/TechoCardBoard.cpp index 8a3a54b16..7b6bd94ce 100644 --- a/variants/lilygo_techo_card/TechoCardBoard.cpp +++ b/variants/lilygo_techo_card/TechoCardBoard.cpp @@ -20,6 +20,7 @@ Adafruit_NeoPixel *Led[] = void TechoCardBoard::begin() { NRF52BoardDCDC::begin(); + gps_rf_power.begin(); // LNA stays off until the GPS is started Wire.begin(); for (uint8_t i = 0; i < sizeof(Led) / sizeof(Led[0]); i++) diff --git a/variants/lilygo_techo_card/TechoCardBoard.h b/variants/lilygo_techo_card/TechoCardBoard.h index a2ee3ea1e..a9d1e548b 100644 --- a/variants/lilygo_techo_card/TechoCardBoard.h +++ b/variants/lilygo_techo_card/TechoCardBoard.h @@ -3,6 +3,7 @@ #include #include #include +#include #include // built-ins @@ -17,7 +18,9 @@ class TechoCardBoard : public NRF52BoardDCDC { bool _torchStatus = false; public: - TechoCardBoard() : NRF52Board("TECHO_OTA") {} + RefCountedDigitalPin gps_rf_power; // GPS antenna LNA, claimed while the GPS is running + + TechoCardBoard() : NRF52Board("TECHO_OTA"), gps_rf_power(PIN_GPS_RF_EN, HIGH) {} void begin(); uint16_t getBattMilliVolts() override; void onBeforeTransmit(void) override; diff --git a/variants/lilygo_techo_card/target.cpp b/variants/lilygo_techo_card/target.cpp index b3375dbbe..9be5d6709 100644 --- a/variants/lilygo_techo_card/target.cpp +++ b/variants/lilygo_techo_card/target.cpp @@ -13,7 +13,8 @@ VolatileRTCClock fallback_clock; AutoDiscoverRTCClock rtc_clock(fallback_clock); #ifdef ENV_INCLUDE_GPS -NmeaGpsDriver gps_driver(Serial1); +// GPS_RF_EN (antenna LNA) is claimed while the GPS runs and released when it stops +NmeaGpsDriver gps_driver(Serial1, PIN_GPS_TX, PIN_GPS_RX, GPS_RESET, GPS_EN, &board.gps_rf_power); MicroNMEALocationProvider nmea(gps_driver, &rtc_clock); EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea); #else diff --git a/variants/lilygo_techo_card/variant.cpp b/variants/lilygo_techo_card/variant.cpp index 0b00791a1..547ab0921 100644 --- a/variants/lilygo_techo_card/variant.cpp +++ b/variants/lilygo_techo_card/variant.cpp @@ -34,9 +34,9 @@ void initVariant() { pinMode(SPEAKER_EN_2, OUTPUT); digitalWrite(SPEAKER_EN_2, LOW); - // gps - pinMode(PIN_GPS_STANDBY, OUTPUT); - digitalWrite(PIN_GPS_STANDBY, HIGH); + // gps - PIN_GPS_RF_EN (LNA) is switched by TechoCardBoard::gps_rf_power + pinMode(PIN_GPS_RF_EN, OUTPUT); + digitalWrite(PIN_GPS_RF_EN, LOW); pinMode(PIN_GPS_EN, OUTPUT); digitalWrite(PIN_GPS_EN, HIGH); pinMode(PIN_GPS_RESET, OUTPUT); diff --git a/variants/lilygo_techo_card/variant.h b/variants/lilygo_techo_card/variant.h index 699453e0e..84aab348d 100644 --- a/variants/lilygo_techo_card/variant.h +++ b/variants/lilygo_techo_card/variant.h @@ -113,15 +113,18 @@ //////////////////////////////////////////////////////////////////////////////// // GPS -// NOTE: these pins are defined differently to how lilygo does them but they -// seem to work properly for how EnvironmentSensorManager operates. +// NOTE: these pins are named differently to how lilygo does them but they +// work properly for how EnvironmentSensorManager operates. LilyGo's own +// examples switch the GPS on/off by driving GPS_WAKE_UP and GPS_RF_EN together. // TODO: MAYBE? migrate to board based sensor manager / add GPS_WAKE_UP to ESM +#define GPS_L76K // Quectel L76K: applies GPS+BDS+GLONASS config on start + #define PIN_GPS_RX (21) // GPS_UART_RX in lilygo pin defs #define PIN_GPS_TX (19) // GPS_UART_TX in lilygo pin defs #define PIN_GPS_EN (25) // GPS_WAKE_UP in lilygo pin defs #define PIN_GPS_RESET (47) // GPS_EN in lilygo pin defs -#define PIN_GPS_STANDBY (29) // GPS_RF_EN in lilygo pin defs +#define PIN_GPS_RF_EN (29) // GPS_RF_EN in lilygo pin defs (antenna LNA), follows GPS on/off #define PIN_GPS_PPS (23) // GPS_1PPS in lilygo pin defs // buzzer - enabled in platformio.ini so it can be easily turned off if not wanted.