Skip to content

Commit 4739ad6

Browse files
committed
Fix GPS +8mA power leak: assert reset pin in stop()
Root cause: MicroNMEALocationProvider::stop() was not asserting the reset pin. On boards like the Heltec T114 where GPS_RESET (pin 38) is the same as PIN_3V3_EN, begin() sets pin 38 HIGH (powering the 3V3 rail) but stop() never set it back LOW. This left the GPS module powered even when disabled, causing +8mA constant draw. Also reverts previous Serial1.end()/PSEL workaround attempts - the UART hang was a symptom of the GPS still being powered and sending NMEA data, not the root cause. Adds gps_active guard on _location->loop() to avoid processing NMEA data when GPS is disabled. Fixes #1628
1 parent 71d8e57 commit 4739ad6

2 files changed

Lines changed: 4 additions & 22 deletions

File tree

src/helpers/sensors/EnvironmentSensorManager.cpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -583,14 +583,6 @@ void EnvironmentSensorManager::initBasicGPS() {
583583
MESH_DEBUG_PRINTLN("No GPS detected");
584584
}
585585
_location->stop();
586-
#ifdef NRF52_PLATFORM
587-
// Redirect UART RX to its own TX pin before ending Serial. When GPS powers
588-
// down its TX drops LOW (break condition), preventing nRF52 UARTE's RXTO
589-
// event from firing and hanging Serial1.end() indefinitely. Looping RX to
590-
// TX guarantees an idle (HIGH) line so RXTO fires promptly.
591-
NRF_UARTE0->PSEL.RXD = NRF_UARTE0->PSEL.TXD;
592-
#endif
593-
Serial1.end(); // Disable UART peripheral to save power (significant on nRF52)
594586
gps_active = false; //Set GPS visibility off until setting is changed
595587
}
596588

@@ -688,14 +680,6 @@ void EnvironmentSensorManager::start_gps() {
688680
return;
689681
#endif
690682

691-
// Re-initialize UART (was closed by stop_gps() to save power)
692-
Serial1.setPins(PIN_GPS_TX, PIN_GPS_RX);
693-
#ifdef GPS_BAUD_RATE
694-
Serial1.begin(GPS_BAUD_RATE);
695-
#else
696-
Serial1.begin(9600);
697-
#endif
698-
699683
_location->begin();
700684
_location->reset();
701685

@@ -713,11 +697,6 @@ void EnvironmentSensorManager::stop_gps() {
713697
#endif
714698

715699
_location->stop();
716-
#ifdef NRF52_PLATFORM
717-
// Redirect UART RX to TX pin — see comment in initBasicGPS()
718-
NRF_UARTE0->PSEL.RXD = NRF_UARTE0->PSEL.TXD;
719-
#endif
720-
Serial1.end(); // Disable UART peripheral to save power (significant on nRF52)
721700

722701
#ifndef PIN_GPS_EN
723702
MESH_DEBUG_PRINTLN("Stop GPS is N/A on this board. Actual GPS state unchanged");

src/helpers/sensors/MicroNMEALocationProvider.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,10 @@ public :
7979
if (_pin_en != -1) {
8080
digitalWrite(_pin_en, !PIN_GPS_EN_ACTIVE);
8181
}
82-
if (_peripher_power) _peripher_power->release();
82+
if (_pin_reset != -1) {
83+
digitalWrite(_pin_reset, GPS_RESET_FORCE);
84+
}
85+
if (_peripher_power) _peripher_power->release();
8386
}
8487

8588
bool isEnabled() override {

0 commit comments

Comments
 (0)