---
title: "BatteryStateService"
canonical_url: https://developer.repebble.com/docs/c/Foundation/Event_Service/BatteryStateService/
last_updated: 2026-10-29
sdk_version: 4.33.1
---
# BatteryStateService

Source: https://developer.repebble.com/docs/c/Foundation/Event_Service/BatteryStateService/

Determines when the battery state changes

The BatteryStateService API lets you know when the battery state changes, that is, its current charge level, whether it is plugged and charging. It uses the [BatteryChargeState](https://developer.repebble.com/docs/c/Foundation/Event_Service/BatteryStateService.md#BatteryChargeState) structure to describe the current power state of Pebble.

Refer to the [classio-battery-connection](https://github.com/pebble-examples/classio-battery-connection) example, which demonstrates using the battery state service in a watchface.

## Function Documentation

void battery\_state\_service\_subscribe([BatteryStateHandler](https://developer.repebble.com/docs/c/Foundation/Event_Service/BatteryStateService.md#BatteryStateHandler) handler)

Subscribe to the battery state event service. Once subscribed, the handler gets called on every battery state change.

#### Parameters
 handler

A callback to be executed on battery state change event

void battery\_state\_service\_unsubscribe(void)

Unsubscribe from the battery state event service. Once unsubscribed, the previously registered handler will no longer be called.

[BatteryChargeState](https://developer.repebble.com/docs/c/Foundation/Event_Service/BatteryStateService.md#BatteryChargeState) battery\_state\_service\_peek(void)

Peek at the last known battery state.

#### Returns

a [BatteryChargeState](https://developer.repebble.com/docs/c/Foundation/Event_Service/BatteryStateService.md#BatteryChargeState) containing the last known data

## Data Structure Documentation

struct BatteryChargeState

Structure for retrieval of the battery charge state.

#### Data Fields
uint8\_t charge\_percent

A percentage (0-100) of how full the battery is.

bool is\_charging

True if the battery is currently being charged. False if not.

bool is\_plugged

True if the charger cable is connected. False if not.

## Typedef Documentation

 typedef void(\* BatteryStateHandler)(BatteryChargeState charge) 

Callback type for battery state change events.

#### Parameters
 charge

the state of the battery [BatteryChargeState](https://developer.repebble.com/docs/c/Foundation/Event_Service/BatteryStateService.md#BatteryChargeState)
