machine.deepsleep does not 'reset'
-
I am encountering a problem using machine.deepsleep() using a LoPy4 on an expansion board 3.0.
The code counts pin interrupts and periodically publishes the total count. The code maximises deepsleep.
The sensor count uses Pin_deepsleep_wakeup and the total time interval between publish uses machine.deepsleep()
The code all works fine until the time config.interval is complete and wake_reason == 1.
After the LoRa_publish is called the final line of code machine.deepsleep(config.interval) does not 'reset' the deepsleep time. On entering deepsleep the LoPy immediately returns 'timer completed' indicating that the time interval passed into deepsleep() method is not the config.interval figure.Any ideas??? Do I have to clear some memory before I call machine.deepsleep() again ???
import machine import utime from machine import Timer import pycom import config #user defined import LoRa_publish #user defined rst=machine.reset_cause() if rst != 3: # if not woken from deepsleep utime.sleep(10) #to allow ctrl+C pycom.nvs_set('counter', 0) machine.pin_deepsleep_wakeup(pins = ['P23'], mode = machine.WAKEUP_ALL_LOW, enable_pull = True) machine.deepsleep(config.interval) else: if (machine.wake_reason()[0])==1: #pin wakeup total_count = pycom.nvs_get('counter') +1 pycom.nvs_set('counter', total_count) print(machine.remaining_sleep_time()) machine.pin_deepsleep_wakeup(pins = ['P23'], mode = machine.WAKEUP_ALL_LOW, enable_pull = True) machine.deepsleep(machine.remaining_sleep_time()) elif (machine.wake_reason()[0])==2: #RTC timer complete print('timer completed') total_count = pycom.nvs_get('counter') LoRa_publish.publish(total_count) #int published to TTN pycom.nvs_set('counter', 0) machine.pin_deepsleep_wakeup(pins = ['P23'], mode = machine.WAKEUP_ALL_LOW, enable_pull = True) machine.deepsleep(config.interval) #this does not restart a new interval
-
Hi,
Have you fix it?
I'm facing the same problem