Battery life of the AnnoyATtiny85

Quite a while ago I promised a post about the battery life of the AnnoyATtiny85.  I’ve been pretty busy getting ready for Vancouver Mini Maker Faire lately, but I’m finally on the home stretch there, so I’m taking a break to finally write this post.

As you may recall from that previous post, I spent a lot of time getting the power usage of the AnnoyATtiny85 down to miniscule levels.  After all that effort, I wanted to know how long one of these devices would run for, before it became too quiet to be annoying.  Based on some rough back-of-the-envelope calculations, I discovered that the answer was on the order of many months, so I didn’t want to just leave one sitting in my apartment for months.  Instead, I programmed one with some modified code, that made it beep every 2 seconds.

Having an annoyer that should last a much shorter period of time, I decided to do some data logging, to get a good answer to my initial question.  My data logging was accomplished with a Arduino Uno connected to a Linux PC, that was simply logging the data from the serial port to a file, after prepending a timestamp to each line.  One ground pin of the Arduino was connected to the negative battery terminal of the annoyer, and two analog pins of the Arduino were connected to the positive battery pin, and the piezo beeper output pin of the annoyer.  The code on the Arduino simply read these pins a number of times every second, and wrote the output to the serial port.

After a couple hours of sitting there beeping merrily away in a corner of my workshop, I realized that it would eventually drive me mad, so I put a small piece of tape over the piezo.  I could still here it if I listened for it, but I was no longer at risk of losing my mind.  Not from that, at least.

For the next week, I would take the tape off every now and then and subjectively judge for volume of the beeping.  For the first few days, I couldn’t discern any difference between it, and a beeper with a fresh battery.  After about 5 days, it was starting to get a little bit quieter, and after 7 days, the volume had dropped enough that I could imagine it wouldn’t do a very good job of annoying anyone any more.

At this point, I had slightly over 500MB of text data recorded from my datalogger.  After running it through a few scripts, I came up with this graph:

The horizontal axis is time. The vertical axis for the red is battery voltage. The green is raw analogRead data from the buzzer pin. The faint green line at the bottom is the level read when not beeping. The range of higher readings are from when it’s beeping. (The short gap early on the 25th is when I accidentally exited the datalogger script)

One thing I found interesting is that the battery actually started at 3.1v and rapidly dropped to 2.8v, where it stayed for 16 hours before slowly beginning to drop again.  This graph zooms in on the first 18 hours of the test:

Ok, that may be pretty ant all, but what does this all tell us about the real-life battery life of this device, when it’s beeping every 5-8 minutes instead of every 2 seconds?  Let’s do the math.

For the test, the watchdog timer was set to make it start beeping every 2 seconds.  The beeps last, on average, 0.6 seconds.  This means it spends an average of 1.4 seconds idle, in deep power saving mode, between beeps.

To calculate the average current draw, we multiply 1.4 seconds by 0.007mA, the current it draws then it’s idle, and add that to 0.6 seconds times 7mA, the current it draws then it’s beeping.  We divide the whole thing by 2 seconds to get the average current draw in mA.

Test current draw:
((2s-0.6s)*0.007mA + 0.6s*7mA) / 2.0s
(1.4s*0.007mA + 0.6s*7mA) / 2.0s
(0.0098mAs + 4.2mAs) / 2.0s)
4.2098mAs / 2.0s

(This current draw was measured at 3.0v, so this calculation won’t be entirely accurate due to the voltage dropping over the time period of the test.  It should give us a ball-park answer though.)

It took 7 days for the beeper to be quiet enough that it was no longer serving it’s annoying purpose, so let’s see how many milliamp hours it consumed during this time.

7 days = 7*24 hours = 168 hours
 168 hours * 2.1049mA = 353mAh

This is significantly more than the 240mAh claimed in the datasheet, which is probably accounted for in the fact that this device is drawing current at a much lower average rate than was used to calculate the 240mAh, and the fact that I’m not taking into account the decreasing voltage and it’s effect on the current draw.

Now, I’d like to figure out how this relates to the current draw when it’s beeping every 5-8 minutes instead.  The average period in this case will be:

(5*60 + 8*60) / 2 = 390s

390s instead of 2.  Now, we can’t just take 390s/2s = 195 and multiply the result by 195.  That wouldn’t take into account the fact that the ratio of time it’s beeping is changing.  It’s still just 0.6s, but 0.6s every 390 seconds instead of every 2 seconds.

Let’s do the math again, with 390s:

((390s-0.6s)*0.007mA + 0.6s*7mA) / 390s
(389.4s*0.007mA + 0.6s*7mA) / 390s
(2.7258mAs + 4.2mAs) / 390s)
6.9258mAs / 390s

So when this is running with it’s normal settings, it’s average current draw will be around 0.01775mA, or 17.75 microamps!  How does that compare to the test scenario?

2.1049mA / 0.01775mA = 118

The average current draw of test is 118 times that of normal operation.
So, it lasted 7 days before it got too quiet in the test, so if we multiply that by 118, we get 826 days!  That’s over two years.

Now, since we didn’t account for changes in voltage, or the fact that some cells may have been on the shelf for a while, and won’t start at quite the same capacity, in addition to normal losses of capacity over the 826 days (just like sitting on the shelf), we can’t realistically expect them to last that long.  But, I think it’s realistic to say they should last for many months before they get noticeable quieter.

If anyone has information to share about how to account for the drop in voltage over the time of the test, I would be very interested to hear from you.

One thought on “Battery life of the AnnoyATtiny85”

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: