IoT 201: Power Management, Part 1

You don’t need fancy market research to know that long battery life is critical for the success of battery-operated electronics. Previous lessons in our IoT 101 series discussed how to efficiently supply battery power to your IoT device. Today we kick off our IoT 201 series with tips on how to efficiently draw power from your IoT batteries.

You can’t manage what you can’t measure, so let’s start by building an instrument to measure what power our IoT device is consuming in real-time, and relate that power consumption to what our software is doing. Here’s a thumbnail spec for the instrument:

  • Two analog inputs, one each tracking voltage and current drawn from the power supply.
  • Signal conditioning for each analog signal to match the 0 – 1.8 V range of an ARTIK 5 or ARTIK 10 developer board.
  • At least four digital inputs to track the state of the unit under test.
  • One digital input to trigger data logging.
  • Data logging software to produce a flat file of records.
  • Controllable sample interval down to tens of milliseconds.

System overview

We’ll use a resistor stack to divide the power supply voltage into the range of our ARTIK analog input channels. Current will be measured with a Hall effect sensor amplified by an op amp to increase resolution. That gets us instantaneous power consumption: current times voltage (I * V). To understand how the power consumed relates to the work being done by our IoT device, we’ll record unit state through a sequential block of GPIO pins; the size and position of the block will be selectable in software. A separate GPIO pin will be used to trigger the data logger to create a delimited flat file for offline analysis.

Logging voltage, current, and IoT device state lets us see where and when we’re consuming the most power.

Here’s the parts list for the datalogger:

  • One low-current sensor breakout board ($11.95 from Sparkfun)
  • Two 1 K Ohm Potentiometers
  • Breadboard and jumper wires
  • 2.54 mm (0.1”) pin strip header
  • Pigtail cables to insert the instrument between your power supply and your IoT device
  • Arduino or other C++ development environment
  • Voltmeter

Circuit walkthrough

A Hall-effect sensor measures current with zero insertion loss, while a potentiometer divides the power supply voltage for reading as an analog input.

The current sensing board uses an ACS 712 hall effect sensor from Allegro Microsystems, which handles up to 50 A with output sensitivity between 66 and 185 mV/A depending on supply voltage. To boost the signal for the current levels we need, the board includes an op amp and two trim pots, one for offset and one for gain.

Details of the current sensor, showing amplifier and calibration circuits.

An editable schematic of the current sensor board is available on GitHub along with the board layout. (You’ll need to install a free version of CadSoft Eagle.) Note the circuit derives the amplifier reference voltage from Vcc, so any noise in the supply will be imposed on the output. The power supply that came with my ARTIK 5 development kit had a bit of noise, but it was perfectly acceptable. However, if you’re measuring power drawn from a noisy source, you’ll want to use cleaner power for the current sensor. I’ll talk more about optimizing the current sensor in Part 2 of this guide.

Build procedure

Here’s how to build the current sensor.

Step 1

Order the low-current sensor breakout board from Sparkfun or other online retailer. I paid $11.95 for mine and got free shipping and delivery in less than a week. Collect the rest of the parts list.

Step 2

Take a strip of 2.54 mm (0.1”) pin header and break off one two-pin piece and one three-pin piece. Insert them from the bottom of the breakout board through the adjacent Ip+ / Ip- and GND / Vo / 5V holes respectively. Solder in place.

Step 3

Insert pots in breadboard. Connect the ends of each fixed resistor to Vcc and GND. Use a voltmeter to measure the voltage between the wiper and ground; adjust pots to set the voltage to approximately 1.6 V (90% of full scale value for ARTIK analog inputs).

Step 4

Insert the breakout board into the breadboard. First, dry fit the pins to see how they align in your breadboard. The board will be skewed slightly due to the alignment of the two- and three-pin headers, but it will insert without problem. However, if you have a narrow breadboard like mine, the inserted board will block access to sockets connected to the pins. I solved that with green jumpers for the Ip+ and Ip- pins. With the jumpers in place, insert the breakout board.

Step 5

Finish wiring the instrument, including jumpers to ARTIK pins for A0, A1, GND, and jumpers from GND to GPIO pins you plan to use for status input and trigger.

Using the instrument

We now have an instrument to improve our IoT designs or to track the power consumed by any low-voltage device. In fact, the ACS 712 sensor provides a minimum of 7.1 KVrms isolation between input and output, so we could use it in power circuits, though obviously not in its breadboard incarnation. The sensor also works on AC as well as DC currents, though the software developed for this project is not designed to handle AC sources. In Part 2 of this guide you’ll find software for the data logger and learn how to use it to improve the battery performance of your IoT design. I’ll also discuss how to take this design off the breadboard and into a lab environment. Explore the IoT 101 series: Connectivity, Networks, Sensors, Security, Power Supplies (Part 1, Part 2) About the author: Kevin Sharp has been an engineer since long before he got his engineering degree, and has extensive experience in data acquisition and control networks in industrial, retail, and supply chain environments. He’s currently a freelance writer based in Tucson, Arizona.