Go Down

Topic: Arduino Library Issue: Requesting suggestion (Read 2218 times) previous topic - next topic

rmunny

Hello,
I have a query regarding the SparkFun Battery Babysitter - LiPo Battery Manager library with the following link:
https://github.com/sparkfun/Battery_Babysitter

From the manual page 29 (attached), 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:
Code: [Select]
int16_t BQ27441::power(void)
{
return (int16_t) readWord(BQ27441_COMMAND_AVG_POWER);
}


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

Code: [Select]
uint16_t BQ27441::readWord(uint16_t subAddress)
{
uint8_t data[2];
i2cReadBytes(subAddress, data, 2);
return ((uint16_t) data[1] << 8) | data[0];
}


Code: [Select]
// Read a specified number of bytes over I2C at a given subAddress
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?

Code: [Select]
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. But reading data from different offsets sounds confusing and the data I am getting doesn't make sense. I hope to hear back soon. Thanks for your time.

ballscrewbob

It does sound like a question that should be asked on the sparkfun site for a better answer.

It may not be the answer you were looking for but its the one I am giving based on either experience, educated guess, google (who would have thunk it ! ) or the fact that you gave nothing to go with in the first place so I used my wonky crystal ball.

rmunny

Thanks for your response. Actually I asked there also but didn't get any response. In case, if somebody has already worked with this, might help me get the answer as it is an Arduino library.

Juraj

sure is, it is not a suggestion for Arduino project

Go Up