Skip to content

Commit

Permalink
docs: Move battery sensing hardware integration to new page
Browse files Browse the repository at this point in the history
  • Loading branch information
caksoylar committed Dec 11, 2024
1 parent 84baf92 commit 0f9abbc
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 22 deletions.
30 changes: 30 additions & 0 deletions docs/docs/development/hardware-integration/battery.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
title: Battery Sensing
sidebar_label: Battery Sensing
---

If your keyboard is using one of the [boards supported in ZMK](../../hardware.mdx) it will already be configured to [sense and report battery levels](../../features/battery.md).
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](../../config/battery.md) 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:

```dts
/ {
chosen {
zmk,battery = &vbatt;
};
vbatt: vbatt {
compatible = "zmk,battery-nrf-vddh";
};
}
```
24 changes: 2 additions & 22 deletions docs/docs/features/battery.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,5 @@ Windows may not properly ask the keyboard to notify it of changes in battery lev

## Adding a Battery Sensor to a 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](../config/battery.md) 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:

```dts
/ {
chosen {
zmk,battery = &vbatt;
};
vbatt: vbatt {
compatible = "zmk,battery-nrf-vddh";
};
}
```
If your keyboard is using one of the [boards supported in ZMK](../hardware.mdx) it will already be configured to sense and report battery levels.
If you are using a custom board, see [battery sensing hardware integration page](../development/hardware-integration/battery.md) to add support.
1 change: 1 addition & 0 deletions docs/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ module.exports = {
"development/hardware-integration/encoders",
"development/hardware-integration/soft-off-setup",
"development/hardware-integration/pointing",
"development/hardware-integration/battery",
],
},
{
Expand Down

0 comments on commit 0f9abbc

Please sign in to comment.