Skip to content

forderud/HidBattery

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Arduino battery emulator

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.

Supported Arduinos

Setup & Usage

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.

Additional setup on Linux

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.

Tested on the following Operating Systems

  • Mac OS 14 Sonoma
  • Ubuntu 24 LTS
  • Windows 2000 - 11

Screenshots

Windows 11

image
Obtained with CDC_DISABLED defined1 to emulate 6 batteries.

Windows 10

image
Obtained with CDC_DISABLED defined1 to emulate 6 batteries.

Windows 2000

image
Obtained with CDC_DISABLED defined1 to emulate 6 batteries.

MacOS

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

Linux

image
Limtation: Linux seem to assume charge values in %, regardless of the actual unit (upower issue #300).

Windows HidBatt extension driver

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.

Footnotes

  1. CDC_DISABLED can be defined by uncommenting a line in %LOCALAPPDATA%\Arduino15\packages\arduino\hardware\avr\<version>\cores\arduino\USBDesc.h. This will disable serial console over USB, which will free up 3 USB endpoints for alternative usage. 2 3

About

Arduino battery emulator

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •