Smart battery communication via I2C

Dear community,

I came across a topic discussing communication through Arducopter via I2C for battery parameters, implemented using Arduino. You can find the link below. While following the instructions and using the provided code from that thread, I encountered some issues with the data reflection.

Issue 1: The behavior of the battery capacity used seems abnormal. For instance, when I set the capacity remaining parameter to 2000 and the full charge capacity to 10000 as defined in the parameters, the Bat mah used in Mission Planner shows 6000, but I believe it should be 8000. Similarly, when I set the capacity remaining to 3000 mah, the capacity used shows as 4000. It appears that the capacity used is being calculated by doubling the capacity remaining.

Issue 2: The battery voltage displays 391.68 V even with 0 volts input condition, and when cell voltages are applied, they simply add up to 391.68 V.

All other parameters seem to function correctly. I’m seeking assistance to understand what might be going wrong here. Is it possible that I’m making a mistake, or could there be an existing bug in the code?

Link to older discussion:

Hello,

about issue 1: This was changed after I published the repositry. Apparently there is a capacity scaler implemented in here: ardupilot/libraries/AP_BattMonitor/AP_BattMonitor_SMBus.cpp at master · ArduPilot/ardupilot · GitHub, which gets set to two for the Maxell battery: ardupilot/libraries/AP_BattMonitor/AP_BattMonitor_SMBus_Maxell.h at master · ArduPilot/ardupilot · GitHub Although I’m a bit surprised by your measurements then, because as far as I understand it, the full capacity should also get multiplied by 2…

About the second issue, did you read this?

Thanks for quick reply @Vabe.

Issue-1: Any suggestions how could I handel this?
Issue-2: Yeah, I went through this but couldn’t precisely understand which version is referred here. Can you explain a bit what could be done to solve this issue, please?

Issue 1: Divide the value for full charge capacity and remaining capacity by 2 on the Arduino.
Issue 2: Try a large serial number, I think it has to be greater than 3

Thanks. I will give it a try.
How does “uint16_t full_charge_capacity = 0; //estimated full charge capacity in mAh or 10mWh” works? I do not see any changes in “Battery Used mAh” after setting this.

Battery used mAh shouldn’t change when changing full_charge_capacity, it should change when setting remaining_capacity

Ok. thanks. what’s the use of full_charge_capacity parameter here?

To let the FC know what the full capacity is. Based on this one can calculate the remaining battery percentage and the mAh used