2025-06-24 12:06 AM
Hi,
I am having the same issue as this previous forum post, but the question was never answered.
Voltage and temperature sense give expected readings.
REG_VOLTAGE_LOW: 29; REG_VOLTAGE_HIGH:6 --- VOLTAGE: 3818mV
REG_TEMPERATURE_LOW: 186; REG_TEMPERATURE_HIGH:0 --- TEMP: 23 deg
from the datasheet ---> current (mA) = current_code* 11.77 / Rsense (mΩ)
REG_CURRENT_LOW: 203; REG_CURRENT_HIGH: 54 --- CURRENT: 15429mV
Where the actual current for my application is 2.5A. I am using a 10mOhm current sense resistor. Indeed a multimeter reveals 25mV drop across it.
Could somebody please tell me if this is a hardware issue? I have followed all recommendations in the datasheet closely, but cannot find a reason that current is this high. Furthermore, when my application draws only 3.5mA, the current reads 18018mA
Thank you very much.
2025-06-24 12:35 AM
Welcome @rs231, to the community!
If the maximum current to be measured is 2.5A, you should use a shunt of 80mV/2.5A = 32mohms, maybe only 30mohms to have some margin at the top.
Can you insert some schematics as a picture and please also the part of the programme that reads out the STC3100 so that both can be checked?
Regards
/Peter
2025-06-24 7:31 PM - edited 2025-06-24 7:33 PM
Hi Peter,
Thanks for getting back to be quickly!
I noticed that the max voltage is +/- 80mV. Since 2.5A corresponds to 25mV with the 10mOhm shunt, I thought this should be alright?
I will post the code for the working temperature, vs the non-working current. Note unsigned integers are used for now but both values are positive. The environment is C in Zephyr RTOS.
void read_current(void)
{
uint8_t buf[2] = {0};
int ret = i2c_burst_read_dt(&i2c_fuel_gauge, REG_CURRENT_LOW, buf, 2);
if (ret == 0)
{
printk("raw current lower: %d\n", buf[0]);
printk("raw current upper: %d\n", buf[1]);
uint16_t raw_current = (buf[1] << 8) | buf[0];
printk("raw current total: %d\n", raw_current);
int current_mA = raw_current * (1177 / 100) / SENSE_RESISTOR_MILLI_OHMS;
printk("current_mA: %d mA\n", current_mA);
}
else
{
printk("Failed to read battery current: %d\n", ret);
}
}
void read_temp(void)
{
uint8_t buf[2] = {0};
int ret = i2c_burst_read_dt(&i2c_fuel_gauge, REG_TEMPERATURE_LOW, buf, 2);
if (ret == 0)
{
printk("raw temp lower: %d\n", buf[0]);
printk("raw temp upper: %d\n", buf[1]);
uint16_t raw_temp = (buf[1] << 8) | buf[0];
int temp_deg = raw_temp * 125 / 1000;
printk("Fuel Gauge temp %d deg\n", temp_deg);
}
else
{
printk("Failed to read fuel gauge temp: %d\n", ret);
}
}
The schematic is as follows:
Thanks for your help.