# Riffle Power Consumption

by kinasmith | 09 Jun 01:54

## Measuring Power Consumption

As with most battery powered devices, it's a reasonable thing to want to know how long they are going to run before running out of power. This depends highly on how much power they actually consume and, obviously, the size of the battery being used. It's easy to measure current consumption with a multimeter, but it is sometimes very interesting to look at it over time. For example, if I'm building a datalogger that records a sensor reading every 15 minutes, I can measure with a multimeter the standby current, how much power the device is consuming while just waiting, but the actual sensor reading and logging events happen fast. To calculate the amount of energy being used, I need to know the current and the exact amount of time.

It can be measured with an oscilloscope with a couple tricks.

Ohm's Law states:  V = I/R  Where I is current, R is resistance, and V is voltage.

So, if we measure the Voltage across a Resistor, we can calculate the Current flowing through it. If the Resistance stays fixed, and the Voltage changes...the Current changes too.

## Actual Consumption

The code I was using the example with the SHT-21 Temp/Humidity Sensor and using the RealTime Clock as the scheduler. The code is on Github here.

### Results?

This is the full Sensor Reading and Data Recording Cycle. You can see the unit divisions on the bottom of the screen, 50mV per square vertically and 100mS per square horizontally.

The Riffle wakes up, which is the initial rise in current ~300mS from the left of the screen. It takes about 300mS for the sensors to take their readings, then there is a large spike in current, which is the data being written to the SD card, then 300mS to finish up, then it goes back to sleep.

Looking more closely at that current spike, we can see each individual write event happen.

This is our code for that time chunk.

void writeDataToCard(float t, float h, float v, long utc) {
File dataFile = SD.open("LOG.CSV", FILE_WRITE);
if (dataFile) {
dataFile.print(t);
dataFile.print(",");
dataFile.print(h);
dataFile.print(",");
dataFile.print(v);
dataFile.print(",");
dataFile.print(utc);
dataFile.println();
dataFile.close();
}
}


We're writing 4 values to the SD card, the Temperature, the Humidity, the Battery Voltage, and the Time Stamp, and there are 4 spikes...Neat.

If we want to calculate how much current is being drawn during those write events it's easy.

V=I/R = 150mV=I/2.2ohms = 68mA


But those spikes are only about 0.5mS long....so it doesn't really matter too much. What's more important is the sleeping and awake average current draw.

### Awake

Awake current is ~11mA, at a battery voltage of 3.8volts, and we're awake for 600mS, which means it uses 0.007mWh of power

### Sleeping

Sleeping current is ~ 5mA, and for a time period of always. Let's just calculate power consumption for 1 hour. Same math applies, and we get 19mWh for an hour of sleeping.

### Prospective Battery life

So, if we're using the 18650 battery that came with the Riffle, it's a 2200mAh @ a nominal voltage of 3.7v, which is a capacity of 8140mWh

8140/19.007 is 428 hours, which is about....

18 days

This assumes we live in a magical world where the rated capacity of the battery is actually accurate...which unfortunately is not the world we live in. Assuming 50% of the rated capacity on any battery is pretty normal, which leaves us with....

9 days

## Thoughts

It's pretty easy to reason out that the amount of power consumption during sleep is the major factor in extending battery life. A sleep current of 5mA is exceedingly high for a device like this. It shouldn't be more than 10 or 20 µA, which is many orders of magnitude smaller. The Atmel ATmega328 is capable of sleep consumption of close to 1µA, as documented here.

I'm not sure where the leakage is happening, but it seems like it shouldn't be drawing this much power. Maybe I forgot to turn something off or on....

Those are my thoughts right now.

thanks for this. I do think 9 days is good for some use cases, and not great for others

This is so fantastic. So neat to see the current spikes with the SD card writes!

ANd ... oh, my, what a terribly high sleeping current ...

I should definitely do the math soon and add up the nominal quiescent power draw of all of the other chips on the board in addition to the 328p. The LDO and the additional eeprom will be part of the tally ... as will the SHT-21. I don't expect they'd should require as much as a millivolt altogether, though. There is some question as to whether the LDO part is properly chosen -- there might be a lower-power version of the same package that could be swapped in.

I somehow suspect that the SD card itself might be responsible for a lot of power consumption while sleeping. Edward Mallon has done a lot of great research into this, and the power draw seems to depend on the SD card manufacturer. He also found some trick around pulling up the MISO MOSI SCK lines (if I recall) when the device was asleep.

Maybe one simple thing to do, in order to see how much the SD card is contributing (even when not writing), would be to modify the sketch so that skips the write part ... and then remove the SD card ... and let the device sleep, and measure the current then? One could also try an SD card from another manufacturer ...

Bravo on this elegant setup. Really helpful to see this process laid out so nicely.

Is this a question? Click here to post it to the Questions page.