|
| 1 | +.. _npm2100_fuel_gauge: |
| 2 | + |
| 3 | +nPM2100: Fuel gauge |
| 4 | +################### |
| 5 | + |
| 6 | +.. contents:: |
| 7 | + :local: |
| 8 | + :depth: 2 |
| 9 | + |
| 10 | +The Fuel gauge sample demonstrates how to calculate the state of charge of a supported primary cell battery using the `nPM2100 <nPM2100 product website_>`_ and the :ref:`nrfxlib:nrf_fuel_gauge`. |
| 11 | + |
| 12 | +Requirements |
| 13 | +************ |
| 14 | + |
| 15 | +The sample supports the following development kits: |
| 16 | + |
| 17 | +.. table-from-sample-yaml:: |
| 18 | + |
| 19 | +The sample also requires an nPM2100 evaluation kit that you need to connect to the development kit as described in `Wiring`_. |
| 20 | + |
| 21 | +Overview |
| 22 | +******** |
| 23 | + |
| 24 | +This sample allows the calculation of state of charge from a battery connected to the nPM2100 PMIC. |
| 25 | + |
| 26 | +Battery models for Alkaline AA, AAA, LR44, and Lithium-manganese dioxide coin cell CR2032 batteries are included. |
| 27 | +You can change the active battery model using a shell command, as illustrated in `Testing`_. |
| 28 | +You can also change the battery model at compile time using the :kconfig:option:`CONFIG_BATTERY_MODEL` Kconfig option. |
| 29 | + |
| 30 | +Wiring |
| 31 | +****** |
| 32 | + |
| 33 | +With this configuration, the nPM2100 EK is wired to supply power to the DK. |
| 34 | +This ensures that the TWI communication is at compatible voltage levels, and represents a realistic use case for the nPM2100 PMIC. |
| 35 | + |
| 36 | +.. note:: |
| 37 | + |
| 38 | + To prevent leakage currents and program the DK, do not remove the USB connection. |
| 39 | + |
| 40 | + Unplug the battery from the nPM2100 EK and set the DK power switch to "OFF" while applying the wiring described below. |
| 41 | + If you have issues communicating with the DK or programming it after applying the wiring, try to power cycle the DK and EK. |
| 42 | + |
| 43 | +To connect your DK to the nPM2100 EK, complete the following steps: |
| 44 | + |
| 45 | +#. Prepare the DK for being powered by the nPM2100 EK: |
| 46 | + |
| 47 | + .. tabs:: |
| 48 | + |
| 49 | + .. group-tab:: nRF52840 and nRF5340 DKs |
| 50 | + |
| 51 | + * Set switch **SW9** ("nRF power source") to position "VDD". |
| 52 | + * Set switch **SW10** ("VEXT -> VnRF") to position "ON". |
| 53 | + |
| 54 | + .. group-tab:: nRF54L15 DK |
| 55 | + |
| 56 | + * Remove jumper from **P6** ("VDDM CURRENT MEASURE"). |
| 57 | + |
| 58 | +#. Connect the TWI interface and power supply between the chosen DK and the nPM2100 EK as described in the following table: |
| 59 | + |
| 60 | + .. list-table:: nPM2100 EK connections. |
| 61 | + :widths: auto |
| 62 | + :header-rows: 1 |
| 63 | + |
| 64 | + * - nPM2100 EK pins |
| 65 | + - nRF52840 DK pins |
| 66 | + - nRF5340 DK pins |
| 67 | + - nRF54L15 DK pins |
| 68 | + * - SDA |
| 69 | + - P0.26 |
| 70 | + - P1.02 |
| 71 | + - P1.11 |
| 72 | + * - SCL |
| 73 | + - P0.27 |
| 74 | + - P1.03 |
| 75 | + - P1.12 |
| 76 | + * - VOUT |
| 77 | + - P21 External supply |
| 78 | + - P21 External supply |
| 79 | + - P6 VDDM current measure, VDD:nRF pin |
| 80 | + * - GND |
| 81 | + - GND |
| 82 | + - GND |
| 83 | + - GND |
| 84 | + |
| 85 | +#. Make the following connections on the nPM2100 EK: |
| 86 | + |
| 87 | + * Remove the USB power supply from the **J4** connector. |
| 88 | + * On the **P6** pin header, connect pins 1 and 2 with a jumper. |
| 89 | + * On the **BOOTMON** pin header, select **OFF** with a jumper. |
| 90 | + * On the **VSET** pin header, select **3.0V** with a jumper. |
| 91 | + * On the **VBAT SEL** switch, select **VBAT** position. |
| 92 | + * Connect a battery board to the **BATTERY INPUT** connector. |
| 93 | + |
| 94 | +Building and running |
| 95 | +******************** |
| 96 | + |
| 97 | +.. |sample path| replace:: :file:`samples/pmic/native/npm2100_fuel_gauge` |
| 98 | + |
| 99 | +.. include:: /includes/build_and_run.txt |
| 100 | + |
| 101 | + |
| 102 | +Testing |
| 103 | +******* |
| 104 | + |
| 105 | +|test_sample| |
| 106 | + |
| 107 | +#. |connect_kit| |
| 108 | +#. |connect_terminal| |
| 109 | + |
| 110 | +If the initialization was successful, the terminal displays the following message with status information: |
| 111 | + |
| 112 | +.. code-block:: console |
| 113 | +
|
| 114 | + PMIC device ok |
| 115 | + nRF Fuel Gauge version: 1.0.0 |
| 116 | + Fuel gauge initialised for Alkaline AA battery. |
| 117 | + V: 1.188, T: 20.62, SoC: 25.00 |
| 118 | +
|
| 119 | +.. _table:: |
| 120 | + :widths: auto |
| 121 | + |
| 122 | + ====== =============== ================================================== |
| 123 | + Symbol Description Units |
| 124 | + ====== =============== ================================================== |
| 125 | + V Battery voltage Volts |
| 126 | + T Temperature Degrees C |
| 127 | + SoC State of Charge Percent |
| 128 | + ====== =============== ================================================== |
| 129 | + |
| 130 | +Determine the active battery type using the following shell command: |
| 131 | + |
| 132 | +.. code-block:: console |
| 133 | +
|
| 134 | + $ battery_model |
| 135 | + Battery model: Alkaline AA |
| 136 | +
|
| 137 | +Use the same shell command to change the active battery type: |
| 138 | + |
| 139 | +.. code-block:: console |
| 140 | +
|
| 141 | + $ battery_model Lithium_CR2032 |
| 142 | + Fuel gauge initialised for Lithium CR2032 battery. |
| 143 | +
|
| 144 | +Dependencies |
| 145 | +************ |
| 146 | + |
| 147 | +The sample uses the following `sdk-nrfxlib`_ library: |
| 148 | + |
| 149 | +* :ref:`nrfxlib:nrf_fuel_gauge` |
| 150 | + |
| 151 | +In addition, it uses the following Zephyr libraries: |
| 152 | + |
| 153 | +* :ref:`zephyr:logging_api` |
| 154 | +* :ref:`zephyr:shell_api` |
0 commit comments