nPM1300: Fuel gauge
The Fuel gauge sample demonstrates how to calculate the state of charge of a development kit battery using nPM1300 and the nRF Fuel Gauge library.
For more information about fuel gauging with the nPM1300, see Using the nPM1300 Fuel Gauge.
Requirements
The sample supports the following development kits:
Hardware platforms |
PCA |
Board name |
Board target |
---|---|---|---|
PCA10090 |
|
||
PCA10156 |
|
||
PCA10175 |
|
||
PCA10095 |
|
||
PCA10040 |
|
||
PCA10056 |
|
The sample also requires an nPM1300 EK that you need to connect to the development kit as described in Wiring.
Overview
This sample allows to calculate the state of charge, time to empty, and time to full information from a battery on the development kit connected to the nPM1300 PMIC.
Wiring
To connect your DK to the nPM1300 EK, complete the following steps:
Connect the TWI interface between the chosen DK and the nPM1300 EK as in the following table:
nPM1300 EK pins
nRF52 DK pins
nRF52840 DK pins
nRF5340 DK pins
nRF54L15 DK pins
nRF54H20 DK pins
nRF9160 DK pins
SDA
P0.26
P0.26
P1.02
P1.11
P0.04
P0.30
SCL
P0.27
P0.27
P1.03
P1.12
P0.00
P0.31
GPIO3
P0.22
P1.12
P1.12
P1.10
P0.05
P0.10
VDDIO
VDD
VDD
VDD
VDDIO
VDD_P0
VDD
GND
GND
GND
GND
GND
GND
GND
Make the following connections on the nPM1300 EK:
Remove all existing connections.
Connect a USB power supply to the J3 connector.
Connect a suitable battery to the J2 connector.
On the P2 pin header, connect VBAT and VBATIN pins with a jumper.
On the P17 pin header, connect all LEDs with jumpers.
On the P13 pin header, connect RSET1 and VSET1 pins with a jumper.
On the P14 pin header, connect RSET2 and VSET2 pins with a jumper.
Note
When using the nRF54L15 DK, the nPM1300 GPIO3 interrupt pin assignment uses the DK’s LED 1 pin.
Building and running
This sample can be found under samples/pmic/native/npm1300_fuel_gauge
in the nRF Connect SDK folder structure.
To build the sample, follow the instructions in Building an application for your preferred building environment. See also Programming an application for programming steps and Testing and optimization for general information about testing and debugging in the nRF Connect SDK.
Note
When building repository applications in the SDK repositories, building with sysbuild is enabled by default.
If you work with out-of-tree freestanding applications, you need to manually pass the --sysbuild
parameter to every build command or configure west to always use it.
Testing
After programming the sample to your development kit, complete the following steps to test it:
Connect the kit to the computer using a USB cable. The kit is assigned a COM port (Windows) or ttyACM device (Linux), which is visible in the Device Manager.
Connect to the kit with a terminal emulator (for example, nRF Connect Serial Terminal). See Testing and optimization for the required settings and steps.
If the initialization was successful, the terminal displays the following message with status information:
PMIC device ok
V: 4.101, I: 0.000, T: 23.06, SoC: 93.09, TTE: nan, TTF: nan
Symbol
Description
Units
V
Battery voltage
Volts
I
Current
Amps (negative for charge, positive for discharge)
T
Temperature
Degrees C
SoC
State of Charge
Percent
TTE
Time to Empty
Seconds (may be NaN)
TTF
Time to Full
Seconds (may be NaN)
Dependencies
The sample uses the following sdk-nrfxlib library:
In addition, it uses the following Zephyr libraries: