Make an Arduino board with USB capabilities act as a HID Power Device to emulate one or more battery packs. This can be useful for simulating various power scenarios that are otherwise hard to test with an actual battery.
The project is based on Alexander Bratchik's HIDPowerDevice project, but with changes to make the emulated battery more like a "battery" instead of a "UPS". The project is also extended to emulate multiple batteries.
- (Pro)Micro
- Leonardo
Clone this repository to your Arduino libraries folder (C:\Users\<username>\Documents\Arduino\libraries\HidBattery on Windows). Then, open the battery/battery.ino sketch in Arduino IDE and press "Upload". The Operating System will afterwards detect one or more new batteries.
The BatteryQuery.exe tool can be used for querying battery parameters from the command line.
Copy linux/98-upower-hid.rules file to the /etc/udev/rules.d/ folder and reboot. This is required for Linux device manager (udev) to recognize the Arduino board as a battery.
- Mac OS 14 Sonoma
- Ubuntu 24 LTS
- Windows 2000 - 11

Obtained with CDC_DISABLED defined1 to emulate 6 batteries.

Obtained with CDC_DISABLED defined1 to emulate 6 batteries.

Obtained with CDC_DISABLED defined1 to emulate 6 batteries.

Limitation: MacOS displays the battery as a UPS. The UI furthermore only display aggregated information, and not per-battery.

Limtation: Linux seem to assume charge values in %, regardless of the actual unit (upower issue #300).
This repo also contains a HidBattExt filter driver that extends the in-built HidBatt driver in Windows to also parse and report CycleCount and Temperature battery parameters.