
How to run an Arduino clone on a 9V battery for weeks or even months - hansc
http://hwstartup.wordpress.com/2013/03/11/how-to-run-an-arduino-on-a-9v-battery-for-weeks-or-months/
======
Joeboy
TI's msp430s are crazily power-efficient. Worth a look if you want to run a
long time on batteries. Or indeed fruit:
<http://www.youtube.com/watch?v=nPZISRQAQpw>

~~~
IgorPartola
I recently started playing with MSP430's. They are fun devices and I think
there are lots of possibilities with those. I have no real experience with
other uC's so I can't say anything about others or compare. Having said that,
here are some very basic impressions:

TI's example code is often confusing and over-engineered. It is much better to
find advice on blogs and forums instead.

The community has some great individuals that will produce great examples and
tutorials. Unfortunately, it is very far removed from places like GitHub.
Almost all code is shared directly in the forums at 43oh.com.

There are a couple of big projects surrounding MSP430's. Energia is, from what
I understand, an Arduino-like IDE which lets you program at a much higher
level, but at the cost of some performance. When you only have 512 bytes of
RAM, it may or may not be an issue. Another one is BSP430 which is a lower
level set of libraries. It promises much higher level abstractions at the cost
of small performance penalties. I found the tutorials to be rather terse, but
I may need to give it more time.

Outside of those big projects, there is lots of duplication of effort. It is
typical to see 3-5 different implementations of bit-banging UART drivers that
are all slightly different. I am no exception, as I started writing my own
little set of libraries for dealing with various peripherals.

Lastly, a lot of the tutorials out there either use the register names
directly (P2IE, P1SEL, etc) or provide really poorly named abstractions
(cal_adc_15t30). Most of my time working with it so far has been spent on
naming functions something like gpio_get_val(), uart_puts(), etc.

P.S.: Physical hardware buttons are terrible devices. Debouncing them is a
must and most implementations in the wild are incorrect. [1] is a good read.

[1] <http://www.ganssle.com/debouncing.htm>

~~~
theatrus2
The problem with the raw register names is that they're not even consistent
between compilers/libraries. However, they're usually the best route to go
form an efficiency standpoint.

~~~
IgorPartola
Well, even doing a

    
    
      #define LED_GREEN  BIT6
    

would be an improvement. However, I'd be willing to pay a small cost in terms
of RAM/performance for doing something like this:

    
    
      gpio_get_val(P1, 6);
    

which would return whether port 1, pin 6 is high or low. I think that can even
be a macro so it would be compiled down to (P1OUT & BIT6).

------
SageRaven
Ever since these small devices have been in production, I've always wondered
about their potential use in clandestine installations. Obviously things like
the Shiva Plug are almost capable of hiding in plain site, so long as there's
a plug near by.

I've also wondered if there are clamp-on induction taps that can be clamped to
power lines (say, above the tiles in a corporate bathroom powering the lights)
and drive low-power devices like a small Arduino.

This 9V hack is really cool for sensors and the like, but it wouldn't power a
full OS with wireless AP ability for very long.

~~~
Maakuth
Hmm, indeed. Some sort of rogue mesh network installation powered by induction
should be interesting for people like the Syrian opposition.

~~~
chris_mahan
I think right now the Syrian opposition is more interested in anti-tank and
surface-to-air missiles.

------
fr0sty
This is a wonderful little piece of information. Thank you.

I had the crazy idea a while back about stuffing a micro-controller,
temp+humidity sensor, piezo speaker into my guitar case to let me know if the
Humidity got out-of-band but I couldn't see how to get this to run for more
than a few days with out having a gian5t battery pack or having to plug it in
to the wall.

Now I know, and knowing is half the battle.

------
jcr
Excellent writeup. Thanks. Are you planing on covering the "What else can you
do?" stuff in more detail in another post? If not, then adding a few more
details/links in that part would be an idea for improving something that's
already great.

------
ay
I have a dark corner near the entrance door and I made a battery-run light (2
LEDs - to light up the key hole) with very simple logic: when you press the
button, it lights up for 2 minutes, then blinks for another 2 minutes; then
blinks faster for another minute; then goes dark.

The button is wired to "reset" pin of an attiny45, the LEDs are connected to
two pins of the chip, and the code, predictably, ends with a low-power sleep
instruction.

Two 2100mAh AA-sized accumulators provide the power.

I "launched" it into use about 4 months ago (I forgot the exact date), still
did not have to recharge.

~~~
chimi
Just out of curiosity, why have it blink for 2 minutes, then faster for 1
minute?

~~~
theatrus2
That would be annoying to me too. I'd have it PWM dim.

~~~
ay
Unhelpful when you are putting in the keys - better strobed full-light than
dim - the latter sounds cool but is impractical. The human vision is much more
effective at flash-like lighting than at a constant near-zero one. At least,
mine and my cohabitants :-)

Try it IRL and then tell me your opinion, I'm curious to know your opinion.

------
ericb
I'd love to see a pre-packaged low power optimized Arduino. This would open up
a ton of possibilities that I daydream about. I don't want to solder chips
myself, though.

~~~
veemjeem
I'm not sure if that makes sense. I think you'll find that most of the time
when you do a project, the microcontroller is the component that uses the
least amount of power compared with your other parts.

~~~
ericb
It does, for certain use cases (see the guitar case humidity monitor mentioned
above). In the RAMPS stack for the 3d printer I'm building where the heated
elements and stepper motors burn up proportionally more power, it wouldn't
make sense.

This would be a specialty flavor of the arduino, not a change for the
standard.

------
gpurkins
Sparkfun also has an exceptional write up on how to get into the microamp
ballpark: <http://www.sparkfun.com/tutorials/309>

The article's try and see approach is very detailed and a great read for
anyone looking to get into prototyping with AVR for battery based projects.

------
juanre
A good option when you only need to monitor a few signals is to use an xbee
series 2 module, that will also wirelessly transfer the data to a central
server. It can run attached to an Arduino, but also stand-alone. "Building
Wireless Sensor Networks", by Robert Faludi, is a very readable introduction.

------
stephengillie
Very cool. This is how final projects should be -- we shouldn't just shove the
entire prototyping board into whatever we're making.

Any clues for how to keep 9v batteries providing enough juice when they're in
the fridge? I'm trying to build a fridge monitor:
[http://gilgamech.blogspot.com/2013/02/wireless-temp-
sensor.h...](http://gilgamech.blogspot.com/2013/02/wireless-temp-sensor.html)

~~~
Eduardo3rd
Cool starter project! You could solve this problem in a couple of different
ways.

The most obvious would be running the circuit off of the fridge power supply
directly. I'm not sure how comfortable you would be with re-wiring your fridge
though. The potential to start a fire is probably relatively small, but it
still exists.

Another option would be running a small heater around the battery itself. It
shouldn't take very much power to keep a 9v warm enough for minimal losses in
a fridge. (<http://www.bipowerusa.com/products/bipower-bl9v-u.pdf>)

~~~
HeyLaughingBoy
Instead of using a heater to warm the battery, much better to find a battery
that is rated for the temperatures you need to use it.

~~~
Eduardo3rd
True, but if someone is going for low cost off the shelf 9 volt batteries it
could be a temporary solution. Plus they would learn how to build an
electrical heater, which is a useful skill to have for lots of applications.

------
nathanpc
Great explanation. Thanks.

