I'm trying to read both voltage and current of battery by giving some load. My battery voltage when checked with Multimeter is 3.12v but my code is giving 2.9v. Which register should I read to get current values?
Connection:
Code logic:
Rshunt_lsb = 0.4
shuntVoltage_bytes = i2c.readfrom_mem(addr,__REG_SHUNTVOLTAGE, 2) //shunt resistor- 0x01
shuntVoltage_val = int.from_bytes(shuntVoltage_bytes,'big')
print("Shunt voltage after calculation:",shunt_voltage*Rshunt_lsb/100)
Output:
Shunt register value: 697
Shunt voltage after calculation: 2.784
Shunt register value: 696
Shunt voltage after calculation:2.7
Is my connection and code proper? How should I calculate current?
To calculate current
Current_LSB = 32800
calibration_register = trunc(0.04096/(Current_LSB * Rshunt_lsb))
print(calibration_register) //prints 0
current_register = (shunt_voltage * calibration_register) / 4096 //returns 0 as well
I'm unable to read current, Please help.
Thanks in Advance!