Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mDot_LoRa_Sensornode_Flowmeter_impl mbed-rtos mbed
Usage of sleep and deepsleep
Generally you are free to choose which one you would like to use. However deepsleep() saves even more Energy than sleep() because it also turns off the peripherals clocks.
How it works¶
Everytime no measurement Task is running because of a delay the idle_task will be called by the rtos. The default idle hook calls a function that will be called by the idle task. In our case sleep() or deepsleep(). This means if you just want to send data every minute or hour the measurment Tasks only run for a short amount of time. The rest of the time the idle task and therefore its idle hook function (sleep or deepsleep) runs and saves energy.
How to use¶
Just open rtos_idle.c in your mbed_rtos Library and adapt the default_idle_hook(void) function:
usage of sleep during idle task
static void default_idle_hook(void) { /* Sleep: ideally, we should put the chip to sleep. Unfortunately, this usually requires disconnecting the interface chip (debugger). This can be done, but it would break the local file system. */ sleep(); }
And if you want to use deepsleep:
usage of sleep during idle task
static void default_idle_hook(void) { /* Sleep: ideally, we should put the chip to sleep. Unfortunately, this usually requires disconnecting the interface chip (debugger). This can be done, but it would break the local file system. */ deepsleep(); }
More theory about the topic of idle tasks can be found here :http://www.freertos.org/RTOS-idle-task.html