Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
6 years, 5 months ago.
Lowest power consumption achievable w/ sleep manager in mbed OS 5.9
Wondering what is the lowest power consumption achievable with the sleep manager api in deep sleep? I have done some measurements on the NUCLEO F411RE board, just running the code below w/ mbed-os-5.9.4 and I'm seeing a little under 5 mA, both when deep sleep is enabled and locked. Is this expected? I'm measuring the current draw w/ a DMM across JP6. Is it possible to get into the tens or hundreds of micro amps w/ the sleep manager api?
Thanks, Evan
include the mbed library with this snippet
#include "mbed.h" RawSerial pc(USBTX, USBRX); int main() { pc.baud(115200); while (true) { // Deep sleep for 1 second printf("Deep sleep allowed: %i\r\n", sleep_manager_can_deep_sleep()); wait(5); // Lock deep sleep printf("Locking deep sleep\r\n"); DeepSleepLock lock; // Sleep for 1 second printf("Deep sleep allowed: %i\r\n", sleep_manager_can_deep_sleep()); wait(5); } }
1 Answer
6 years, 5 months ago.
Hi Evan,
We see two issues with your example:
- DeepSleepLock::lock() actually prevents deep sleep from being entered and you aren't toggling the lock state
- wait() doesn't actually allow deep sleep to be entered! Please see: https://os.mbed.com/docs/v5.9/reference/wait.html
To enter deep sleep you can use Thread::wait() instead - which takes an argument in msec.
Here is an updated program we tested:
#include "mbed.h" DeepSleepLock lock_out_sleep; int main() { while (true) { // allow deep sleep lock_out_sleep.unlock(); // wait for 10 seconds Thread::wait(10000); // lock out deep sleep lock_out_sleep.lock(); // wait for 10 seconds Thread::wait(10000); } }
Using JP6 we see the current measurement toggle between 6.6mA and 1.9mA.
On Mbed 5.9.4 for deep sleep to be entered you need both MBED_TICKLESS and DEVICE_LPTICKER defined. You can do this through targets.json if building with the CLI or with the Compile Macros for the Online compiler (under the Compile menu).
Please try the example above and let us know what you measure. We don't know if this is the lowest achievable value as we aren't intimately familiar with this device. Next week we'll perform some additional research.
-Ralph, Team Mbed
Thanks Ralph, I replaced the wait w/ Thread::wait and was getting current draw toggling between 4.6 mA and 140 uA. Worked just the same with the way I had the locks set up relying upon RAII of the DeepSleepObject object to lock on construction and release on destruction.
Probably would be good to update the example @ https://os.mbed.com/docs/v5.9/reference/power-management.html to use Thread::wait as well.
Thanks, Evan
posted by 11 Aug 2018