01/19/2018
Average power usage for an application will depend on what peripherals and duty cycle are chosen, etc but we can get some idea of what ultra-low power means for users of the CMWX1ZZABZ by measuring the power required to perform a simple task, in this case blinking an led, going into stop mode for 5 seconds, then repeat.
Here is the sketch:
/* LED Blink, for Grasshopper
This example code is in the public domain.
*/
#include <STM32L0.h>
#define myLed 13 // red led
#define myADC A1
float VDDA, Temperature;
uint32_t UID[3] = {0, 0, 0};
uint16_t adc = 0;
void setup()
{
Serial.begin(38400);
delay(2000);
Serial.println("Serial enabled!");
pinMode(myLed, OUTPUT);
digitalWrite(myLed, LOW); // start with leds off, since active HIGH
pinMode(myADC, INPUT);
analogReadResolution(12);
STM32L0.getUID(UID);
Serial.print("STM32L0 MCU UID = 0x"); Serial.print(UID[0], HEX); Serial.print(UID[1], HEX); Serial.println(UID[2], HEX);
}
void loop()
{
digitalWrite(myLed, HIGH); // toggle red led on
delay(100); // wait 100 millisecond
digitalWrite(myLed, LOW); // toggle red led off
delay(1000); // wait 1000 milliseconds
VDDA = STM32L0.getVDDA();
Temperature = STM32L0.getTemperature();
adc = analogRead(myADC);
Serial.print("ADC = "); Serial.println(adc);
Serial.print("VDDA = "); Serial.println(VDDA, 2);
Serial.print("STM32L0 MCU Temperature = "); Serial.println(Temperature, 2);
STM32L0.stop(5000);
}
I am also reading an ADC and sending out some serial, but these are typical tasks. How much power is used?
You can see that the average power usage during the active part of the sketch is almost proportional to the clock speed as expected; the proportionality is better when the constant average power (~22 uA) to blink the led is factored out. This means for most applications you want to run at 4.2 MHz clock speed if you can to minimize power usage. In this case, it takes 62 uA to blink the led for 100 ms and read the ADC every five seconds at 4.2 MHz; USB serial is disabled at 4.2 and 16 MHz.
In stop mode, all state information (SRAM) is retained and after the time out (or upon interrupt when using STM32L0.stop();) the program picks up where it left off. Best practice is to have all sections of the main loop depend on interrupts and leave the MCU in stop mode otherwise. When the Grasshopper is in stop mode, my multimeter reads 2.1 uA. Now that is ultra-low power!
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.
Hello,
I have try your sketch using the grasshopper and I get 289 uA in the stop mode (mesured with the Current Ranger and a 3.3V power supply). While reading values, I could quickly see that the current is going to approx 2380 uA.
I have try to change the CPU Speed to 4.2 MHz, but except the fact that USB ist disabled, this doesn't seems to have any effect on the power consumption.
I did not cut the power led, do you think It could produce the difference ?
Thanks for your help
Are you sure? yes | no