Battery managment system

So do you know what to do next?

A 12V lead-acid battery has the capacity of 60 Ah which means if 60 A current is drawn by the load, the battery will be able to supplly it for 1 hour before it goes to its final volt (typically: 1.9x6 = 11.4V). At this point, the charger must be auto ON and start constatnt voltage charging of the battery; else, constatnt current boost charge would be required (charging current ~= 60/4 = 15A) for about 3/4 hours to recover the normal life of the battery.

The following schematic (Fig-1, untested) may be helpful for you.


Figure-1:

I specify that I would like to power the circuit from the laptop battery.I got hold of this diagram and this code.

type or paste code here

// Tested and compiled with no errors 
// measuring AC current using ACS712 current sensor 
// The ACS712 works with high voltage AC so be careful ! 
// source - /www.circuitschools.com
 
#include <LiquidCrystal_I2C .h>
 
const int sensorIn = A0;
int mVperAmp = 185; // 5A version SC712 – use 100 for 20A Module or 66 for 30A Module
int Watt = 0;
double Voltage = 0;
double VRMS = 0;
double AmpsRMS = 0;
 
// initialize the LCD library with I2C address and LCD size
LiquidCrystal_I2C lcd (0x3F, 16,2); 
 
void setup() {
Serial.begin (9600);
Serial.println ("ACS712 current sensor");
 
// Initialize the LCD connected 
lcd. init ();
// Turn on the backlight on LCD. 
lcd. backlight ();
lcd.setCursor (0, 0);
lcd.print ("ACS712 current sensor");
 
}
 
void loop() {
 
Serial.println ("");
 
Voltage = getVPP();
VRMS = (Voltage/2.0) *0.707; //root 2 is 0.707 – dealing with sine
AmpsRMS = (VRMS * 1000)/mVperAmp;
 
Serial.print(AmpsRMS);
Serial.print(" Amps RMS — ");
Watt = (AmpsRMS*240/1.2);
// note: 1.2 is my own empirically established calibration factor
// as the voltage measured at A0 depends on the length of the OUT-to-A0 wire
// 240 is the main AC power voltage – this parameter changes locally
Serial.print(Watt);
Serial.println(” W”);
lcd_control ();
 
}
 
// ***** function calls *******
float getVPP()
{
float result;
int readValue; // value read from the sensor
int maxValue = 0; // store max value here
int minValue = 1024; // store min value here
 
uint32_t start_time = millis();
while((millis()-start_time) < 1000) //sample for 1 Sec
{
readValue = analogRead(sensorIn);
// see if you have a new maxValue
if (readValue > maxValue)
{
/*record the maximum sensor value*/
maxValue = readValue;
}
if (readValue < minValue)
{
/*record the minimum sensor value*/
minValue = readValue;
}
}
 
// Subtract min from max
result = ((maxValue – minValue) * 5.0)/1024.0;
 
return result;
}
 
void lcd_control (){
lcd.print (AmpsRMS);
lcd.print (" Amps ");
//Here cursor is placed on first position (col: 0) of the second line (row: 1) 
lcd. setCursor (0, 1);
lcd.print (Watt);
lcd.print (" watt ");
delay (100);
}
how was this code and this diagram supposed to display the voltage on the battery and its charge percentage?

Where are your Battery and Battery Charger?

the battery will be placed in the load position

And what will be a load? The battery is not a load.

I doesn't and it can't
He assumed the voltage was 240VAC and then divided that by a magic number to make the numbers come out right.
This is a very bad tutorial!

I'd say this is a fairly simple project, but the only advice I'll give is to break it down into bite sized chunks.
Pick something. Say the LCD. Now trawl the interweb for tutorials on hooking up an LCD to an UNO and displaying something.
Monitoring the voltage of a single cell, 3.6V nominal Li-ion is also simple. Google should bring up a host of ideas and there's many Arduino tutorials on reading battery voltages on the web, so give something a try. Read a voltage (analog input perhaps?) and print it to the serial monitor.
As for reading small currents that you are likely to draw from the cell, an INA219 is a good choice. The ACS712 is also good and very easy to use. Again, there are loads of tutorials online.
I think that for a charging module, I'd start with a TP4056. They're cheap and easy to use. But if you intend to charge and discharge at the same time then it's worth also reading up about how to add a 'power path'.
Once you have each individual sensor/device working individually, put the code and the circuit together.
That's pretty much how I learned. Really nothing to gain just by copying and pasting code given to you. And it's way more satisfying to figure it out yourself than just rely on the hard work of others.
If/when you've tried your best, but still have issues then most of the guys here will be happy to help you fine tune things, but they'll make you work for it :laughing: but this is a good thing as it'll help you understand exactly how it all works and goes together, so it'll all be a step easier for the next project.
For the record, I'm speaking from experience. I went through hundreds of examples and tutorials before I dared to ask anyone on here for assistance. But because I'd had a good go on my own first, then they really helped me out
Cheers
Matt

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