|
| 1 | +.. zephyr:code-sample:: fuel_gauge |
| 2 | + :name: Fuel Gauge |
| 3 | + |
| 4 | + fuel gauge driver API usage. |
| 5 | + |
| 6 | +Overview |
| 7 | +******** |
| 8 | + |
| 9 | +This sample shows how to use the Zephyr :ref:`fuel_gauge_api` API driver for. |
| 10 | + |
| 11 | +First, the sample tries to read all public fuel gauge properties to verify which are supported by |
| 12 | +the used fuel gauge driver. |
| 13 | +Second, the sample then reads the battery percentage and voltage proper periodically using the |
| 14 | +``FUEL_GAUGE_RELATIVE_STATE_OF_CHARGE`` and ``FUEL_GAUGE_VOLTAGE`` properties. |
| 15 | + |
| 16 | +.. note:: |
| 17 | + The sample does not set/write any properties to avoid misconfiguration the IC. |
| 18 | + |
| 19 | +Building and Running |
| 20 | +******************** |
| 21 | + |
| 22 | +The sample can be configured to support a fuel gauge. |
| 23 | + |
| 24 | +Features |
| 25 | +******** |
| 26 | +By using this fuel gauge you can get the following information: |
| 27 | + * Read all public fuel gauge properties except ``FUEL_GAUGE_BATTERY_CUTOFF`` |
| 28 | + * Battery charge status as percentage (periodically) |
| 29 | + * Battery voltage (periodically) |
| 30 | + |
| 31 | +Sample output |
| 32 | +************* |
| 33 | + |
| 34 | +``` |
| 35 | +*** Booting Zephyr OS build f95fd665ad26 *** |
| 36 | +[00:00:00.116,000] <inf> app: Found device "lc709203f@0b" |
| 37 | +[00:00:00.116,000] <inf> app: Test-Read generic fuel gauge properties to verify which are supported |
| 38 | +[00:00:00.116,000] <inf> app: Info: not all properties are supported by all fuel gauges! |
| 39 | +[00:00:00.116,000] <inf> app: Property "FUEL_GAUGE_AVG_CURRENT" is not supported |
| 40 | +[00:00:00.116,000] <inf> app: Property "FUEL_GAUGE_CURRENT" is not supported |
| 41 | +[00:00:00.116,000] <inf> app: Property "FUEL_GAUGE_CHARGE_CUTOFF" is not supported |
| 42 | +[00:00:00.116,000] <inf> app: Property "FUEL_GAUGE_CYCLE_COUNT" is not supported |
| 43 | +[00:00:00.116,000] <inf> app: Property "FUEL_GAUGE_CONNECT_STATE" is not supported |
| 44 | +[00:00:00.116,000] <inf> app: Property "FUEL_GAUGE_FLAGS" is not supported |
| 45 | +[00:00:00.116,000] <inf> app: Property "FUEL_GAUGE_FULL_CHARGE_CAPACITY" is not supported |
| 46 | +[00:00:00.116,000] <inf> app: Property "FUEL_GAUGE_PRESENT_STATE" is not supported |
| 47 | +[00:00:00.116,000] <inf> app: Property "FUEL_GAUGE_REMAINING_CAPACITY" is not supported |
| 48 | +[00:00:00.116,000] <inf> app: Property "FUEL_GAUGE_RUNTIME_TO_EMPTY" is not supported |
| 49 | +[00:00:00.116,000] <inf> app: Property "FUEL_GAUGE_RUNTIME_TO_FULL" is not supported |
| 50 | +[00:00:00.116,000] <inf> app: Property "FUEL_GAUGE_SBS_MFR_ACCESS" is not supported |
| 51 | +[00:00:00.116,000] <inf> app: Property "FUEL_GAUGE_ABSOLUTE_STATE_OF_CHARGE" is not supported |
| 52 | +[00:00:00.122,000] <inf> app: Property "FUEL_GAUGE_RELATIVE_STATE_OF_CHARGE" is supported |
| 53 | +[00:00:00.122,000] <inf> app: Relative state of charge: 100 |
| 54 | +[00:00:00.122,000] <err> lc709203f: Thermistor not enabled |
| 55 | +[00:00:00.122,000] <inf> app: Property "FUEL_GAUGE_TEMPERATURE" is not supported |
| 56 | +[00:00:00.123,000] <inf> app: Property "FUEL_GAUGE_VOLTAGE" is supported |
| 57 | +[00:00:00.123,000] <inf> app: Voltage: 4190000 |
| 58 | +[00:00:00.124,000] <inf> app: Property "FUEL_GAUGE_SBS_MODE" is supported |
| 59 | +[00:00:00.124,000] <inf> app: SBS mode: 1 |
| 60 | +[00:00:00.124,000] <inf> app: Property "FUEL_GAUGE_CHARGE_CURRENT" is not supported |
| 61 | +[00:00:00.124,000] <inf> app: Property "FUEL_GAUGE_CHARGE_VOLTAGE" is not supported |
| 62 | +[00:00:00.124,000] <inf> app: Property "FUEL_GAUGE_STATUS" is not supported |
| 63 | +[00:00:00.124,000] <inf> app: Property "FUEL_GAUGE_DESIGN_CAPACITY" is supported |
| 64 | +[00:00:00.124,000] <inf> app: Design capacity: 500 |
| 65 | +[00:00:00.124,000] <inf> app: Property "FUEL_GAUGE_DESIGN_VOLTAGE" is not supported |
| 66 | +[00:00:00.124,000] <inf> app: Property "FUEL_GAUGE_SBS_ATRATE" is not supported |
| 67 | +[00:00:00.124,000] <inf> app: Property "FUEL_GAUGE_SBS_ATRATE_TIME_TO_FULL" is not supported |
| 68 | +[00:00:00.124,000] <inf> app: Property "FUEL_GAUGE_SBS_ATRATE_TIME_TO_EMPTY" is not supported |
| 69 | +[00:00:00.124,000] <inf> app: Property "FUEL_GAUGE_SBS_ATRATE_OK" is not supported |
| 70 | +[00:00:00.125,000] <inf> app: Property "FUEL_GAUGE_SBS_REMAINING_CAPACITY_ALARM" is not supported |
| 71 | +[00:00:00.125,000] <inf> app: Property "FUEL_GAUGE_SBS_REMAINING_TIME_ALARM" is not supported |
| 72 | +[00:00:00.125,000] <err> app: Error: cannot get property "FUEL_GAUGE_MANUFACTURER_NAME": -88 |
| 73 | +[00:00:00.125,000] <err> app: Error: cannot get property "FUEL_GAUGE_DEVICE_NAME": -88 |
| 74 | +[00:00:00.125,000] <err> app: Error: cannot get property "FUEL_GAUGE_DEVICE_CHEMISTRY": -88 |
| 75 | +[00:00:00.125,000] <inf> app: Property "FUEL_GAUGE_CURRENT_DIRECTION" is supported |
| 76 | +[00:00:00.125,000] <inf> app: Current direction: 0 |
| 77 | +[00:00:00.126,000] <inf> app: Property "FUEL_GAUGE_STATE_OF_CHARGE_ALARM" is supported |
| 78 | +[00:00:00.126,000] <inf> app: State of charge alarm: 8 |
| 79 | +[00:00:00.127,000] <inf> app: Property "FUEL_GAUGE_LOW_VOLTAGE_ALARM" is supported |
| 80 | +[00:00:00.127,000] <inf> app: Low voltage alarm: 0 |
| 81 | +[00:00:00.127,000] <inf> app: Polling fuel gauge data 'FUEL_GAUGE_RELATIVE_STATE_OF_CHARGE' & 'FUEL_GAUGE_VOLTAGE' |
| 82 | +[00:00:00.128,000] <inf> app: Fuel gauge data: Charge: 100%, Voltage: 4190mV |
| 83 | +[00:00:05.130,000] <inf> app: Fuel gauge data: Charge: 100%, Voltage: 4190mV |
| 84 | +[00:00:10.131,000] <inf> app: Fuel gauge data: Charge: 100%, Voltage: 4190mV |
| 85 | +``` |
0 commit comments