I have code running on my Arduino Uno to get the information from LTC2944 over I2C, but when I port the code to Particle Electron, my readings are 240 (or 1111 0000 in binary).
Do you guys have any idea why I am getting that response?
I have 4.7k I2C pull-ups.
I ran the I2C scanner and I get the response that “I2C device found at address 0x64”, which is good.
I am utilizing the Wire library and the LTC2944 library from here.
My setup includes the following lines.
Wire.setSpeed(CLOCK_SPEED_100KHZ); Wire.stretchClock(true); Wire.begin(); LTC2944_mode = LTC2944_AUTOMATIC_MODE | prescalar_mode | alcc_mode ; ack |= LTC2944_write(LTC2944_I2C_ADDRESS, LTC2944_CONTROL_REG, LTC2944_mode);
My main loop includes the following lines.
// Read 16-bit charge measurement ack |= LTC2944_read_16_bits(LTC2944_I2C_ADDRESS, LTC2944_VOLTAGE_MSB_REG, &voltage_measurement); // Convert voltage reading to Volts batteryState.voltage_V = LTC2944_code_to_voltage(voltage_measurement); Serial.print("Raw Battery Voltage: "); Serial.println(voltage_measurement);
The result is
Raw Battery Voltage: 240