Spark Battery Life Testing

@wgbartley, I was looking at the code that sets the RTC wakeup alarm for deep sleep. It takes a uint32_t value in seconds so I don’t seen any reason for what might cause what you observed with the 1800s sleep. :frowning:

We’re up to 1 week and still going!


Test #8 finally gave up last night after 1 week, 1 day, 7 hours, 1 minute, and 42 seconds.


These tests are great. Thanks for putting this together @wgbartley :slight_smile:

What we also need is to know what the average current consumption is when the Spark Core is in sleep and deep sleep modes. You could kind of determine that if you knew what the capacity of your battery was at the discharge rate of the Spark Core… kind of hard to know for sure though since that’s a chicken and egg problem.

If we know the average current consumption when the spark is sleeping and also the wake up current, then we can calculate how long it will last with a given battery.

Does anyone have a good current meter to test this with? If not I have a HP34401A that could be good enough.

I don’t have any fancy equipment. My fanciest is a cheap multimeter from Lowe’s. My Weller soldering station is nice, but I use it way less than the multimeter.

It looks like all the tests finally finished. Since the final test was 30-minute intervals and didn’t come close to doubling the 15-minute test as far as battery time, I think the point of diminishing return lies between those two intervals, and probably closer to the 15-minute interval than the 30-minute side of things.

If anyone has any other tests they’d like to see done with a Core and one of my batteries, let me know, and I’d be happy to facilitate. I’m only going to dedicate one Core for any additional testing so that I have some back in the pool for other projects!

1 Like

This is great data. I was just about to perform the same type of tests using 4 AA Eneloop batteries instead. I’ll think I’ll do some calcs on your data and perform some testing of my own and compare the results.

If there is a diminishing return after 15 minutes of sleep, might this suggest it doesn’t actually stay asleep for longer than 15 minutes? Averaging a longer sleep current with fixed brief wake currents should just get better and better the longer you are asleep. The bulk of the battery’s capacity should be consumed in the wake current, so a longer sleep time should in fact prolong the run time.

Time to do some real current measurements… I’ll bust out the HP34401A.

Can you share what’s at “http://myhost.mydomain.tld/?l=test1” so I can compare apples to apples? I’m assuming this is some PHP script on your webhost. Thanks!

1 Like

@BDub, I spoke to @timb about this as well. It would be good to understand the peak current consumed during wakeup and the profile of current consumption. I measured over 500ma peak current on the 5V side but I don’t know for how long. That peak may affect the battery life if it nears or exceeds it max A/hr rating. Food for thought. :smile:

I thought it might be something similar to that. However, the true update interval is close to 30 minutes, so it definitely sleeps or stays in some sort of not-powered-up-and-connected-to-wifi mode for the full ~30 minutes.

I’ve uploaded the code to GitHub here –

I have my HP34401A setup and measuring current within a couple uA. Just need that server side code from @wgbartley :wink: Got it!

@peekay123 first off, let’s not confuse battery life with battery capacity. Battery life would describe how many charge/discharge cycles you’ll get, while capacity is how many mA/h’s you get out of the battery in one discharge cycle (which varies with load current and ambient temperature).

Basically with WG’s 600mAh lipo, 500mA peaks are not going to affect it’s battery life at all. Lipos are easily rated for 1C, if not 10-20C and up discharge rates. C is the capacity of the battery in Amps per Hour. So WG’s battery would be 1C = 600mAh which means you could discharge it at a constant 600mA for 1 hour before it’s dead. This varies from battery to battery so you have to check the datasheet for all of the specifics. If you discharge a battery at a higher C rate like 5C or 10C you might only get 90% or 80% of the capacity rating of the battery. So for 5C you would discharge it at a 3A rate (600mA x 5), and you might expect it to last for 60min/5, but in reality it will probably be somewhat less than that due to more internal heat dissipation and chemistry crap … so maybe 3A for 10 mins instead of 12 mins. You typically won’t see the battery capacity go up if you use lighter loads though, it’s not really inversely proportional like that.

Which is why these little peaks of 500mA won’t do much except be a much higher load than the sleep current, and averaged over time will look like a very small load (say a couple mA). So then essentially you can take 600mA and divide by 2mA let’s say, and get 300 hours of run time. I’m totally just guessing at numbers here… off to measuring!

