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
WakeUp::calibrate();
while(1) {
//Set LED to zero
myled = 0;
//Set wakeup time for 2 seconds
WakeUp::set_ms(2000);
//Enter deepsleep, the program won't go beyond this point until it is woken up
deepsleep();
//Set LED for 1 second to one
myled = 1;
wait(1);
}
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.
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.
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: