This USB stick measures supply voltage, calculates power consumption and displays it on an OLED display.
There was a time when USB drives were only for transferring data. Not anymore. The interface is increasingly being used as a power supply and charging port for an assortment of gizmos and gadgets. Take this DIY USB line power meter stick from Electro-Labs, for example. The meter is capable of measuring the supply voltage of the devices connected to the USB port or charger, calculating its power consumption, and then displaying the reading on an integrated 0.5″ OLED screen.
The board itself is built around an ATmega328. In order to keep the circuit as small as possible and reduce the number of components, the MCU runs off its internal 8MHz clock. Meanwhile, the voltage and current are measured by its built-in 10-bit ADC.
To enhance the accuracy of the measurements, an external 2.5V voltage reference IC is included as well. The current is converted to voltage on a 0.01R sense resistor and precisely amplified by an LT6106 high side current sense amplifier before being sent to the AVR’s 10-bit analog port. The stick is capable of measuring up to 2.5A. Since the OLED display requires 3.3V supply voltage, a linear voltage regulator handles the 5V to 3.3V conversion.
“An external 2.5V voltage reference is used to get more accurate ADC readings. Since the ADC module of ATmega328 is 10-bit, the reading resolution is 2.44mV (2.5V/1024). It is quite enough for the purpose of the circuit,” Electro-Labs writes. “The 5V line of the USB port is passed through a voltage divider network including 14K and 10K resistors to extend the readable voltage up to 6V.”
The tiny OLED communicates via an SPI interface and is driven by the U8Glib library. An Arduino sketch reads the separate ADC inputs for the voltage and current, and reveals the measurements on the display. 10 samples from each channel are averaged to filter out the noise.
“After a simple V*I power calculation, it shows up the values on the display by using the U8Glib library. The measurement is repeated every one second. The software runs in an endless loop,” the Electro-Labs crew adds.
Intrigued? You can find a breakdown of entire project, including bill of materials and its necessary code, on its original page here.