I hope you choose to go with 1xAAA. 
Much higher capacity, low cost, widely available.
The case gets thicker and the gadget weighs a bit more. 
No biggie.

Ron K. Jeffries

On Sun, Dec 15, 2013 at 8:51 PM, Werner Almesberger <werner@almesberger.net> wrote:
Now that I have a complete case, I tried to make Anelok run off
battery power so that I can show it off also outside the lab.

Alas, this turned out to be more difficult than expected. First
of all, idle current (where "idle" means spinning in a while (1);
loop) jumped from 4-5 mA after reset to well above 50 mA after
initializing all the subsystems.

This turned out to be caused by the solder pads of the OLED cable
somehow shorting one GPIO to ground. The soldering looked fine,
though. Re-soldering the pads made the problem go away for a
moment, then return. It took cutting a groove between the pads
to keep these two apart.

With that issue gone, a pad further down the line decided to
carry the torch and started to act up at about 20 mA. Well, also
that issue fell victim to a hot iron and a sharp knife.

These events suggest that the amount of rework I've done on that
part of the PCB has about reached the board's limits. I call this
"rework to death", where you eventually reach a point where every
attempt to fix something just creates new problems.

Anyway, so far that area seems to be under control. Then I
optimized some of the GPIO initializations, saving some 400 uA in
total. One surprising find was that setting GPIOs going to
(unconnected) pads to "off" draws some 50 uA per pin more than
setting them to output low.

Alas, Anelok still didn't make it even to the PIN input dialog,
with its rather moderate energy consumption (about 10 mA).

So I kept on experimenting. I added CPU sleep and converted the
timing delays (mdelay) to sleep with wakeup by interrupt (msleep).
Surprisingly, this only reduced the power consumption from about
4 mA to about 3 mA, and the deeper sleep modes didn't seem to have
any additional effect.

And Anelok still wouldn't run from battery power alone.

Today, I broke all those changes down into reasonably small chunks
and added a few more uses of msleep. Lo and behold, after all
this, it would suddenly be content with just the battery.

Here's the proof - no cables attached:


The case looks a bit odd because the two halves came apart during
the experiment. Also, the temperature measurement is a bit too
optimistic - ambient temperature was only in the low 30es.

A quick measurement revealed that idle current can now be as low
as about 1 mA, which would be reasonably close to the up to
500 uA the MCU alone can draw in the current sleep mode. (It can
go much lower, but this needs more work.)

There are more mysteries in power management, e.g., the board
didn't want to start at 2.5 V (from a lab power supply) in one
experiment, while even voltages as low as 1.5 V should be fine.

While things look better now, the initial poor results may indicate
that a stronger battery may be needed. The boost converter could
also run from a single AAA cell (which would require only a
moderate size increase) but the current unstabilized battery
voltage rail (MCU and RF) would have to move past the/a converter,
which means that the converter would be continuously active.

As they say, research has shown that more research is needed.

- Werner

Qi Hardware Discussion List
Mail to list (members only): discussion@lists.en.qi-hardware.com
Subscribe or Unsubscribe: http://lists.en.qi-hardware.com/mailman/listinfo/discussion