Nol.A SDK Library 26.11.2
For IoT System Software Development
Loading...
Searching...
No Matches
BQ27441 Class Reference

BQ27441 battery fuel-gauge interface. Call begin() before other operations. The I2C bus is borrowed and must outlive the driver. More...

#include <SparkFun_BQ27441.hpp>

Public Types

enum  current_measure { AVG , STBY , MAX }
 Parameters for the current() function, to specify which current to read. More...
enum  capacity_measure {
  REMAIN , FULL , AVAIL , AVAIL_FULL ,
  REMAIN_F , REMAIN_UF , FULL_F , FULL_UF ,
  DESIGN
}
 Parameters for the capacity() function, to specify which capacity to read. More...
enum  soc_measure { FILTERED , UNFILTERED }
 Parameters for the soc() function. More...
enum  soh_measure { PERCENT , SOH_STAT }
 Parameters for the soh() function. More...
enum  temp_measure { BATTERY , INTERNAL_TEMP }
 Parameters for the temperature() function. More...
enum  gpout_function { SOC_INT , BAT_LOW }
 Parameters for the setGPOUTFunction() funciton. More...

Public Member Functions

 BQ27441 (TwoWire &, uint8_t addr=I2C_ADDRESS)
bool begin (void)
bool setCapacity (uint16_t capacity)
uint16_t voltage (void)
int16_t current (current_measure type=AVG)
uint16_t capacity (capacity_measure type=REMAIN)
int16_t power (void)
uint16_t soc (soc_measure type=FILTERED)
uint8_t soh (soh_measure type=PERCENT)
uint16_t temperature (temp_measure type=BATTERY)
bool GPOUTPolarity (void)
bool setGPOUTPolarity (bool activeHigh)
bool GPOUTFunction (void)
bool setGPOUTFunction (gpout_function function)
uint8_t SOC1SetThreshold (void)
uint8_t SOC1ClearThreshold (void)
bool setSOC1Thresholds (uint8_t set, uint8_t clear)
uint8_t SOCFSetThreshold (void)
uint8_t SOCFClearThreshold (void)
bool setSOCFThresholds (uint8_t set, uint8_t clear)
bool socFlag (void)
bool socfFlag (void)
uint8_t sociDelta (void)
bool setSOCIDelta (uint8_t delta)
bool pulseGPOUT (void)
uint16_t deviceType (void)
bool enterConfig (bool userControl=true)
bool exitConfig (bool resim=true)
uint16_t flags (void)
uint16_t status (void)

Detailed Description

BQ27441 battery fuel-gauge interface. Call begin() before other operations. The I2C bus is borrowed and must outlive the driver.

Member Enumeration Documentation

◆ capacity_measure

Parameters for the capacity() function, to specify which capacity to read.

