Can you help me replicate this for 3.2V LiFePO 4 battery that has 27000mAh? Battery Management System | State of Charge (SOC) | State of Health (SOH) - YouTube specially the SOC and SOH part.
Can you post the code and circuit, saves everyone having to watch the Video .......................
Here's the code I am using for the voltage, current and temperature sensors (not including the SOC and SOH, the video didn't provide any code)
// Floats for ADC voltage & Input voltage
float adc_voltage = 0.0;
float in_voltage = 0.0;
// Floats for resistor values in divider (in ohms)
float R1 = 30000.0;
float R2 = 7500.0;
// Float for Reference Voltage
float ref_voltage = 5.0;
// Integer for ADC value
int adc_value = 0;
// Variables for Measured Voltage and Calculated Current
double Vout = 0;
double Current = 0;
const double scale_factor = 0.066; // 30A
const double vRef = 5.00;
const double resConvert = 1024;
double resADC = vRef/resConvert;
double zeroPoint = vRef/2;
void setup(){
// Setup Serial Monitor
Serial.begin(9600);
Serial.println("BMS");
}
void loop(){
// Read the Analog Input
adc_value = analogRead(A0);
// Determine voltage at ADC input
adc_voltage = (adc_value * ref_voltage) / 1024.0;
// Calculate voltage at divider input
in_voltage = adc_voltage / (R2/(R1+R2));
// Print results to Serial Monitor to 2 decimal places
Serial.print("Input_Voltage = ");
Serial.print(in_voltage, 2);
Serial.print(" V ");
// Vout is read 1000 Times for precision
for(int i = 0; i < 1000; i++) {
Vout = (Vout + (resADC * analogRead(A1)));
delay(1);
}
// Get Vout in mv
Vout = Vout /1000;
// Convert Vout into Current using Scale Factor
Current = (Vout - zeroPoint)/ scale_factor;
// Print Vout and Current to two Current = ");
Serial.print("Input_Current = ");
Serial.print(Current,2);
Serial.print(" A ");
//Multiply voltage and current to get power
float power = in_voltage*Current;
Serial.print("Power= ");
Serial.print(power,2);
Serial.print(" W ");
// Get a reading from the temperature sensor:
int reading = analogRead(A3);
// Convert the reading into voltage:
float voltage = reading * (5000 / 1024.0);
// Convert the voltage into the temperature in degree Celsius:
float temperature = voltage / 10;
// Print the temperature in the Serial Monitor:
Serial.print("Temperature = ");
Serial.print(temperature);
Serial.print(" \xC2\xB0"); // shows degree symbol
Serial.println("C");
delay(1000);
}
Here's the schematic (from the video) it just composes of Voltage Divider, ACS712 current sensor and lm35 temperature sensor
Well SOH (State of Health) implies that your are measuring how many mAHr is drawn from the battery, versus a voltage drop as in the SOC (State of Charge). And then comparing the measured results from a known good battery, not so easy.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.