Battery SOC & SOH

Hi everyone! I wanted to create a battery monitoring system using Arduino Nano. I am searching for codes to measure SOC and SOH of battery but I failed. I've read some in this forum and some other forums but I cannot find decent and working codes.

This is one of the codes I found but this is only for SOC and it is only printing 0.7 on serial monitor

// Assume current coming from serial port

const float C_per_Ah = 3600;

// signal adjustment
const float current_scale_A = 0.1; // Ampere per serial step
const int current_offset = 128; // Offset of serial value for I=0A


float CBat_Ah = 94;  /* Assumed Battery Capacity in Ah */
float Cbat_C = CBat_Ah * C_per_Ah; /* ... in Coulomb */

float SOC = 0.7; /* Initial State of Charge */

int incomingByte = current_offset; // for incoming serial data, initial 0 Ampere
float I = 0; /* current */

// the setup routine runs once when you press reset:
void setup() 
{
    Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
}


// the loop routine runs over and over again forever:
void loop() 
{
  delay(1000);               // wait for a second

  if (Serial.available() > 0) 
  {
    // read the incoming byte:
    incomingByte = Serial.read();
  }
  I = (incomingByte-current_offset) * current_scale_A;

  SOC = SOC + I/Cbat_C;
  Serial.print("New SOC: ");
  Serial.println(SOC, 4);
}

This is the one closest to what I am trying to do

but when I contacted the owner, It cost a lot and I cant afford it so I am hoping to get some help.

Why? Generally these can only be indications. You would need to fully charge cycle the battery to get a better estimate, then monitor all the environmental variables ...

So why not just use the terminal voltage as an indication?

How am I going to implement it in arduino?

Like this

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.