Files
zmk/docs/docs/development/hardware-integration/battery.md
Cem Aksoylar 700e9b264f docs: Move more sections under hardware integration (#2704)
docs: Move battery sensing hardware integration to new page

docs: Refactor lighting hardware integrations to new category

docs: Link to pin control page from lighting pages

docs: Consolidate lighting feature pages

docs: Remove incorrect redirect

docs: Consolidate lighting config pages
2025-01-13 21:14:25 -08:00

1.4 KiB

title, sidebar_label
title sidebar_label
Battery Sensing Battery Sensing

If your keyboard is using one of the boards supported in ZMK it will already be configured to sense and report battery levels. Below instructions are only intended for users defining and using a custom board.

To enable a battery sensor on a new board, add the driver for the sensor to your board's .dts file. ZMK provides two drivers for estimating the battery level using its voltage:

  • zmk,battery-voltage-divider: Reads the voltage on an analog input pin.
  • zmk,battery-nrf-vddh: Reads the power supply voltage on a Nordic nRF52's VDDH pin.

See the battery level configuration page for the configuration supported by each driver provided by ZMK.

Zephyr also provides some drivers for fuel gauge ICs such as the TI bq274xx series and Maxim MAX17xxx series. If you use a battery sensor that does not have an existing driver, you will need to write a new driver that supports the SENSOR_CHAN_GAUGE_STATE_OF_CHARGE sensor channel and contribute it to Zephyr or ZMK.

Once you have the sensor driver defined, add a zmk,battery property to the chosen node and set it to reference the sensor node. For example:

/ {
    chosen {
      zmk,battery = &vbatt;
    };

    vbatt: vbatt {
        compatible = "zmk,battery-nrf-vddh";
    };
}