You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my loop, when I'd like to go into deep sleep mode I do
LowPower.deepSleep(sleepMs);
This works wonderfully, and sleeps for sleepMs when the above "serialInitialized" returns 'true'.
The LowPower.deepSleep() call returns in just one or two milliseconds, regardless of sleepMs, when the above "serialInitialized" returns 'false'.
The core problem turns out to be the fact that, when using Arduino's USB Support: CDC (generic 'Serial' supersede U(S)ART)
...IF AND ONLY IF the USB is unplugged at the time of setup(). And if indeed the USB is unplugged at the time of setup(), (as helpfully indicated by serialInitialized being false) deepSleep() will fail.
If the USB is plugged in during setup(), OR if USB Support is set to 'None', serialInitialized returns 'true' and deepSleep() works fine.
The workaround in my device (which happens to have a screen) is to use that serialInitialized flag to warn the user to rebuild the sketch without USB support, however it would be best if deepSleep() were enhanced so that it does not immediately wake if USB support is configured but unplugged.
Thank you for a great library and for your consideration.
The text was updated successfully, but these errors were encountered:
My sketch is using Arduino IDE 2.3.3 with STM32duino version 2.8.1 with a Blues Cygnet (STM32L433) mcu which has an LSE.
As many do, I always initialize my sketch with:
I then initialize the low power package with
In my loop, when I'd like to go into deep sleep mode I do
This works wonderfully, and sleeps for sleepMs when the above "serialInitialized" returns 'true'.
The LowPower.deepSleep() call returns in just one or two milliseconds, regardless of sleepMs, when the above "serialInitialized" returns 'false'.
The core problem turns out to be the fact that, when using Arduino's
USB Support: CDC (generic 'Serial' supersede U(S)ART)
...IF AND ONLY IF the USB is unplugged at the time of setup(). And if indeed the USB is unplugged at the time of setup(), (as helpfully indicated by serialInitialized being false) deepSleep() will fail.
If the USB is plugged in during setup(), OR if USB Support is set to 'None', serialInitialized returns 'true' and deepSleep() works fine.
The workaround in my device (which happens to have a screen) is to use that serialInitialized flag to warn the user to rebuild the sketch without USB support, however it would be best if deepSleep() were enhanced so that it does not immediately wake if USB support is configured but unplugged.
Thank you for a great library and for your consideration.
The text was updated successfully, but these errors were encountered: