Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TTGO LORA32 v2.1(1.6) incorrectly wakes from deep sleep #322

Closed
tschundler opened this issue Aug 16, 2020 · 13 comments
Closed

TTGO LORA32 v2.1(1.6) incorrectly wakes from deep sleep #322

tschundler opened this issue Aug 16, 2020 · 13 comments
Assignees
Labels
bug Something isn't working

Comments

@tschundler
Copy link
Contributor

Originally reported by @thomslik in #279 (comment) 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:

ets Jun  8 2016 00:22:57

rst:0x5 (DEEPSLEEP_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 188777542, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:732
load:0x40078000,len:9132
ho 0 tail 12 room 4
load:0x40080400,len:5100
entry 0x40080640
E (448) spiram: SPI RAM enabled but initialization failed. Bailing out.
Emitting reboot packet for serial shell
⸮⸮��H�booted, wake cause 3 (boot count 6), reset_reason=reset
I2C device found at address 0x3c
ssd1306 display found
done
Meshtastic swver=unset, hwver=unset
Setting random seed 1133865350
Total heap: 265572
Free heap: 237968
Total PSRAM: 0
Free PSRAM: 0
NVS: UsedEntries 183, FreeEntries 447, AllEntries 630
Using analog input for battery level
Turning on screen
Read RTC time as 7 (cur millis 120) valid=0
ERROR: No UBLOX GPS found
Hoping that NEMA might work
RadioConfig reset!
Installing AES128 key!
Initial packet id 2051513129, numPacketId 4294967295
Loading saved preferences
Loaded saved preferences version 11
Installing AES128 key!
NODENUM=0x1d698bf8, 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

@tschundler
Copy link
Contributor Author

@tschundler
Copy link
Contributor Author

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.

@LaurentLouf
Copy link

Could this be a brownout ? Do you have any mean to measure the power voltage ?

@tschundler
Copy link
Contributor Author

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

@geeksville
Copy link
Member

geeksville commented Aug 18, 2020 via email

@geeksville geeksville changed the title Boot loop on low battery with TTGO LORA32 v2.1(1.6) TTGO LORA32 v2.1(1.6) incorrectly wakes from deep sleep Aug 22, 2020
@geeksville
Copy link
Member

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

@geeksville geeksville added the bug Something isn't working label Aug 22, 2020
@geeksville geeksville added this to To do in Meshtastic work via automation Aug 22, 2020
@geeksville geeksville moved this from To do to In progress in Meshtastic work Aug 22, 2020
@geeksville
Copy link
Member

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

@thomslik
Copy link

thomslik commented Aug 23, 2020

I added the requested line in configuration.h as shown in my file here: (proper formatting not shown due to copy and paste)
#define LED_PIN 25 // If defined we will blink this LED
#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
#define USE_RF95

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
��␀�␀���␀�␀␀␀�␀�����␀��␀␀␀␀␀␀␀␀␀␀␀␀␀�␀␀␀�␀␀␀␀␀␀␀␀�␀␀␀␀␀␀␀␀�␀���␀��␀��␀␀�␀��␀␀�␀␀␀��␀�␀��␀�␀␀␀␀����␀␀␀␀�␀␀␀���␀���␀�␀���␀��␀␀���␀���␀�␀

@geeksville
Copy link
Member

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)

@geeksville
Copy link
Member

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

@geeksville
Copy link
Member

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?

geeksville added a commit to geeksville/Meshtastic-esp32 that referenced this issue Aug 26, 2020
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?
@thomslik
Copy link

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!

@geeksville
Copy link
Member

yay! thanks for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
No open projects
Development

No branches or pull requests

4 participants