Giter VIP home page Giter VIP logo

sparkfun_bq27441_arduino_library's Introduction

SparkFun BQ27441-G1A LiPo Fuel Gauge Arduino Library

SparkFun Battery Babysitter

SparkFun Battery Babysitter (featuring the BQ27441-G1A LiPo Fuel Gauge) (PRT-13777)

Texas Instrument's BQ27441-G1A is a self-calibrating, I2C-based fuel gauge for lithium polymer (LiPo) batteries -- it measures your battery's voltage to estimate its charge percentage and remaining capacity. The chip is also hooked up to a current-sensing resistor, which allows it to measure current and power! The fuel gauge makes up half of the SparkFun Battery Babysitter.

This Arduino library abstracts away all of the low-level I2C communication, so you can easily initialize the fuel gauge then read voltage, state-of-charge, current, power, and capacity. It also implements all of the chip's low-battery, and SoC-change alerts on the GPOUT pin.

Thanks to:

  • keton for adding extended config methods and an example showing how to use them

Repository Contents

  • /examples - Example sketches for the library (.ino). Run these from the Arduino IDE.
  • /src - Source files for the library (.cpp, .h).
  • keywords.txt - Keywords from this library that will be highlighted in the Arduino IDE.
  • library.properties - General library properties for the Arduino package manager.

Documentation

Products that use this Library

Version History

  • 1.0.0 - Initial release of the BQ27441 Arduino Library.

License Information

This product is open source!

Please review the LICENSE.md file for license information.

If you have any questions or concerns on licensing, please contact [email protected].

Distributed as-is; no warranty is given.

  • Your friends at SparkFun.

sparkfun_bq27441_arduino_library's People

Contributors

keton avatar nseidle avatar per1234 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sparkfun_bq27441_arduino_library's Issues

No need to wait for data after Wire.requestFrom()

When the Wire.requestFrom() returns, the I2C transaction has completely finished and the received data is in the receive buffer of the Wire library. The Wire.read() only reads the data from that buffer.

The waiting with the delay is not needed.

Query regarding data from class power

Hello,
From the manual page 29 https://www.ti.com/lit/ug/sluuac9a/sluuac9a.pdf?ts=1594252976133&ref_url=https%253A%252F%252Fwww.google.com%252F I see that power is under Subclass 68, and hibernate I and V can be read from offset 7 and 9. Now in the example BQ27441_Basic, power data is got by calling the function power() which is as following:

int16_t BQ27441::power(void) { return (int16_t) readWord(BQ27441_COMMAND_AVG_POWER); }

The readword() and i2cReadBytes() functions are as following:

uint16_t BQ27441::readWord(uint16_t subAddress)
{
	uint8_t data[2];
	i2cReadBytes(subAddress, data, 2);
	return ((uint16_t) data[1] << 8) | data[0];
}
int16_t BQ27441::i2cReadBytes(uint8_t subAddress, uint8_t * dest, uint8_t count)
{
	int16_t timeout = BQ72441_I2C_TIMEOUT;	
	Wire.beginTransmission(_deviceAddress);
	Wire.write(subAddress);
	Wire.endTransmission(true);
	
	Wire.requestFrom(_deviceAddress, count);
	
	for (int i=0; i<count; i++)
	{
		dest[i] = Wire.read();
	}
	
	return timeout;
}

My questions are:

  1. The power() function is reading 2 bytes so which 2 bytes it is reading (Hibernate I at offset 7 or Hibernate V at offset 9)?

  2. In the BQ27441_Basic.ino how can, it is reporting power in mW just by reading Hibernate I or Hibernate V?
    int power = lipo.power(); // Read average power draw (mW)

  3. If I want to see both the Hibernate I at offset 7 and Hibernate V at offset 9, how should I modify the library to print the individual data of Hibernate I at offset 7 and Hibernate V at offset 9 and also the power?

Please correct me if I am wrong. Thanks for your time.

setSOC1Thresholds(SOCI_SET, SOCI_CLR) failing?

By using and adapting the BQ27441_GPOUT_BAT_LOW example, there seems to be a problem with setSOC1Thresholds(SOCI_SET, SOCI_CLR).

Whatever will be defined as const byte SOCI_SET (as well as const byte SOCI_CLR), the BQ27441 stay always to use and report with BQ27441::SOC1SetThreshold(void) a threshold value of 60%.

Any idea what's wrong there?

Thanks a lot in advance!

setSOC1Thresholds(SOCI_SET, SOCI_CLR) fail

Hi there!
I arize the problem again.
This problem still exists in both libraris:
SparkFun_BQ27441_Arduino_Library
and
Battery_Babysitter
To reproduce, just run BQ27441_GPOUT_BAT_LOW.ino
You'll see that SOC1SetThreshold() funtion allways return 64(0x40).

I observe this on three bq27441 chips.

My uC ATSAMD51 in WIO Terminal.

Battery state-of-charge (%) always at 100%

hello
Thank for this Drivers.
battery of 2600Mah 3.6V

with the basic example , I see the voltage decrease according to my mesurement
but the state-of-charge (%) stay at 100 %

do you have an idea Why iy=t is stay at 100% please ?

thank you

Correct BATTERY_CAPACITY configuration

In the BQ27441_Extended_Configuration example lipo.setCapacity(BATTERY_CAPACITY) command executed
AFTER entering config mode(lipo.enterConfig()),
while in the BQ27441_Basic example it executed WITHOUT entering config mode.
Is it correct?

mistake inside enterConfig() function

on this line:
while ((timeout--) && (!(status() & BQ27441_FLAG_CFGUPMODE)))

status() should be replaced with flags()

correct line:
while ((timeout--) && (!(flags() & BQ27441_FLAG_CFGUPMODE)))

please fix,
thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.