katarinak998
Published

Li-Ion battery measurement system

Hardware and software for voltage, current, capacity and temperature measurements of Li-Ion battery.

IntermediateFull instructions provided4,871
Li-Ion battery measurement system

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
LM35 temperature sensor
×1
Hall effect sensor ACS724
×1
LCD 16x2 display
×1
LCD I2C driver
×1
Voltage regulator B8A325
×1
DC motor
×1
Li-Ion charger TC4056A
×1
Rocker Switch, SPST
Rocker Switch, SPST
×2
Resistor 10k ohm
Resistor 10k ohm
×2
Li-Ion 1500mAh battery
×1
Arduino Mega 2560
Arduino Mega 2560
×1
Breadboard (generic)
Breadboard (generic)
×1

Hand tools and fabrication machines

Arduino IDE

Story

Read more

Schematics

Hall effect sensor, DC motor, Li-Ion battery and Arduino Nano

Wiring Hall effect sensor, DC motor, Li-Ion battery and Arduino Nano

Temperature sensor LM35 and Arduino Nano

Wiring Temperature sensor LM35 and Arduino Nano

LCD display with I2C driver and Arduino Nano

Wiring LCD display with I2C driver and Arduino Nano

Voltage regulator, battery, battery charger and Arduino Nano

Wiring Voltage regulator, battery, battery charger and Arduino Nano

Voltage divider for voltage measurment

Complete scheme

Scheme with added switches, one for turning ON and OFF complete hardware and second one for DC motor only. There is Arduino Mega for Serial connection too.

Code

Code

Arduino
#include <LiquidCrystal.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
#include <MillisTimer.h>

#include <SoftwareSerial.h>

SoftwareSerial mySerial(8, 7); // RX, TX

#define HallS A2; //pin Hallovog senzora 
#define LM35 A1; // pin  temperaturnog senzora
#define cellPin A0; //pin  baterije



float temperatura;  //varijabla u koju pohranjujemo temperaturu
float vout;  //trenutna  varijabla za očitanje senzora temperature
float V;    // varijabla napona kojega očitava Hallov senzor s A2 pina
float ImA; // Varijabla struje u miliamperima
float IA;    // varijabla struje u amperima
float v;      // varijabla napona baterije
float mv = 0;    //napon baterije u milivoltima
const float mvc = 5; // napon rada mikrokontrolera
float uzorci = 0;
float Capacity = 0.0;  // varijabla kapaciteta
unsigned long previousMillis = 0; // prethodno vrijeme u ms
unsigned long millisPassed = 0;  // trenutačno vrijeme u ms


void setup()
{
  pinMode(A1, INPUT); // Configuring pin A1 as input
  Serial.begin(9600);
  lcd.init();
  lcd.backlight();

  mySerial.begin(9600);

  delay(1000);

}


void loop()

{

  //MJERENJE TEMPERATURE
  vout = analogRead(A1);
  vout = (vout * 500) / 1023;

  temperatura = vout; // temperatura u stupnjevima celzijusevim


  Serial.print("temp=");
  Serial.print(temperatura);
  Serial.print(" °C\n");

  mySerial.print("temp=");
  mySerial.print(temperatura);
  mySerial.println(" °C\n");


  delay(1000); //Delay of 1 second for ease of viewing in serial monitor




  //MJERENJE STRUJE


  V = analogRead(A2); //očitavanje napona s pina A2
  delay(10);

  V = (V / 1023) * 5;                                              // prebacivanje digitalne ADC vrijednosti u napone
  V = V - 2.500;                                                   // Subtract the zero current value Nominally 2.500V
  V = V * 1000;                                                    // pretvaranje napona iz volta u milivolte
  ImA = abs((V / 400) * 1000); // prebacaivanje napona sa senzora u struju
  IA = ImA / 1000;
  Serial.print("ImA = "); Serial.print(ImA); Serial.println(" mA\n");
  if (IA < 0.01) {
    lcd.setCursor(7, 0);  //ispis struje
    lcd.print("noCurrent");

  }

  mySerial.print("ImA=");
  mySerial.print(ImA);
  mySerial.println("mA\n");

  delay(1000);

  //MJERENJE NAPONA


  uzorci = analogRead(A0);
  mv = uzorci * mvc;
  v = mv / 1000;
  Serial.print("V="); Serial.print(String(v)); Serial.print("V\n");

  mySerial.print("V=");
  mySerial.print(v);
  mySerial.println("V\n");


  delay(100);

  //MJERENJE KAPACITETA


  if ( mv > 4400 ) {

    //Serial.println( "Warning High-V! ");

    lcd.setCursor(0, 1);
    lcd.print("HIGH-V");



    //delay(1000);
  }

  else if (mv < 3000) {

    Serial.println( "Warning Low-V! ");

    lcd.setCursor(0, 1);
    lcd.print("LOW-V");

    delay(1000);
  }
  else if (mv > 3000 && mv < 4300  ) { // provjera je li napon baterije u sigurnim granicama

    millisPassed = millis() - previousMillis;

    Capacity = Capacity + ImA * (millisPassed / 3600000.0); // 1 Hour = 3600000ms
    previousMillis = millis();
    Serial.print("C=");
    Serial.print(Capacity);
    Serial.print("mAh\n");

    mySerial.print("C= ");
    mySerial.print(Capacity);
    mySerial.println(" mAh\n");

    lcd.begin(16, 2);                       //ispis kapaciteta na LCD
    lcd.setCursor(7, 1);
    lcd.print(Capacity, 1);
    lcd.print("mAh");


    lcd.setCursor(0, 1);   //ispis napona
    lcd.print(v, 1);
    lcd.print("V");

    lcd.setCursor(7, 0);  //ispis struje
    lcd.print(ImA, 0);
    lcd.print("mA");


    lcd.setCursor(0, 0);   //ispis temperature
    lcd.print(temperatura, 0);
    lcd.print("*C");





  }


  delay(1000);

Credits

katarinak998

katarinak998

0 projects • 0 followers

Comments