Im trying to make bms with arduino but cant make it work

in first image it measures voltages on dividers just fine but i want to add arduino instead of multimeters, so i have to put negative sides of dividers to arduino ground and thats where the problem comes since other will get higher voltage and other lower.

can anyone help how i can make it work i've been trying to make bms for weeks but nothing seems to work:(

heres image when dividers negative sides are together

Hi,
How many cells do you want to monitor?

Have you Goolged;

arduino battery management system

Tom.. :smiley: :+1: :coffee: :australia:

2 cells,
those caps act as cells and transistors with diodes will be connected to arduino if i only could make it measure voltage correctly

and i'll google that now

i found on google some article where opamps were used in measuring (no idea what opamp is) but while i was looking at it i got idea that i can use simple math to get cells voltage.

so arduino first measures first cell and then both cells voltage,
so second cell = both voltage - first cell voltage

it works for measure!

but if i make other have more capasitance than other, one cell gets over voltage even when i skipped diodes and just made it shortcut when its at 4.2v?

is it just that tinkercad can't simulate it or am i doing something wrong?

here is code i use

int cell1 = 0;
int cell2 = 0;


void setup()
{
  pinMode(A0,INPUT);
  pinMode(A1,INPUT);
  
  pinMode(2,OUTPUT);
  pinMode(3,OUTPUT);

  Serial.begin(9600);
}


void loop()
{
cell1 = analogRead(A0);
cell2 = analogRead(A1);  

cell1 = cell1/2;
  
cell2 = cell2 - cell1;
  
Serial.print("CELL 1 = ");
Serial.println(cell1);

Serial.print("CELL 2 = ");
Serial.println(cell2);  
  
  
  if (cell1 >= 430){
  digitalWrite(2,HIGH);
  }  else { digitalWrite(2,LOW); }
  
    if (cell2 >= 430){
  digitalWrite(3,HIGH);
  }  else { digitalWrite(3,LOW); }


}

Hi,
I don't know what your experience with electronics is, but this pictorial image doesn't help at all.
Draw (even freehand) a schematic according to electronics standards.
In addition to allowing us to better understand your project, it will also allow you to visualize possible electronics errors.
Despite my long experience in electronics, I could not determine what this component that I marked in your image would be.
forum

it's 4 diodes in series

Hi, @osha22

I assume you are using the diodes in the "Simulation" as some sort of battery source.
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, component names and pin labels.

Hand drawing will allow you to draw the proper symbols for the components you have in your circuit.

Thanks... Tom.. :smiley: :+1: :coffee: :australia:

Where did you get that upside-down diagram from.
Where do the four diodes (~2.6volt) fit in.
A BMS needs an exact voltage reference, like the TL431.
Leo..

diodes are to waste energy as cell hits 4.20v so it wont over charge but instead just warm diodes little

diodes are 1n4001,
all resistors are 470ohm exept in voltage divider 47000ohm,
caps i use for test are 16v and 1000uf.

in vcc i used 8.4v/9v/12v, all gave same result

i made this on breadboard and other cap got 5v and other under 4v,
but if u make it to regulate it to 2-3v it works, both caps have same voltage.?

@ruilviana - heres scemathic

what upsidedown diagram?

diodes are to waste energy as cell hits 4.2v so it wont overcharge

no need for reference voltage as i can code it, or is there?

Drawing conventions are supply on top, ground down, signal left to right.
Your last diagram is far easier to understand.

The bottom transistor barely works, because the base has to overcome the four diode threshold and it's own BE diode threshold. So there won't be significant current flowing until the base is > ~3.3volt. That transistor would work if the diodes were in the collector line, but then there is no current limiting. A resistor would (also) be needed for that.

You power the Nano with 5volt on the V-in pin, which needs a minimum of 6volt to make 5volt for the processor and the output pin. I guess currently the pin outputs no more than about 4volt.

The top transistor won't be working at all. It's base needs 4.2volt + 2.6volt +0.65volt = 7.45volt.
The Arduino pin can't provide that.
Leo..

Hi,
First, put the discharge diodes in the collector circuit instead of the emitter circuit of the 2N5551's.
That way you will get reliable operation of the lower 2N5551.

Now, (with that change) the second 2N5551, it's emitter will be at 4.2V above gnd due to the potential above the lower capacitor, (please use component designators, R1, R2, C1, C2, Q1 etc) so to turn it on you will need 4.2V + 0.7V (Vbe) = 4.9V at the base.
You only have 5V from D3 of the Nano.

So you will probably, in real life, not have enough base current to drive the BJT into conduction.

Are you going to use diodes as the real discharge devices?
Are you only going to do a BMS on capacitors.

Can you please explain what you project is, what hardware, what outcomes?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

This is a common way in BMS circuits, because diodes have a convenient fixed voltage drop.
With only a resistor as discharge load, (current) saturation is a problem.
Leo..

it's for powerbank, i will later add rgb leds, voltage regulator to 5v for usb charging and 20v stepupconverter for laptop charging, i also will replace arduino with atmega168 mcu :slight_smile:

i took diodes out completely cause they just seemed to prevent discharge and used resistor instead,
added bc547 transistor to other discharge transistor and it helped a little but not enought,

now the lower cap stays always on voltage i want (minimium it can keep at is 2.9v),

but if i make it even slightly go over 3v the upper cap just jumps to 5-6v and lower stays in desired voltage.

and i dont get why it works when its set to regulate to under 3v but as soon as voltage goes even a little over 3v other cap jumps to over 5v??

@Wawa

Q5 needs a base voltage of "cap U13 + BE junction of top 2N5551 + BE junction of BC547",
which totals to 5.5volt, which the Arduino can't provide.
Leo..

ohhhh sry i didnt't quite understand what was the problem earlier xd,
but do you have any suggestion how i can overcome that?

I have seen designs with opto couplers.
The opto transistor could drive the power transistor that takes the charge current.

Not sure why you use a low current high voltage transistor.
The opposite would be better.

As said before, a TL431 setup on each battery is commonly used, and safer (not depending on the Arduino.
Leo..

opto couplers, i forgot about their existance :smiley:

and im using 2n5551 cause i have very small amount of those high current transistors so if i blow 1 i will have to get new, but 2n5551, i have dozens of them.

i also use irl 2 in paralell, not 1 like in scemathic.

i dont have TL431 but isnt it just for taking the reference voltage?
if so can i use 3.3v regulator instead ( AMS1117 ).