71 {
72 REMAIN, // Remaining Capacity (DEFAULT)
73 FULL, // Full Capacity
74 AVAIL, // Available Capacity
75 AVAIL_FULL, // Full Available Capacity
76 REMAIN_F, // Remaining Capacity Filtered
77 REMAIN_UF, // Remaining Capacity Unfiltered
78 FULL_F, // Full Capacity Filtered
79 FULL_UF, // Full Capacity Unfiltered
80 DESIGN // Design Capacity
capacity_measure
Parameters for the capacity() function, to specify which capacity to read.
Definition SparkFun_BQ27441.hpp:71

◆ current_measure

Parameters for the current() function, to specify which current to read.

64 {
65 AVG, // Average Current (DEFAULT)
66 STBY, // Standby Current
67 MAX // Max Current
current_measure
Parameters for the current() function, to specify which current to read.
Definition SparkFun_BQ27441.hpp:64

◆ gpout_function

Parameters for the setGPOUTFunction() funciton.

102 {
103 SOC_INT, // Set GPOUT to SOC_INT functionality
104 BAT_LOW // Set GPOUT to BAT_LOW functionality
gpout_function
Parameters for the setGPOUTFunction() funciton.
Definition SparkFun_BQ27441.hpp:102

◆ soc_measure

Parameters for the soc() function.

84 {
85 FILTERED, // State of Charge Filtered (DEFAULT)
86 UNFILTERED // State of Charge Unfiltered
soc_measure
Parameters for the soc() function.
Definition SparkFun_BQ27441.hpp:84

◆ soh_measure

Parameters for the soh() function.

90 {
91 PERCENT, // State of Health Percentage (DEFAULT)
92 SOH_STAT // State of Health Status Bits
soh_measure
Parameters for the soh() function.
Definition SparkFun_BQ27441.hpp:90

◆ temp_measure

Parameters for the temperature() function.

96 {
97 BATTERY, // Battery Temperature (DEFAULT)
98 INTERNAL_TEMP // Internal IC Temperature
temp_measure
Parameters for the temperature() function.
Definition SparkFun_BQ27441.hpp:96

Constructor & Destructor Documentation

◆ BQ27441()

BQ27441::BQ27441 ( TwoWire & ,
uint8_t addr = I2C_ADDRESS )

Initializes class variables and binds the I2C bus and 7-bit address.

Member Function Documentation

◆ begin()

bool BQ27441::begin ( void )

Initializes I2C and verifies communication with the BQ27441. Must be called before using any other functions.

Returns
true if communication was successful.

◆ capacity()

uint16_t BQ27441::capacity ( capacity_measure type = REMAIN)

Reads and returns the specified capacity measurement

Parameters
typeEnum specifying capacity value to be read
Returns
specified capacity measurement in mAh.

◆ current()

int16_t BQ27441::current ( current_measure type = AVG)

Reads and returns the specified current measurement

Parameters
typeEnum specifying current value to be read
Returns
specified current measurement in mA. >0 indicates charging.

◆ deviceType()

uint16_t BQ27441::deviceType ( void )

Read the device type - should be 0x0421

Returns
16-bit value read from DEVICE_TYPE subcommand

◆ enterConfig()

bool BQ27441::enterConfig ( bool userControl = true)

Enter configuration mode - set userControl if calling from an Arduino sketch and you want control over when to exitConfig.

Parameters
userControlis true if the Arduino sketch is handling entering and exiting config mode (should be false in library calls).
Returns
true on success

◆ exitConfig()

bool BQ27441::exitConfig ( bool resim = true)

Exit configuration mode with the option to perform a resimulation

Parameters
resimis true if resimulation should be performed after exiting
Returns
true on success

◆ flags()

uint16_t BQ27441::flags ( void )

Read the flags() command

Returns
16-bit representation of flags() command register

◆ GPOUTFunction()

bool BQ27441::GPOUTFunction ( void )

Get GPOUT function (BAT_LOW or SOC_INT)

Returns
true if BAT_LOW or false if SOC_INT

◆ GPOUTPolarity()

bool BQ27441::GPOUTPolarity ( void )

Get GPOUT polarity setting (active-high or active-low)

Returns
true if active-high, false if active-low

◆ power()

int16_t BQ27441::power ( void )

Reads and returns measured average power

Returns
average power in mW. >0 indicates charging.

◆ pulseGPOUT()

bool BQ27441::pulseGPOUT ( void )

Pulse the GPOUT pin - must be in SOC_INT mode

Returns
true on success

◆ setCapacity()

bool BQ27441::setCapacity ( uint16_t capacity)

Configures the design capacity of the connected battery.

Parameters
capacityDesign capacity of battery in mAh (unsigned 16-bit value)
Returns
true if capacity successfully set.

◆ setGPOUTFunction()

bool BQ27441::setGPOUTFunction ( gpout_function function)

Set GPOUT function to BAT_LOW or SOC_INT

Parameters
functionshould be either BAT_LOW or SOC_INT
Returns
true on success

◆ setGPOUTPolarity()

bool BQ27441::setGPOUTPolarity ( bool activeHigh)

Set GPOUT polarity to active-high or active-low

Parameters
activeHighis true if active-high, false if active-low
Returns
true on success

◆ setSOC1Thresholds()

bool BQ27441::setSOC1Thresholds ( uint8_t set,
uint8_t clear )

Set the SOC1 set and clear thresholds to a percentage

Parameters
setSet percentage between 0 and 100.
clearClear percentage between 0 and 100; must exceed set.
Returns
true on success

◆ setSOCFThresholds()

bool BQ27441::setSOCFThresholds ( uint8_t set,
uint8_t clear )

Set the SOCF set and clear thresholds to a percentage

Parameters
setSet percentage between 0 and 100.
clearClear percentage between 0 and 100; must exceed set.
Returns
true on success

◆ setSOCIDelta()

bool BQ27441::setSOCIDelta ( uint8_t delta)

Set the SOC_INT interval delta to a value between 1 and 100

Parameters
deltaInterval percentage value between 1 and 100
Returns
true on success

◆ soc()

uint16_t BQ27441::soc ( soc_measure type = FILTERED)

Reads and returns specified state of charge measurement

Parameters
typeEnum specifying filtered or unfiltered measurement
Returns
specified state of charge measurement in %

◆ SOC1ClearThreshold()

uint8_t BQ27441::SOC1ClearThreshold ( void )

Get SOC1_Clear Threshold - threshold to clear the alert flag

Returns
state of charge value between 0 and 100%

◆ SOC1SetThreshold()

uint8_t BQ27441::SOC1SetThreshold ( void )

Get SOC1_Set Threshold - threshold to set the alert flag

Returns
state of charge value between 0 and 100%

◆ SOCFClearThreshold()

uint8_t BQ27441::SOCFClearThreshold ( void )

Get SOCF_Clear Threshold - threshold to clear the alert flag

Returns
state of charge value between 0 and 100%

◆ socfFlag()

bool BQ27441::socfFlag ( void )

Check if the SOCF flag is set in flags()

Returns
true if flag is set

◆ socFlag()

bool BQ27441::socFlag ( void )

Check if the SOC1 flag is set in flags()

Returns
true if flag is set

◆ SOCFSetThreshold()

uint8_t BQ27441::SOCFSetThreshold ( void )

Get SOCF_Set Threshold - threshold to set the alert flag

Returns
state of charge value between 0 and 100%

◆ sociDelta()

uint8_t BQ27441::sociDelta ( void )

Get the SOC_INT interval delta

Returns
interval percentage value between 1 and 100

◆ soh()

uint8_t BQ27441::soh ( soh_measure type = PERCENT)

Reads and returns specified state of health measurement

Parameters
typeEnum specifying filtered or unfiltered measurement
Returns
specified state of health measurement in %, or status bits

◆ status()

uint16_t BQ27441::status ( void )

Read the CONTROL_STATUS subcommand of control()

Returns
16-bit representation of CONTROL_STATUS subcommand

◆ temperature()

uint16_t BQ27441::temperature ( temp_measure type = BATTERY)

Reads and returns specified temperature measurement

Parameters
typeEnum specifying internal or battery measurement
Returns
Raw temperature register in tenths of kelvin; no Celsius conversion is performed.

◆ voltage()

uint16_t BQ27441::voltage ( void )

Reads and returns the battery voltage

Returns
battery voltage in mV

The documentation for this class was generated from the following file: