pycom / pycom-micropython-sigfox

A fork of MicroPython with the ESP32 port customized to run on Pycom's IoT multi-network modules.
MIT License
198 stars 167 forks source link

Deepsleep go_to_sleep function does not work with UART(1) #91

Closed affoltep closed 6 years ago

affoltep commented 6 years ago

Please include the following information when submitting a bug report:

The following code prevents the LoPy for changing in deepsleep, issued by the initialization of the UART on port 1:

from machine import UART
from deepsleep import DeepSleep

ds = DeepSleep()

uart = UART(1, 9600)                         # init with given baudrate
uart.init(9600, bits=8, parity=None, stop=1) # init with given parameters
#uart.deinit()
#
ds.go_to_sleep(60)  # go to sleep for 60 seconds

If you uncomment the the uart.deinit() the LoPy crash.

Regards Peter

jmarcelino commented 6 years ago

That's because the DeepSleep class also uses UART 1 to communicate with the DeepSleep shield https://github.com/pycom/pycom-libraries/blob/master/deepsleep/deepsleep.py#L32

If you move the ds = DeepSleep() to be below your UART calls it should work.

affoltep commented 6 years ago

Many Thank jmarcelino. You are completely right. I should have study the source code before writing an issue ;)