P.S. If you knew all of that stuff already, great! I’m just kind of pretending like a bunch of people are listening to our conversation and don’t know already :wink:

@BDub, dude your killing me here! I use one wrong word and you on me like a fat kid on a smartie! :stuck_out_tongue:

The 500ma may not be a lot over an hour but it’s still a lot more than 350ma TI states. So what happens when the CC3000 takes a while to connect which I’ve seen at times. That increases the A/hr consumption. The real question is whether that peak current is all CC3000 (hence not in our control) or is there a way to reduce it? :smile:

You don’t have to pretend with me; I’m listening and didn’t know until now. Well, I had an idea, but now I have a better idea. Thanks!

However, regarding the term “battery life”, Wikipedia says it’s both. :stuck_out_tongue_winking_eye:

This is like the Steve Jobs definition… “How long a mobile device can work on a single charge of a rechargeable battery.” That’s consumer crap, not engineering crap :smile:

1 Like

Spark Core is waking up, blinking D7 for 5 seconds, turning off D7 for 5 seconds, turning on D7, POSTing to a PHP script to log that it is alive, turning off D7, then going into DEEP SLEEP for 120 seconds, and repeating… shown here is the first part all the way through to deep sleep. 142-145mA while awake, and 187uA in deep sleep. Running off of a USB port, you can see the voltage measurement on the Tektronix DMM916. Current measured with an HP 34401A accurate to within a few uA’s.

I did not see anything like 500mA… you can watch for yourself :wink:

That’s pretty low current when off… we know the LDO is consuming like 120 or 150uA all of the time so most of it is due to that beast. Still though, anything close to 100uA or less quiescent current is pretty decent for battery powered devices. Obviously lower the better though!

Now to test the long 30 minute wait and see if it powers up current wise at all during that time. If it does my meter will audibly click and I’ll know… that’s about as high tech as I’m going to get with it tonight.

BTW: Here is the setup loop that blinks the D7 led, really I changed it like this so I could reprogram the Core without having to factory reset it :wink:

void setup() {
    pinMode(D7, OUTPUT);
    uint32_t startTime = millis();
    while(millis() - startTime < 5000UL) {
        digitalWrite(D7, HIGH);
        digitalWrite(D7, LOW);

Here’s a little excel work showing how long the battery should last using my measured currents. I adjusted for your average uptime (looks to be about 20 seconds, i.e. it was taking a while to connect to wifi probably) and I also tweaked the battery capacity down to 450mA so that the time of the first test would match, about 12 hours. Then if you look at the rest of the tests, they match up pretty close. I wouldn’t be surprised if your 600mA battery wasn’t being fully charged, and had ~450mA of capacity :wink:

Average current calculation:

Runtime calculation:

What’s interesting is your 900 second test is kind of the outlier in the bunch. 600 and 1800 seem to match my chart pretty close.

BTW: the Core did sleep fully for 30 minutes (1800 seconds) and did not wake up early or anything.

So now if we keep doubling our sleep time, we’re sure to find the point at which there is a true diminishing return.

Aha… it’s when the Wake Time and Wake Current is so diluted by the sheer amount of time that the core is Sleeping. The Sleep Current dominates and you can’t do any better than Battery Capacity / Sleep Current = Runtime Hours.


I know all of the batteries were fully charged when I started them. However, fully charged may not mean exactly 600 mAh. I’m going to label my batteries so I can keep track of them just in case I notice one not living up to it’s labeled potential (like 450 mAh max charge?). I’ll re-run the 900- and 1800-interval tests starting today and tomorrow (wedding anniversary today and Father’s day tomorrow).

1 Like

The way to test it would be to charge it up however you did in previous tests. Then discharge it at a fixed constant current of typically a 1C rate, or 600mA. It should last 1 hour if it is 100% charged. If it doesn’t you can divide the discharge minutes by 60 and multiple by 100 for the capacity it did have. The constant current part might be the tricky part.

Happy Belated Anniversary and Father’s Day!

1 Like

Okay, so I’ve completed my first test using a 60 second sleep time and four Eneloop Ni-MH AA batteries. My calculated battery capacity is almost exactly what the batteries are rated for. Here is a link to the sheet itself.

I’m going to continue testing in subsequent intervals to see if I get the same results.


That’s about as perfect of results as you can expect I think :wink: Good job. Nice chart too :spark: