meshtastic / firmware

Meshtastic device firmware
https://meshtastic.org
GNU General Public License v3.0
3k stars 719 forks source link

[Bug]: Heltec boards shutdown after on_battery_shutdown_after_secs even when connected to USB #3743

Closed fifieldt closed 2 months ago

fifieldt commented 2 months ago

Category

Other

Hardware

Heltec Wireless Tracker

Firmware Version

2.3.4.ea61808

Description

As reported by chrisj, Heltec boards shut down after "Shutdown on battery delay" seconds, even when connected to USB. This is confirmed to affect Heltec V3 and Heltec Wireless Tracker. This is because PowerStatus->getHasUSB returns the incorrect value for these boards.

PowerStatus->getHasUSB is used in various places to determine whether a device is connected to external power. For example, in src/PowerFSMThread.h, we use getHasUSB to determine whether we should check to shut down a device after config.power.on_battery_shutdown_after_secs.

getHasUSB currently returns 0 (i.e. USB not connected) for Heltec-based devices, even when USB is connected.

Relevant log output

# Heltec Wireless Tracker - USB connected
DEBUG | 01:28:08 87 [Power] Battery: usbPower=0, isCharging=0, batMv=3701, batPct=47

# LilyGo T-Beam - USB connected
DEBUG | 01:29:22 45549 [Power] Battery: usbPower=1, isCharging=0, batMv=0, batPct=0
geeksville commented 2 months ago

This issue has been mentioned on Meshtastic. There might be relevant details there:

https://meshtastic.discourse.group/t/question-re-configuration-power-shutdown-on-battery-delay/12241/6

garthvh commented 2 months ago

For the heltec you will need to adjust your adc value until is is showing powered properly, the tbeam which has a better power management chip is detecting usb power.

fifieldt commented 2 months ago

Thanks Garth. I confirm changing the adc value on heltec-wireless-tracker fixes the hasUSB issue.

Perhaps this is just a documentation fix only? Adding a warning to https://meshtastic.org/docs/configuration/radio/power/#shutdown-after-losing-power to check that USB is correctly detected, and alter ADC value if not?