2023-06-09, 03:22 PM
(2023-06-09, 02:15 PM)Tuomas_S Wrote:(2023-06-09, 01:59 PM)Techstyle Wrote:(2023-06-09, 01:22 PM)Tuomas_S Wrote: can confirm, the + sensor cable is only wire in the battery side of shunt. There is a resistor between the terminals but that's it.
I switched the cables other way round to test, but only thing changed was the amperage polarity.
It sounds to me like you have it on the Negative side of the battery?
This is a high-side device, your shunt should be connected to the Positive side of the battery, with Vin+ connected to the Battery side and Vin- connected to the load side (the side that goes to the panel. nothing else should be connected to the battery side of the shunt, all cables (chargers and consumers) should be connected to the load side of the shunt.
Also, ensure you have removed the onboard shunt resistor from the INA219 board?
Everything is wired as per your schema on github, and the onboard resistor has been yanked out. And it is definitively on the + side of things. Other end of shunt goes to battery, other end goes to boat electrical system.
Looks like you have it hooked up right, and you said have current correct, so if you back calculate the Voltage drop across the Shunt (V=IR), do you get the 0.9V? if so you may be looking at "busvoltage" vs "loadvoltage" (the names were not consistent with what I said earlier), here are the definitions:
"ina219_A.getBusVoltage_V()" this equals the voltage available downstream, your Vin-
"ina219_A.getShuntVoltage_mV() / 1000" this equals the drop across the shunt
in my code I call:
Code:
float read_A_loadvoltage_callback() { return (ina219_A.getBusVoltage_V() + (ina219_A.getShuntVoltage_mV() / 1000));}
Code:
ina219_A_loadvoltage->connect_to(new SKOutputFloat("electrical.batteries.A.voltage"));
Code:
ina219_B_current->connect_to(new SKOutputFloat("electrical.batteries.B.current"));
ina219_B_loadvoltage->connect_to(new SKOutputFloat("electrical.batteries.B.voltage"));
//ina219_B_shuntvoltage->connect_to(new SKOutputFloat("electrical.batteries.B.shuntv"));
//ina219_B_busvoltage->connect_to(new SKOutputFloat("electrical.batteries.B.vin-v"));
ina219_B_power->connect_to(new SKOutputFloat("electrical.batteries.B.power"));
ina219_B_loadvoltage->connect_to(new SoCBInterpreter("/Battery B/Voltage/curve"))
->connect_to(new SKOutputFloat("electrical.batteries.B.capacity.stateOfCharge", "/Battery B State of Charge/sk_path"));
hope this helps!!