Posts | Comments

Planet Arduino

Archive for the ‘Power Monitor’ Category

[Trent M. Wyatt]’s CPUVolt library provides a fast way to measure voltage using no external components, and no I/O pin. It only applies to certain microcontrollers, but he provides example Arduino code showing how handy this can be for battery-powered projects.

The usual way to measure VCC is simple, but has shortcomings.

The classical way to measure a system’s voltage is to connect one of your MCU’s ADC pins to a voltage divider made from a couple resistors. A simple calculation yields a reading of the system’s voltage, but this approach has two disadvantages: one is that it constantly consumes power, and the other is that it ties up a pin that you might want to use for something else.

There are ways to mitigate these issues, but it would be best to avoid them entirely. Microchip application note 2447 describes a method of doing exactly that, and that’s precisely what [Trent]’s Arduino library implements.

What happens in this method is one selects Vbg (a fixed internal voltage reference that is temperature-independent) as Vin, and selects Vcc as the ADC’s voltage reference. This is essentially backwards from how the ADC is normally used, but it requires no external hookup and is only a bit of calculation away from determining Vcc in millivolts. There is some non-linearity in the results, but for the purposes of measuring battery power in a system or deciding when to send a “low battery” signal, it’s an attractive solution.

Being an Arduino library, CPUVolt makes this idea very easy to use, but the concept and method is actually something we have seen before. If you’re interested in the low-level details, then check out our earlier coverage which goes into some detail on exactly what is going on, using an ATtiny84.

Giovanni Carrera has created a capable power monitor, dubbed the ArduINA226, using an Arduino Nano and an INA226 IC. 

This chip measures the current and voltage, and calculates power, which is then read by the Arduino board and sent to an LCD display. The unit also features a micro SD card for storage and later analysis, letting you track stats such as energy consumption over time.

Nearly any sort of Arduino board can be used for this setup, but the Nano was chosen as it makes things nice and compact and has an included USB adapter. The electronics are mounted on a PCB and housed in a professional-looking enclosure. 

A full schematic for the ArduINA226 is available in Carrera’s project write-up, along with code if you’d like to make your own.



  • Newsletter

    Sign up for the PlanetArduino Newsletter, which delivers the most popular articles via e-mail to your inbox every week. Just fill in the information below and submit.

  • Like Us on Facebook