Can I monitor 4 lifepo4 cells wired in series with an arduino and power the arduino with the first cell in the series?
Here is a diagram of what I have in mind. The first cell will power the arduino to pin Vin. The other four cells are wired in series. I will tap the positive post of each individual cell and run that through four separate voltage dividers. All voltage dividers using a 2k and 1k resistor. This should prevent the 14.6 max voltage of the pack from damaging the arduino by going over 5v on the analog pins.
Each output of the voltage dividers will go to a separate analog pin where I can get a reading.
Diagram below:
Seems too simple to work so I’m guessing I’m missing something. Thanks!
Not with analogreference being VCC, as this is the first cell, that you want to measure.
So you will have to use the internal fixed voltage reference (depends on which Arduino you use). You will then have to calculate your voltage divider resistors so that the highest voltage per cell will not become more than the voltage of the fixed voltage reference.
[edit]
If you tap from the second (or third) cell, you can do it, as then the arduino will work from 5V, assuming it has a 5V regulator on board. If the 2 cells combined can go below 5V + dropout voltage of the regulator, then better use the 3rd cell, or your 5V will start to sink when the first two cells get depleted. And then you won't notice as your VCC reference is then sinking.
So, if I am planning to use the uno. The voltage reference is 3.3v. If I change the resistor value to 5K and 1.2k. This would make the highest voltage seen from the 14.6v max 2.83. Couldn’t I calculate the voltages of each cell this way?
3.3V?? Where do you get that from? The Atmega328 from the UNO can have VCC as reference or the internal 1.1V reference. I don't think it has a 3.3V reference
@neketege88 if you look at the related topics at the end of the page you will see some of the many times this has been discussed. These contain several solutions you might like to consider, as your proposal as described will not work.
14.6 / 4 = 3.65volt, which is the max charge/float voltage of a LiFePo4 cell.
OP should power the Arduino from the full pack voltage instead of two or three cells, to prevent unequal discharge of the pack (bad). This can be done with a 5volt buck converter, connected to the 5volt pin (not the V-in pin). Use a tiny one with low idle drain. The voltage divider resistors should be 100x or 1000x the value, to minimise uneven discharge (of the lowest cell). Each analogue input should have a 100n ceramic cap to ground.
Leo..
Your idea is OK, but the voltage dividers are wrong.
If you measure between ground and the points between the cells you will see, in a full charged stack of LiFe something like
0 .. 3.65 .. 7.30 .. 10.95 .. 14.6
in a 4S battery.
Each voltage divider must be calculated to give you 1.1 volts for its corresponding analog input.
Use the 1.1 volt internal reference. It is stable but varies, so plan on calibration of some kind, software is easiest, but dividers made of two resistors and a trimmer potentiometer can work.
Be sure to aim the voltage dividers for the lowest voltage the 1.1 reference can actually be.
Typing while this came in. I agree. Typical voltage measuring tools for r/c power themselves from the battery variously, and draw some current. Usually measurement is brief and low power compared to the actual use case, so it might not be terribly important, I still would go that way with the buck regulator.
Thanks for all the help. I understand most of what you all are saying. These are indeed LiFePO4 cells. I understand powering the arduino with only one cell vs the entire pack will cause the one cell to discharge quicker and lead to an out of balance pack, but these are large 105Ah prismatic cells. I didn't think the minimal draw of the arduino would matter that much because I plan to have the arduino on a switch that I only will power on for a few minutes each time I use. However, I do see where that is best practice, and I will add the buck converter.
I'm not sure I understand this? A higher value means more efficient? Is that what you mean?
I most definitely had the reference voltage for the uno wrong. So, my calculations would be to prevent the voltages coming from the voltage divider to the analog pin from each cell exceeding 1.1v. I assume the resistors do not need the same value for each cell? But, wouldn't this make my calculations easier?
It seems that for cells ranging from 3.65 (cell 1) to 14.6, (voltage from ground to the fourth positive cell) I could use a 2M resistor and a 150K resistor for each cell and tap the center of the two resistors. This should give my analog input a range of voltage between .255V to 1.019V.
Does this look closer to being correct?
Does it need to be calculated to give me 1.1V or just not exceed 1.1V?
You could make all the voltage dividers identical, but that means the 3.65 volt measurement will only use a fraction of the range of the analog conversion.
This may be acceptable. Assuming you have a 10 bit a/d conversion, if the 14.6 volts is full scale, the 3.65 volts will only be 1/4 of the full reading. At ten bits, this means the 3.65 volt measurement will only get to 256, so each increment of the value would be 0.014 volts.
If you tuned each voltage divider, each 3.65 volt cell would be measured to 10 bits, giving a resolution of 0.004 volts per increment.
It won't be so precise that it might matter, but why throw away resolution unnecessarily? Just to avoid some calculations and some software.
Using larger resistors just means less current is being taken for the measurements. If you aren't too worried about that current taken for measurement (brief random testing) values above 47K should keep things gentle and cool.
Do add the capacitors mentioned by @Wawa. Do not design this, make PCBs and then find some surprises about how, and how well, the hole thing works. You will need to fiddle with the dividers and the code until you are happier.
Ok, I am working on it now. I am trying to bite this one piece at a time, but ultimately I want to add components so that if the voltages of a cell go below or above a certain voltage an output pin will signal a relay (large high amp) to cut power to the load to prevent damaging the cells. A BMS. I have read many threads on people doing this, but most either go cold or aren't really what I am looking at doing. I want to keep it as simple as possible. When the uno detects a high or low voltage; an output pin cuts off the power to the relay that is allowing the load to pull current from the pack. I am sure I will have to go through a transistor - to relay. Any help/advice appreciated.
Please know or be reminded that the Nano Every uses a different chip than the UNO.
For many things this means nothing. But there are still cases where a library doesn't work, or conflicts somehow.
Postpone switching horses until you've forded a few of the streams you'll need to.
My Nano Every got put into a deployment circumstance where it is happy. Unless I need something it offers that a regular old Nano lacks, I won't be using it otherwise.
Those look scary at a glance! I am thinking you might like to get a wimpy 4S LiFe battery to play with and leave that monster stack safe over in the corner in case. You screw up somehow.
Hard to say if you don't tell us why you think something is missing.
What are you aiming for with the map() function?
What resistors are you now using in the four voltage dividers?
I don't see you ever write HIGH to the relay.
What are the high and low voltage thresholds meant to help with?
The ones like
if (valVoltageInC1 < highVoltageCutOff){
digitalWrite(relayOutput, LOW);
}
look like you should be testing for > or >=. If the voltage is too high, drop the connection to the battery.
I don't see you ever said what current the battery will be expected to deliver to its load in the projext. I'm just curious.
I'm now making a battery analyser and the voltage dividers have three parts, an above resistor, a below resistor and an in between potentiometer, calculated so it should be close when the wiper is in the middle of its range. And the pot only dropping like half a volt, so the thing can be adjusted in the hardware.
Also if your calculations call for odd resistor values, you can usually get close with two standard resistors in parallel.
If you needed a 24K resistor, the standard 220K in parallel with 27K would be close, e.g. Of course you can buy a 24K resistor, but may not have one right there like you might 220K and 27K.