Power Management

For any battery operated device, power management is an important issue.
The Sodaq ONE and Autonomo are built up around the ATSAMD21 microcontroller with an ARM Cortex M0+ core, this core has multiple ways to save power.

On this page I'll try to give an overview of the different modes that the Sodaq nodes can operate in and what the power consumption in these modes is.

Run Forrest, run

The standard Arduino way of programming uses the loop() function to execute the code over and over again.

The simplest program one could write is this:

void setup() {
}

void loop() {
  delay(200);
}

 

This program just waits forever, running the loop() function over and over again. This means the processor keeps executing code at the specified speed the processor is running on. On the standard Autonomo, this consumes 9 mA. With the standard 1200 mAh battery from the power pack, this will drain the battery in 1200/9 = 133 hours.
Besides from being a fairly useless program, this does not provide a very good battery life time.

Deep Sleep

The ARM Cortex M0+ processor has different sleep modes. In deep sleep mode, interrupts are still active but all other peripherals have been shut down as much as possible.

Putting the device in deep sleep mode involves two steps. First the processor needs to be told that it should enter deep sleep mode when requested and when the program is ready, it must tell the processor to wait for interrupts using the __WFI() function.

void initSleep()
{
    // Set the sleep mode
    SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
}

void setup() {
  initSleep();
}

void loop() {
  __WFI();

  delay(200);
}

 

The initSleep() function requests the processor to enter deep sleep mode when waiting for interrupts and in loop() the processor will be halted and it waits for an interrupt to occur.

SInce no interrupt sources have been programmed, the processor will just wait forever. Again useless in this simple form but now it is possible to measure the current: 43 μA. Now the battery will last for: 1200/0.043 = 27906 hours or 3 years and 2 month.

Apart from measuring the current, this program has no use. When a temperature/humidity sensor (AM2320) is added to the system the current in sleep mode increases to 50 μA, resulting in 2 years and 8 month of battery life time.
I selected the AM2320 since this sensor has a very low standby current.