A multifunctional and modular Firmware for Multitech's mDot based on ARM mBed provides a widerange of functionality for several Sensors such as MAX44009, BME280, MPU9250, SI1143 and uBlox. It allows you to quickly build a Sensornode that measures specific data with its sensors and sends it via LoRaWAN.

Dependencies:   mDot_LoRa_Sensornode_Flowmeter_impl mbed-rtos mbed

Usage of sleep and deepsleep

Table of Contents

  1. How it works
  2. How to use

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


All wikipages