@Keyboard_Camper can your latest test be downloaded somewhere? I wanna have a try with my el cheapo multimeter
to sleep or
to stay on with screen off
Thanks! here are some quick results.
First I soldered a wire to the battery terminal and used my programming clip to get to the Vcc pad. Arduboy kept crashing. So I tried using a variable dc/dc converter and got the same results at first. When I soldered a capacitor directly to the GND andf Vcc pogo pins of my programming clip Power was stable enough for Arduboy. I’ve set the voltage to 4.1V to get highest current results.
sketch running no LEDs 26.1mA:
Red LED on ~34,3mA:
Green LED on ~30,6mA:
Power Down ~360uA:
What can I say. Arduboy is Tamagotchi worthy
Look’s like I have a new project Ardubotchi on my stack.
Tamaguino is how I ended up meddling in all this power saving, it would be like an old school Tamagotchi and poop in the middle of the night.
So far I have it so the LED blinks as an indicator when sound and oled are off and once the power stuff is incorporated it can be put in low power to keep the game ticking over without waking me up.
I really want to look at extending the watchdog with a counter next, so it can wake to a minimal power state knock the counter up a notch and go back to sleep having the counter wake for an event.
The Lo Power library can probably be slimmed down a lot and if the deeper sleep modes were to be incorporated into the Arduboy2 library we could have power saving pause.
@Mr.Blinky if you chuck displayOff() & displayOn() into the sketch or disable it in the GoToSleep function you should be able to also measure power down with screen On.
I think the sketch you used unless you edited it had brown out detection enabled.
If you peek into the low power.cpp I think it’s in idle() mode you can switch timers, SPI and more off manually if you’re after some more results for comparison.
Yes BOD was on. I did some more tests today with BOD on ~400uA with BOD off ~375uA saves about ~25uA. I’ve also did some testing with a black screen instead of turning it off with powerdown + BOD off and current draw was about ~1,2 mA
With display on and space invader on screen: 25,9 mA when powerdown 6,6 mA. Same test but with space invader off screen 21,8 mA. Display on powerdown 2,3 mA. Display cleared and powerdown 1.2 mA.
It seems the Atmega32U4 BOD feature can’t be turned off by code. BOD can only be turned off by the fuse settings. So the lower power consumption was purely coincidal I guess.
Anyway. I had a go at powerdown myself to look into thw WDT and I wanted to see a Tamagotchi move around
I was pulling my hairs out why I couldn’t seem to get the WDT to work and then discovered that the USB CDC code disabled the WDT on setup
Here’s a demo with auto power off and auto power on. You can also use the B button to power off and A button to power up again. The WDT interrupt is triggered ever second and drives a simple clock.
It’s funny because when I started with another Arduino example the only thing I could get to work was the WDT and external interrupts we’re the issue.
It’s great to see this being taken to the next level and getting to see the power consumption plummeting on the multimeter is a real treat.
Well every time after a upload and whenever the USB cable was connected (that was most of the time) WDT got disabled
Forgot to mention USB support is also restored after power up. You can ‘play’ around with power down/power up buttons making connect and disconnect sounds on your PC
I wanted to see if I could get the auto features working which are madatory for a Tamagotchi. He needs to wake up and beep around for your attention
I’m starting to see the potential of this power down mode so I want to look into a minimalist version for auto power down for (existing) games. The idea of continuing a game by pressing A button instead of restarting from a level sounds so awesome.
Get this working and I’m sure lots of people will add it.
I’ve got it working now. But it takes 270 bytes. Will move some (re)initialisation stuff out of the ISR to reduce size.
Even at 270 bytes, it is a lot smaller than the code I wrote to save the game to eeprom.
If a reasonable API can be devised for handling low power mode(s), I’ll add it to the Arduoby2 library.
Managed to cut the size down quite a bit. Adding the auto power down to a sketch increases size by ~148 bytes
Addind it to a sketch is quite easy. Besides adding it to the sketch folder and including the header file,
Add the followin to setup():
and add the following to loop():
When no buttons are pressed for over 32 seconds Arduboy is powered down
Besides reducing the code size I also fixed a few issues (disabling USB clock) and discovered that a cheap trick to turn the display off is to just pull the OLED display reset pin low. Power consumption is the same as when the Arduboy2 library displayOff() function was used. @MLXXXp you can save a few more bytes by simplifying displayOff()
Made a little demo to make wachting the powerdown more fun
Except I’ve come across display modules that don’t include a reset pin. They use an RC network to force a reset on power up. For the benefit of those making a clone with such a display, it may be better to use the power down commands, at the expense of a few bytes of code.
I was just thinking about official Arduboy. Didn’t think about those non reset clones.
I’ll have another run at it. Seeing if I can reduce code further by removing the WDT and turn to millis for the timeout.
Made a more (library) friendly version using the timer0 millis for power down timing. WDT is no longer used so it doesn’t doesn’t require the modified CDC.cpp
code is about 40 bytes larger (32 for Arduboy2::displayOff() ) but compiles to ~232 bytes in the example sketch . power down time can be set from 0 seconds up to over 4:40 hours with this version.
Old version renamed autopowerdown-wdt
[WIP] #/Letter Pairs, a brain game
Forgot to post here in the weekend
I made some changes to simplify things. Just include the files in your sketch and add autoPowerDown() in your main loop.
I’v added the autoPowerDown to my forked version of Mystic Balloon. Haven’t turned off my Arduboy since the weekend. Too lazy to switch power off now
It will be interesting to see how long one will last.
I haven’t turned off my Arduboy since Feb 3th and played Mystic Balloon for rougly 10~15 minutes a day (didn’t do exact measurement). This evening it wouldn’t wake up. so that’s about 12 days with 2.5 hours of gameplay.
This is AWESOME to see you guys playing with. I always wanted to just lay it down and not turn it off. 12 days isn’t bad.