I am trying to integrate a BQ27531 battery gas gauge into a i.MX6 SoM. I loaded the drivers and everything looks good on the sysfs. When I run cat /sys/bus/i2c/devices/2-0055/power_supply/bq27531-0/temp
, I get a correct value of 247 (which means 24.7°C).
Now, I want to get the value in the Android system. I wrote a simple app that basically calls:
IntentFilter filter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
Intent intent = registerReceiver(null, filter);
int temprature = intent.getIntExtra(BatteryManager.EXTRA_TEMPERATURE, -1);
This should give me the temperature readings, but it is returning 424 (42.4°C). Why is the temperature value wrong? I am sure that the battery is around room temperature.