EspruinoWifi: Can't connect to wifi after deep sleep #8001
|
Hi all, I'm running an EspruinoWifi to read 3 DHT22 sensors, then sending the values via MQTT. To save power the code should execute, read the values, connect to wifi+mqtt then send the data and go to sleep for 5 minutes. When I'm connected to USB all works great, of course the board will never to into deep sleep. When I'm disconnecting USB and running the wifi off my bench power supply @ 3.3v I can see a current of about 100mA while the code is running, then it drops to zero (near zero I guess, but my power supply is unable to show), the indicator LED goes off. after the 5 minutes have passed I awakens again, but it will stay consuming 50-60mA without connecting to wifi. If I comment out setDeepSleep(1); it will work without USB too, but the consumption is about 5mA while not being busy. Assuming the board is not going to deepSleep, but only idling. Is there anything on the Wifi connection I need to reinitalized after the board wakes from deepSleep? My current code see below. Thanks & Regards, |
Replies: 1 comment 1 reply
|
Hi! Please can you try adding On the STM32 Espruino boards, when you do setDeepSleep it enables the deep sleep mode, which shuts down the main oscillator when no JS code is executing. Unfortunately the downside of that is the UART (which communicates with the WiFi module) also shuts down, so it can't receive data from Wifi properly. So when you have Wifi enabled you need to add |
Hi! Please can you try adding
setDeepSleep(0)as the first line in yourrunfunction?On the STM32 Espruino boards, when you do setDeepSleep it enables the deep sleep mode, which shuts down the main oscillator when no JS code is executing. Unfortunately the downside of that is the UART (which communicates with the WiFi module) also shuts down, so it can't receive data from Wifi properly.
So when you have Wifi enabled you need to add
setDeepSleep(0)and then as you're doing, when you disconnect you can dosetDeepSleep(1);. It might be worth delaying enabling it at the end though - sosetTimeout(() => setDeepSleep(1), 1000)just to ensure the wifi has had a chance to power down properly.