Re: ESP8266 NodeMCU deep sleep working ramdomly
Posted: Fri Jan 08, 2021 8:23 am
Appreciate your reply.
You are right and I know why I did so. In the begining I was using this code:
but when I started troubleshooting I commented out all lines except machine.deepsleep() so now it looks like this:
I should have corrected it right before posting to the forum, sorry.
You are right and I know why I did so. In the begining I was using this code:
Code: Select all
def deep_sleep(msecs): # https://randomnerdtutorials.com/micropython-esp8266-deep-sleep-wake-up-sources/
if debug: write2debug('Inside deep_sleep') # you need to connect GPIO16 (D0) to the RST pin so that the ESP8266 can wake itself up.
rtc = machine.RTC() # configure RTC.ALARM0 to be able to wake the device
rtc.irq(trigger=rtc.ALARM0, wake=machine.DEEPSLEEP)
rtc.alarm(rtc.ALARM0, msecs) # set RTC.ALARM0 to fire after X milliseconds (waking the device)
# put the device to sleep
if debug: write2debug('Going to sleep...\n-------------------------------\n')
machine.deepsleep()
but when I started troubleshooting I commented out all lines except machine.deepsleep() so now it looks like this:
Code: Select all
def deep_sleep(msecs): # https://randomnerdtutorials.com/micropython-esp8266-deep-sleep-wake-up-sources/
'''if debug: write2debug('Inside deep_sleep') # you need to connect GPIO16 (D0) to the RST pin so that the ESP8266 can wake itself up.
rtc = machine.RTC() # configure RTC.ALARM0 to be able to wake the device
rtc.irq(trigger=rtc.ALARM0, wake=machine.DEEPSLEEP)
rtc.alarm(rtc.ALARM0, msecs) # set RTC.ALARM0 to fire after X milliseconds (waking the device)
'''
# put the device to sleep
if debug: write2debug('Going to sleep...\n-------------------------------\n')
machine.deepsleep(msecs)
I should have corrected it right before posting to the forum, sorry.