Measurement of multiple voltages of cells connected in series

Hello, I intend to make a very primitive bms with which I can monitor the voltage of four 18650 batteries connected in series. The problem was that a short circuit was caused when connecting the batteries to the analog pins. The code I used was the following.

#include <math.h>

#define Min 3.5
#define Max 4

double Vnodo1 = 0;
double Vnodo2 = 0;
double Vnodo3 = 0;
double Vnodo4 = 0;
double Bat1 = 0;
double Bat2 = 0;
double Bat3 = 0;
double Bat4 = 0;

void setup() {
  pinMode(7,OUTPUT);
  digitalWrite(7,HIGH);
  Serial.begin(9600);
}

void loop() {
  Vnodo1 = (analogRead(A1)*5.0)/1023;
  delay(10);
  Vnodo2 = (analogRead(A2)*5.0)/1023;
  delay(10);
  Vnodo3 = (analogRead(A3)*5.0)/1023;
  delay(10);
  Vnodo4 = (analogRead(A4)*5.0)/1023;
  delay(10);
  Bat1 = Vnodo1-Vnodo2;
  Bat2 = Vnodo2-Vnodo3;
  Bat3 = Vnodo3-Vnodo4;
  Bat4 = Vnodo4;
  Serial.println(Bat4);
  if (Bat1 < Min || Bat1 > Max || Bat2 < Min || Bat2 > Max || Bat3 < Min || Bat3 > Max || Bat4 < Min || Bat4 > Max){
    digitalWrite(7,LOW);
  }
}

the circuit diagram is attached below, thanks.

battery_circuit.png

battery_circuit.png

Seems to me that apart from the lowest cell in the pic, you're putting over 5V into the analog pins. The top one's getting almost 15V.

What's going into each pin is the sum of the cells from the ground up (to coin a phrase), not the voltage of the last cell only.

The problem was that a short circuit was caused when connecting the batteries to the analog pins. The code I used was the following.

It's not a short circuit. It's an over voltage.
You need to stop and learn basic electronics. What you are doing is pure negligence. It is very obvious that the
voltage of each battery gets added to the previous so only one of them is actually wired correctly (The bottom one)
All of the rest violate every principle of basic electronics and arduino wiring. You shouldn't be wiring things if you
don't know what you are doing. It's fine to post this question. The problem is that you posted it too late, AFTER you
wired it. If you don't know what you are doing then don't do anything until you do. Ask first , then do, not the other
way around. If you were just posting because you wired a led backwards that would be completely different than
what you did. There is a way to accomplish what you are trying to do that involves voltage dividers and math in the
code to calculate the input voltage of each voltage divider.

This is just wrong.

If the batteries are charged:
A3 has 8.6 volts on it (3.6V over the maximum)
A2 has 12.9V on it (7.9V over the maximum)
A1 has 17.2V on it (12.2V over the maximum)

The problem was that a short circuit was caused when connecting the batteries to the analog pins.

You don't have a short, but depending on those resistor values you may have fried the Arduino! ...10K resistors should safely limit the current and then there are small (low current) :"protection diodes" in the ATmega chip to prevent over-voltage.

**What you need is **Voltage Dividers

So, A4 sees 3.7V
A3 sees 7.4V
A2 sees 11.1V
A1 sees 14.8V

And higher if the batteries are charged to 4.2V.

One way you can do this is to use voltage dividers to keep the voltage <=5V.

Your mission: find R1 thru R6 such that V(A1), V(A2), V(A3) do not exceed 5V.
You also want low current draw so the resistors don't excessively drain the batteries.
I'd start with a common value for R2,R4,R6 and calculate for R1, R3, R5. Say 5K.

For example if R5 is 3.9K and R6 is 5K, that V(A3) = 7.4V * 5000/(3900 + 5000) = 4.41V
and if the batteries are fully charged, then V(A3) = 8.4 * 5000/(3900 + 5000) = 5.006, which is higher the 5V reference used by the ADC in an arduino, so the readings will max out at 1023. So, select a different R5 and recalculate,

1 Like

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