I am having difficulty reading data from the bq34z100EVM over I2C. I am using an Arduino Mega and have connected SDA to SDA, SCL to SCL and made sure both devices are sharing a ground. However, I cannot seem to read any of the device's statuses, such as the StateofCharge() or Voltage(). The manual confuses me and I was hoping someone might be able to explain to me step-by-step what bits need to be sent to the chip.
I have been able to get two Arduinos communicating over I2C using the Wire library, so I know that part is working, but I don't seem to understand the procedure for communicating with the bq34z100. Also, I have successfully connected the bq34z100 with the TI evaluation software, calibrated it, and discharged and charged a battery pack through it with the values updating as expected, so I don't believe there is anything wrong with my EVM.
Right now I am sending the address, then the two bytes of command and code and then writing the receive address and trying to read to bytes. So to get the StateofCharge():
Send --> 0xAA, 0x02, 0x03, 0xAB
The relevant Arduino code, using the Wire library is:
void loop()
{
Wire.beginTransmission(0xAA); // Transmits device address
Wire.write(0x02); // Transmit command
Wire.write(0x03); // Transmit code
Wire.endTransmission();
delay(0.1); // 100us delay; have read from another user on the forum that at least 40us is required between sending and receiving
Wire.requestFrom(0xAB, 2); // Send device address (with read bit high) and indicate two bytes to be received
// Wait for bytes and print out to the terminal
while(Wire.available())
{
char c = Wire.read();
Serial.print('y');
}
delay(500); // Delay for 500 ms, allow for data to be received and written to terminal
}
Am I going about this the right way?