Skip to content

This library interfaces with the Texas Instruments BQ27441 Battery Fuel Gauge using software I2C. This allows the device to be connected to any two available I/O pins instead of the hardware-specific I2C peripheral pins.

License

Notifications You must be signed in to change notification settings

Andy4495/BQ27441_SWI2C

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BQ27441_SWI2C Library

Arduino Compile Sketches Check Markdown Links

This library interfaces with the Texas Instruments BQ27441 Battery Fuel Gauge using software (bit-bang) I2C. This allows the device to be connected to any two available I/O pins instead of the hardware-specific I2C peripheral pins on your microcontroller.

SparkFun has a library available when using hardware I2C.

This library depends on a specific SWI2C library.

Usage

Be sure to review the example sketch included with the library.

  1. Install the SWI2C library in addition to this library.

  2. Include the library header file:

    #include <BQ27441_SWI2C.h>

    Note that this library depends on the SWI2C library.

  3. Instantiate a BQ27441_SWI2C object.

    sda_pin is the pin number for the SDA signal, scl_pin is the pin number for the SCL signal.

    BQ27441_SWI2C myBQ27441(uint8_t sda_pin, uint8_t scl_pin);  // Default I2C address 0x55

    The library assumes an I2C device address of 0x55. If for some reason you need to use a different device address, then a third parameter can be used in the constructor:

    BQ27441_SWI2C myBQ27441(uint8_t sda_pin, uint8_t scl_pin, uint8_t device_address);
  4. Access the various device registers using the library methods listed below.

Library Methods

The library includes specific methods to read the various device values.

Standard Commands (see Technical Reference Chapter 4.2 - 4.19):

uint16_t getTemperature();                  // Result in 0.1 Kelvins
uint16_t getTemperatureC();                 // Result in 0.1 Celsius
int16_t  getTemperatureF();                 // Result in 0.1 Fahrenheit
int16_t  getVoltage();
uint16_t getFlags();
uint16_t getNominalAvailableCapacity();
uint16_t getFullAvailableCapacity();
uint16_t getRemainingCapacity();
uint16_t getFullChargeCapacity();
int16_t  getAverageCurrent();
int16_t  getStandbyCurrent();
int16_t  getMaxLoadCurrent();
int16_t  getAveragePower();
uint16_t getStateOfCharge();
uint16_t getInternalTemperature();            // Result in 0.1 Kelvins
int16_t  getInternalTemperatureC();           // Result in 0.1 Celsius
int16_t  getInternalTemperatureF();           // Result in 0.1 Fahrenheit
uint16_t getStateOfHealth();
uint16_t getRemainingCapacityUnfiltered();
uint16_t getRemainingCapacityFiltered();
uint16_t getFullChargeCapacityUnfiltered();
uint16_t getFullChargeCapacityFiltered();
uint16_t getStateOfChargeUnfiltered();

Extended Data Commands (see Technical Reference Chapter 5.1 - 5.2):

uint16_t getOpConfig();
uint16_t getDesignCapacity();

Control Subcommands (see Technical Reference Chapter 4.1.1 - 4.1.6):

uint16_t getControlStatus();
uint16_t getDeviceType();
uint16_t getFWVersion();
uint16_t getDMCode();
uint16_t getPrevMacwrite();
uint16_t getChemID();

Since this library was designed as a simple interface to use software I2C to access battery status (e.g. voltage, current, temperature), other commands which configure or control the BQ27441 are left unimplemented.

The library also provides access to the underlying SWI2C oject and its public methods. This can be useful for debugging and other specialized situations:

SWI2C*   getSWI2CObject();

References

License

The software and other files in this repository are released under what is commonly called the MIT License. See the file LICENSE in this repository.

About

This library interfaces with the Texas Instruments BQ27441 Battery Fuel Gauge using software I2C. This allows the device to be connected to any two available I/O pins instead of the hardware-specific I2C peripheral pins.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages