Skip to the content.

Power module

The power module manages power-related functionality for devices with nPM1300, like the Thingy:91 X, including the following:

Messages

The Power module defines and communicates on the POWER_CHAN channel.

Input Messages

Output Messages

The power message structure is defined in power.h:

struct power_msg {
	enum power_msg_type type;

	/** Contains the current charge of the battery in percentage. */
	double percentage;
};

Configurations

The following Kconfig options control this module’s behavior:

See the Kconfig.power file in the module’s directory for more details on the available Kconfig options.

Kconfig and device tree

State diagram

The Power module uses a minimal state machine with a single state, STATE_RUNNING. In this state, the module:

  1. Initializes the charger and optional fuel gauge in the state entry function.
  2. Waits for messages to arrive via zbus.
  3. Handles battery sample requests and publishes results.
  4. Monitors for VBUS events to enable or disable UART devices.