A USB-C Power Meter That Goes the Extra Mile
Running an AI model on a battery-powered device is very different from running it on a desktop computer. Aside from getting the model to fit within the memory constraints of the hardware, there is the matter of how much energy it consumes. And that is not a question that can typically be answered by just reading a chip’s datasheet. To automate the process of collecting such information from a lab full of development boards, Pierre Dubouilh of Kernwerk recently developed a USB-C power meter with a few tricks up its sleeve.
In addition to measuring power consumption, the little device can remotely power cycle the hardware that is plugged into it. As anyone who has ever run a large number of automated tests on embedded systems can appreciate, not having to walk over to a misbehaving development board to unplug it and plug it back in is a nice feature to have.
Making every milliwatt count
Dubouilh started by drawing up a schematic in KiCad before enlisting the help of Claude Code to check his work. The AI coding assistant then took a crack at laying out the PCB. While some manual cleanup of the layout was necessary, the initial design was functional.
At the core of the meter is a 71-cent ATtiny816 microcontroller. This inexpensive 8-bit chip has enough processing power and all the peripheral hardware needed for the job, and it requires very few external components. Its factory-calibrated internal oscillator also provides the basis for sufficiently accurate timing when calculating energy consumption, eliminating the need for an external crystal.
The actual measurements are handled by a Texas Instruments INA237 current and power monitor paired with a five-milliohm shunt resistor. The board supports USB-C power supplies delivering up to 20 volts at 5 amps, with current measurements having a resolution of 250 microamps.
Pulling the plug remotely
An arrangement of MOSFETs and solid-state relays allows the microcontroller to electrically mimic disconnecting a USB-C cab




Comments
No comments yet. Be the first to share your thoughts.