Closed tschundler closed 4 years ago
reason 3 is apparently ESP_SLEEP_WAKEUP_EXT1
- https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/sleep_modes.html#external-wakeup-ext1
disabling BUTTON_PIN in configuration.h avoids the boot loop, but then of course no working button. I tried -DBUTTON_NEED_PULLUP, but it still bootloops.
Could this be a brownout ? Do you have any mean to measure the power voltage ?
The detected voltage is deliberately wrong on the example above to force it to sleep. It's powered by USB with no battery for testing.
It only seems to occur when trying to sleep due to low battery. And the problem is clearly related to trying to use the RTC interrupts to wake up on button press, since without code related to button pins, it does go to sleep and stays asleep.
While I have had past issues with brownouts in other projects, with the ESP 32 it has reliably set the reset reason to RTCWDT_BROWN_OUT_RESET
Oh I know the problem! We are probably not setting the wake pin correctly for lora32 - because the internal pull-up resistor is not turned on for that board?!
(Sent from a phone - please ignore typos)
On Sun, Aug 16, 2020, 13:50 tschundler notifications@github.com wrote:
The detected voltage is deliberately wrong on the example above to force it to sleep. It's powered by USB with no battery for testing.
It only seems to occur when trying to sleep due to low battery. And the problem is clearly related to trying to use the RTC interrupts to wake up on button press, since without code related to button pins, it does go to sleep and stays asleep.
While I have had past issues with brownouts in other projects, with the ESP 32 it has reliably set the reset reason to RTCWDT_BROWN_OUT_RESET
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/meshtastic/Meshtastic-device/issues/322#issuecomment-674576163, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABXB2I3CLFQX2YOGS7YJIDSBBA73ANCNFSM4QA6TNPA .
I think I know what will fix this... @tschundler would you mind building and testing a version where you add BUTTON_NEED_PULLUP to configuration.h? (I don't have one of these boards)
#elif defined(TLORA_V2_1_16)
...
#define BUTTON_PIN \
12 // If defined, this will be used for user button presses, if your board doesn't have a physical switch, you can wire one
// between this pin and ground
#define BUTTON_NEED_PULLUP
This issue has been mentioned on Meshtastic. There might be relevant details there:
https://meshtastic.discourse.group/t/lilygo-ttgo-t3-lora32-868mhz-v2-1-6-esp32/1084/8
I added the requested line in configuration.h as shown in my file here: (proper formatting not shown due to copy and paste)
12 // If defined, this will be used for user button presses, if your board doesn't have a physical switch, you can wire one
// between this pin and ground
I then modified power.cpp to simulate the low voltage condition. The unit still goes into a boot loop as before, with the following log file: ��␀␂H␁booted, wake cause 0 (boot count 1), reset_reason=reset I2C device found at address 0x3c ssd1306 display found done Meshtastic swver=unset, hwver=unset Setting random seed 1006200448 Total heap: 265664 Free heap: 238428 Total PSRAM: 0 Free PSRAM: 0 NVS: UsedEntries 91, FreeEntries 539, AllEntries 630 Using analog input for battery level Turning on screen Read RTC time as 0 (cur millis 92) valid=0 ERROR: No UBLOX GPS found Hoping that NEMA might work RadioConfig reset! Installing AES128 key! Initial packet id 1389939266, numPacketId 4294967295 Loading saved preferences Loaded saved preferences version 11 Installing AES128 key! NODENUM=0x91828afc, dbsize=1 Starting meshradio init... Set radio: name=Default, config=3, ch=6, power=17 RF95 init result 0 [D][esp32-hal-cpu.c:189] setCpuFrequencyMhz(): PLL: 320 / 4 = 80 Mhz, APB: 80000000 Hz Battery 3mV 0% Trigger powerFSM 10 Transition powerFSM transition=LowBat, from=BOOT to=SDS Entering deep sleep for 31536000 seconds Turning off screen Writing preferences ��␀�␀���␀�␀␀␀�␀�����␀��␀␀␀␀␀␀␀␀␀␀␀␀␀�␀␀␀�␀␀␀␀␀␀␀␀�␀␀␀␀␀␀␀␀�␀���␀��␀��␀␀�␀��␀␀�␀␀␀��␀�␀��␀�␀␀␀␀����␀␀␀␀�␀␀␀���␀���␀�␀���␀��␀␀���␀���␀�␀�����␀␀����␀��␀����␀�␀����␀�␀␀�␀␀␀�������␀��␀�␀␀␀␀��␀␀�␀␀␀␀␀�␀�␀��␀���␀␀����␀␀��␀��␀��␀������␀␀�␀␀��␀��␀��␀␀����␀␀��␀��␀�␀����␀�␀��␀␀�␀�␀����␀��␀␀��␀���␀��␀��␀��␀�␀�␀␀␀�␀␀␀␀␀␀��␀��␀��␀���␀␀�␀␀␀␀␀�␀␀␀�␀��␀���␀␀�����␀��␀�␀␀␀␀���␀���␀���␀␀�␀�␀�␀���������␀␀�␀␀�␀��␀�␀␀␀␀�␀␀␀␀␀�␀�␀����␀␀�␀␀�␀��␀�␀␀␀␀�␀␀␀␀␀�␀␀␀����␀␀�␀␀�␀��␀�␀␀␀␀�␀␀␀␀␀�␀�␀��␀�␀␀���␀␀�␀␀�␀��␀�␀␀␀␀�␀␀␀␀␀�␀␀��␀␀����␀␀�␀␀�␀��␀�␀␀␀␀�␀␀␀␀␀�␀���␀����␀␀�␀␀�␀��␀�␀␀␀␀�␀␀␀␀��␀␀�␀�������␀␀���␀�␀�␀␀␀��␀␀��␀�␀�␀␀␀�␀�␀������␀�����␀␀␀␀��␀��␀��␀�␀␀␀␀��␀␀�␀␀������␀�␀␀�␀�␀␀␀␀��␀␀␀␀�␀␀�␀␀�␀␀␀␀�␀␀␀␀␀�␀␀����␀�␀��␀�␀␀�␀��␀␀�␀␀������␀�␀␀�␀�␀␀␀␀��␀␀␀␀�␀␀�␀␀�␀␀␀␀�␀␀�␀�␀�␀␀����␀�␀��␀�␀��␀�␀␀␀␀␀��␀␀�␀␀������␀�␀␀�␀�␀␀␀␀�␀�␀␀␀␀␀��␀␀␀␀␀␀␀␀␀␀�␀␀����␀�␀��␀�␀�␀␀�␀␀�␀␀␀␀␀��␀␀�␀␀�����␀␀␀␀␀␀␀���␀��␀��␀��␀␀�␀␀␀␀␀␀␀␀␀�����������␀␀␀�␀��␀␀�␀␀������␀�␀␀�␀�␀␀␀␀�␀�␀␀␀␀␀␀␀␀␀␀�␀␀␀␀␀␀�␀␀����␀�␀��␀�␀���␀�␀␀␀␀␀␀��␀␀�␀��␀�␀��␀��␀␀��␀�␀␀␀␀␀�␀�␀␀␀␀␀␀␀␀␀␀�␀␀�␀␀␀��␀␀�␀��␀�␀␀␀�␀␀�␀␀�␀␀␀�␀�␀␀␀�␀�␀��␀��␀␀��␀�����␀�␀␀␀�␀��␀���␀␀�␀␀␀␀���␀���␀�␀␀��␀�␀���␀�␀␀�␀����␀�␀␀�␀␀␀␀�����␀��␀␀�␀��␀���␀��␀���␀���␀�␀���␀��␀���␀�␀���␀�����␀��␀␀␀␀��␀��␀��␀����␀�␀␀�␀�␀␀␀␀␀��␀��␀��␀���␀��␀���␀�␀␀�������␀��␀�␀��␀␀�␀�Emitting reboot packet for serial shell ��␀␂H␁booted, wake cause 3 (boot count 2), reset_reason=reset I2C device found at address 0x3c ssd1306 display found done Meshtastic swver=unset, hwver=unset Setting random seed 3664589159 Total heap: 265664 Free heap: 238428 Total PSRAM: 0 Free PSRAM: 0 NVS: UsedEntries 91, FreeEntries 539, AllEntries 630 Using analog input for battery level Turning on screen Read RTC time as 1 (cur millis 92) valid=0 ERROR: No UBLOX GPS found Hoping that NEMA might work RadioConfig reset! Installing AES128 key! Initial packet id 1883797361, numPacketId 4294967295 Loading saved preferences Loaded saved preferences version 11 Installing AES128 key! NODENUM=0x91828afc, dbsize=1 Starting meshradio init... Set radio: name=Default, config=3, ch=6, power=17 RF95 init result 0 [D][esp32-hal-cpu.c:189] setCpuFrequencyMhz(): PLL: 320 / 4 = 80 Mhz, APB: 80000000 Hz Battery 3mV 0% Trigger powerFSM 10 Transition powerFSM transition=LowBat, from=BOOT to=SDS Entering deep sleep for 31536000 seconds Turning off screen Writing preferences ��␀�␀���␀�␀␀␀�␀�����␀��␀␀␀␀␀␀␀␀␀␀␀␀␀�␀␀␀�␀␀␀␀␀␀␀␀�␀␀␀␀␀␀␀␀�␀���␀��␀��␀␀�␀��␀␀�␀␀␀��␀�␀��␀�␀␀␀␀����␀␀␀␀�␀␀␀���␀���␀�␀���␀��␀␀���␀���␀�␀�����␀␀����␀��␀����␀�␀����␀�␀␀�␀␀␀�������␀��␀�␀␀␀␀��␀␀�␀␀␀␀␀�␀�␀��␀���␀␀����␀␀��␀��␀��␀������␀␀�␀␀��␀��␀��␀␀����␀␀��␀��␀�␀����␀�␀��␀␀�␀�␀����␀��␀␀��␀���␀��␀��␀��␀�␀�␀␀␀�␀␀␀␀␀␀��␀��␀��␀���␀␀�␀␀␀␀␀�␀␀␀�␀��␀���␀␀�����␀��␀�␀␀␀␀���␀���␀���␀␀�␀�␀�␀���������␀␀�␀␀�␀��␀�␀␀␀␀�␀␀␀␀␀�␀�␀����␀␀�␀␀�␀��␀�␀␀␀␀�␀␀␀␀␀�␀␀␀����␀␀�␀␀�␀��␀�␀␀␀␀�␀␀␀␀␀�␀�␀��␀�␀␀���␀␀�␀␀�␀��␀�␀␀␀␀�␀␀␀␀␀�␀␀��␀␀����␀␀�␀␀�␀��␀�␀␀␀␀�␀␀␀␀␀�␀���␀����␀␀�␀␀�␀��␀�␀␀␀␀�␀␀␀␀��␀␀�␀�������␀␀���␀�␀�␀␀␀��␀␀��␀�␀�␀␀␀�␀�␀������␀�����␀␀␀␀��␀��␀��␀�␀␀␀␀��␀␀�␀␀������␀�␀␀�␀�␀␀␀␀��␀␀␀␀�␀␀�␀␀�␀␀␀␀�␀␀␀␀␀�␀␀����␀�␀��␀�␀␀�␀��␀␀�␀␀������␀�␀␀�␀�␀␀␀␀��␀␀␀␀�␀␀�␀␀�␀␀␀␀�␀␀�␀�␀�␀␀����␀�␀��␀�␀��␀�␀␀␀␀␀��␀␀�␀␀������␀�␀␀�␀�␀␀␀␀�␀�␀␀␀␀␀��␀␀␀␀␀␀␀␀␀␀�␀␀����␀�␀��␀�␀�␀␀�␀␀�␀␀␀␀␀��␀␀�␀␀�����␀␀␀␀␀␀␀���␀��␀��␀��␀␀�␀␀␀␀␀␀␀␀␀�����������␀␀␀�␀��␀␀�␀␀������␀�␀␀�␀�␀␀␀␀�␀�␀␀␀␀␀␀␀␀␀␀�␀␀␀␀␀␀�␀␀����␀�␀��␀�␀���␀�␀␀␀␀␀␀��␀␀�␀��␀�␀��␀��␀␀��␀�␀␀␀␀␀�␀�␀␀␀␀␀␀␀␀␀␀�␀␀�␀␀␀��␀␀�␀��␀�␀␀␀�␀␀�␀␀�␀␀␀�␀�␀␀␀�␀�␀��␀��␀␀��␀�����␀�␀␀␀�␀��␀���␀␀�␀␀␀␀���␀���␀�␀␀��␀�␀���␀�␀␀�␀����␀�␀␀�␀␀␀␀�����␀��␀␀�␀��␀���␀��␀���␀���␀�␀���␀��␀���␀�␀���␀�����␀��␀␀␀␀��␀��␀��␀����␀�␀␀�␀�␀␀␀␀␀��␀��␀��␀���␀��␀���␀�␀␀�������␀��␀�␀��␀␀�␀�Emitting reboot packet for serial shell ��␀␂H␁booted, wake cause 3 (boot count 3), reset_reason=reset I2C device found at address 0x3c ssd1306 display found done Meshtastic swver=unset, hwver=unset Setting random seed 1986187969 Total heap: 265664 Free heap: 238428 Total PSRAM: 0 Free PSRAM: 0 NVS: UsedEntries 91, FreeEntries 539, AllEntries 630 Using analog input for battery level Turning on screen Read RTC time as 2 (cur millis 92) valid=0 ERROR: No UBLOX GPS found Hoping that NEMA might work RadioConfig reset! Installing AES128 key! Initial packet id 1223135943, numPacketId 4294967295 Loading saved preferences Loaded saved preferences version 11 Installing AES128 key! NODENUM=0x91828afc, dbsize=1 Starting meshradio init... Set radio: name=Default, config=3, ch=6, power=17 RF95 init result 0 [D][esp32-hal-cpu.c:189] setCpuFrequencyMhz(): PLL: 320 / 4 = 80 Mhz, APB: 80000000 Hz Trigger powerFSM 10 Transition powerFSM transition=LowBat, from=BOOT to=SDS Entering deep sleep for 31536000 seconds Turning off screen Writing preferences ��␀�␀���␀�␀␀␀�␀�����␀��␀␀␀␀␀␀␀␀␀␀␀␀␀�␀␀␀�␀␀␀␀␀␀␀␀�␀␀␀␀␀␀␀␀�␀���␀��␀��␀␀�␀��␀␀�␀␀␀��␀�␀��␀�␀␀␀␀����␀␀␀␀�␀␀␀���␀���␀�␀���␀��␀␀���␀���␀�␀
ok thanks - I need to read the datasheet today, I dimly remember some extra call is needed to leave that pullup powered during sleep (all of the other boards have an external pullup, which is why they don't show this problem)
This issue has been mentioned on Meshtastic. There might be relevant details there:
https://meshtastic.discourse.group/t/ttgo-lora-v2-board-specific-issues/1138/4
oh - I think I found the problem (probably)! we were isolating gpio12 (which isn't used on other boards) to save power during sleep. gpio12 is the button for this board. @thomslik would you mind pulling this commit and seeing if it works better?
I think that's it! Loaded your version and simulated low battery with modified power.cpp. It goes to sleep as soon as it boots up. Pressing the added button (pin 12 to ground) immediately wakes it for a second before it returns to sleep. No more boot loop! Good job. Thanks!
yay! thanks for your help!
Originally reported by @thomslik in https://github.com/meshtastic/Meshtastic-device/issues/279#issuecomment-673534078 related to misreading the battery level. Even with correct battery measurement, when the battery gets low, the device goes into a boot loop.
To simulate with USB connected, I reverted 3de1607, and here is the output: