Question re: Configuration - Power - Shutdown on battery delay

I’m not sure about what this setting is doing. My understanding is that a nonzero value in this field specifies the number of seconds the device will remain on after losing external power. The device will shut down after the specified number of seconds have elapsed.

I accidentally tried setting this value to 3600 (one hour) on a Heltec V3 that did not have a battery but that was plugged into external power continuously. The device shut down after one hour. The behavior is consistent, and if I set the value to zero the device stays on as long as it has external power.

Is this just a quirk because the device had no battery, or am I misunderstanding the function, or is this a bug?

Thanks

May I confirm: was the external power through USB, or through the other connector? and what firmware version are you running?

Heltec V3, firmware 2.3.3.818fa7
Power is via USB. Stock setup with no other devices attached to the board

1 Like

Thanks.

From a naive reading of the code:

it seems to me like if there’s USB plugged in, it shouldn’t even be looking at that config option. So perhaps there is a bug in the code that detects presence of USB.

If you enable debug logging, there should be a line in the log that looks like:

Battery: usbPower=X, isCharging=Y, batMv=Z, batPct=X

it would be interesting to see what it says :slight_smile:

OK, I noticed that the USB detection code had a lot of references to “NRF” in it. So, I ran a comparison of a nRF52840 and a ESP32 device:

LilyGo T-Beam (nRF52840)

DEBUG | 01:29:22 45549 [Power] Battery: usbPower=1, isCharging=0, batMv=0, batPct=0

Heltec Wireless Tracker (ESP32)

DEBUG | 01:28:08 87 [Power] Battery: usbPower=0, isCharging=0, batMv=3701, batPct=47

Surprise, only the NRF-based device correctly determines USB is connected. So, since your Heltec V3 device is ESP32-based, it looks like the current code thinks it has no USB connected, and so it will shut-down after that battery delay option has expired.

Looks like a bug to me :slight_smile:

1 Like

Filed a bug: [Bug]: ESP32 boards shutdown after on_battery_shutdown_after_secs even when connected to USB · Issue #3743 · meshtastic/firmware · GitHub

1 Like

Ah, makes sense. I actually use this feature with a T-beam and it works as far as I can tell. I only happened to try it with the Heltec because I was copying settings.

1 Like

It depends on having a good reading for power, have you adjusted the adc?

1 Like

I just changed adc from 4.9 to 5.64 on the heltec-wireless-tracker and USB is now correctly detected. Thanks Garth :slight_smile:

Proposed a documentation update: shutdown after losing power - check power detection status note by fifieldt · Pull Request #1226 · meshtastic/meshtastic · GitHub

(testing github/discord bot changes via this comment - pls ignore :wink: )

1 Like