Low power / DeepSleep on mBuino

I played a bit tonight with my new mBuino toys that just arrived today. So far everything is working very nicely and I really like it. I was also pleasantly surprized to find that my mBuino’s included the battery holder.

Of course now one of the first things I wanted to do is to put a working mBuino on my keychain that flash a different LED very briefly every second. It was quite easy to do, but the “Wait” command I’m currently using is obviously not the best choice for ultra low power consumption. I tried using deepsleep in code as shown below, but the problem was that it simply never wakes up from deep sleep. Any advise?

 #include "mbed.h"
 #include "WakeUp.h"
DigitalOut myled(P0_7);
int main() {
    //The low-power oscillator can be quite inaccurate on some targets
    //this function calibrates it against the main clock
    while(1) {
        //Set LED to zero
        myled = 0;
        //Set wakeup time for 2 seconds
        //Enter deepsleep, the program won't go beyond this point until it is woken up
        //Set LED for 1 second to one
        myled = 1;


The e dice uses deep sleep so you can use that as a reference. We will be posting the code and other details in the coming weeks

1 Like

I put a CR2025 and only got about a day’s worth of blinking

… (the timing was different than the default firmware.bin - mine was just red/yellow - an embellishment to an iron man costume). ahem… .NERD!!!

Thanks for that info Gus, However, I have no idea where the source code for the e-dice is. I had a look on mbed and found some examples of dice code for the mBuino itself (like the one from Valentin Ivanov), but that use the normal wait command. I could not find the source code of the official e-dice anywhere.

Oops, sorry, I see now that I did not read your reply properly. Ok, no problem… I’ll wait until the code is posted.

I just saw this:


and based on this created this:

I included the same deep sleep code from that post in my project (see mbed.org /users/maxint/code/mBuino_Dice/ ).
It’s working great! I’ve attached a tilt-switch with interrupt routine to my mBuino and even small movement is enough to trigger the routine which will wake mBuino from deep sleep.

Next project idea: add sirene and (waterproof) housing to create tiny anti-theft bike-alarm.

Just a quick update… Someone posted a fix that gets the Powerdown mode down to 3uA at Some notes on mBuino power consumption | Mbed

It had to do with unconfigured GPIO pins default to having the internal pullups enabled. The board has a pull down on pin P0_3. This conflict was causing the extra power draw in sleep mode.

Here is the code snippet to get current down to 3uA:

 #include "mbed.h"
DigitalIn progMode(P0_3);
void enterPowerDown() {
    LPC_PMU->PCON = 0x2;
int main () {

@ KiwiSaner - I believe it was AndyA


The mbed library here: mBuino_Sleep - Enables lower power Sleep and power down modes fo… | Mbed
provides a single function call that makes it easy to access any of the possible sleep modes and also takes care the power sucking pullup and shutting off the LEDs before sleeping.