## Introduction: Lipo Cell Monitor and Alarm

Hi,

In this project I will show you how to build a simple Lipo cell Monitor/Alarm for your RC car or drone.

1 - REQUIRED PARTS

- Arduino (prefer micro size).

- 5V Buzzer.

- 5 x 1K resistor.

- 5V regulator.

- Some cables

2 - HOW IT WORKS ?

The idea is simple, we read the voltage of each cell via an Analog pin and then compare it, if the voltage is below a certain limit for more than 5 seconds, the buzzer tones. The only thing to take in consideration here is that the arduino uses 5V so we can't directly put the lipo max voltage in. For this project I'm using a 3S Battery (3 cell battery), so I have to use 2 bridge dividers like so :
- First cell : Connects directly to A0.

- Seoncd two : Add 1K resistor, then the A1 cable, then another 1K resistor connected to GND.

- Third three : Add 2K resistor, A2 cable, 1K resistor to GND.

If you want to add more cell simply add 1K to the first resistor. So for a 4S lipo we have :

3K resistor, then A3 then 1K to GND.

For the buzzer it's pretty simple, connect the GND to GND and the positive to the pin 8.

For portability add a 5V regulator where the GND is connected to GND, input of the regulator to positive of the first cell, and output of the regulator to VIN of the arduino.

and voila, that's it for the hardware.

3 - PROGRAMMING

Let's talk about the code now. It is simple but for the comprehension of everyone I'll explain all the code.

So first of all, we define pins where our cells and buzzer are connected to.

```#define CELL_1 A0
#define CELL_2 A1
#define CELL_3 A2
#define buzzer 8```

Then three variables. They'll contain the current cell voltage in order to compare it.

```float C1;
float C2;
float C3;```

Just after that, we declare another variable, that is our cellLimit voltage, below this value buzzer will tone.

`float cellLimit = 3.3;`

In this case it's 3.3V.

NOTE : Lipo battery should never go under 3V per cell, in this case the limit is a safety margin of 3.3V.

Then we declare a simple variable that will act as a timer, it will prevent false positive for exemple when you have the trhottle up for a moment.

`int count = 0;`

Next the setup, there's nothing really intrusting to explain here, just setting up the serial monitor, this is not an obligation, but for the purpose of debbuging we'll do this.

```void setup() {
Serial.begin(9600);
}```

Next let's enter the loop. I start by calling two functions that I wrote.

```ReadVoltages();
printInfo();```

ReadVoltages is a function that simply reads the analog signal and convert it to volts, we will talk about it later.

And the printInfo function simply prints the result in the serial monitor.

After that we compare the results, if one of the cell is equal or less than the cellLimit variable we increment the counter. If the counter goes to 5 (meaning that we waited enough time) we call a function that will make the buzzer tone. And if the voltage is upper cellLimit we simply set count to 0, then wait for half a second.

```if (C1 < cellLimit || C2 < cellLimit || C3 < cellLimit)  {
count++;
if (count >= 5)
beep(true);
else
beep(false);
}
else
{
count = 0;
}

delay(500);```

The two next functions are the functions used to read and convert the analog signal to volts. We simply convert the analog signal that can be between 0.0 and 1023.0 to volts, and then return the value.

```float ReadVoltageC1(float val){
res = res * (5.0 / 1023.0);
return (res);
}

{
res = (res + 0.10) * (5.0 / 1023.0);
return (res);
}```

This is the function that reads and set cell variables :

```void ReadVoltages(){
}```

The beep function is a bit long, so let's start by the beginning. First we check if we ask the function to tone or not (represented by the variable action, where true = tone and false = stop tone). If action = true then we make the buzzer tone and wait for a moment. Then, we read voltages and print them.
Again in this function we check the current voltage of each cells, if the voltage is below cellLimit, we call beep again with action = true.

NOTE : This is a recursive function. It means that this function will make the buzzer keep beeping if the cells are under cellLimit variable.

And then, if the voltage of each cell is upper than cellLimit we decrease the counter. If it reaches 0 (meaning that we waited enough time), we stop the buzzer and so we go back in the loop function.

Quickly this is the printInfo function :

```void printInfo(){
Serial.println("Cell 1 : " + String(C1) + "V");
Serial.println("Cell 2 : " + String(C2) + "V");
Serial.println("Cell 3 : " + String(C3) + "V");
Serial.println("Count beeper : " + String(count));
}```

4 - CONCLUSION

(Please note that I'm french so if you see any mistakes feel free to tell it to me and I'll fix it !)
Enjoy !