I am planning to use a wemos d1 mini to read/monitor voltages from a battery. 100aH LIFEPO4 4s. I found several topics that covered this, but I found some conflicting information. I'd like to know that I am understanding it correctly. From my understanding the wemos d1 mini already has a voltage divider built in. According to this thread (WEMOS 12V DC Battery Monitor - Help!), If I want to read voltages up to 13.2 volts I can just add 1M ohm resistor in series to the A0 pin on the board and use a formula to calculate the voltage. Is this basically what that means?
The LIFEPO4 battery could read up to 14.6V (hopefully never higher). If I would like to read up to say 15.2V, I would need to add 200K more resistor in series to the 1M in the schematic above, and I would need to adjust the formula given in the thread? Am I understanding all of this correctly? How accurate can I expect the voltages to be from the wemos board? I am basically going to have the wemos board turn the load off once the battery drops to a certain voltage. I am not looking for incredible accuracy, but I would like to be fairly close.
I don't know anything about the wemos.... The "regular Arduino" with its 10-bit ADC (0-1023) is usually accurate within 1 or 2 counts (~0.2% of full-scale). The 12-bit versions are more precise, but probably no more accuate.
It also depends on the accuracy/stability of the reference, which is usually the supply voltage. If the reference is low the reading will be high and vice-versa.
You can damage the device with excess voltage but a 1M resistor will limit the current so you are probably safe with the resistor, and if you measure on the wemos-side of the resistor it should be lower (but it's not proportional and that makes it useless for measuring 12V).
Thanks! I read it. I "think" I understand, but I still think the way I have the diagram is correct. The wemos already has a built in voltage divider at the A0 pin. A 220K and a 100K: I found this and I think this is what I am trying to do:
So the 1M I placed in the drawn schematic above would be adding to the 220K resistor that is already in the wemos board. It would be increasing the resistance to 1,220,000 above where the A0 pin is tapping the divider. If I am understanding correctly, If I add a 1M resistor and a 470K resistor the math should work like this:
A0 or 1 = Vs(100,000/1,000,000 + 220,000 + 470,000)
1 = Vs(0.0591716)
1 / 0.0591716 = Vs
Vs = 16.9V
Again, if I am understanding correctly this would mean that IF there was 16.9V going through the two external resistors (1M and 470K) and the two internal resistors The analog reading on A0 would return a reading of 1023. Anything less than this will return a lower reading that I should be able to calculate and determine the correct voltage of the battery. This should be plenty high enough for me to read my battery.
So, all that being said, shouldn't I still add the 1M and 470K resistors in series like my drawing in post #1 (it only has the 1M)?
Like I said, I don't know anything about the wemos.... Maybe someone else knows. I didn't know it has built-in voltage divider. I also don't know it's reference voltage or the ADC resolution.
And with the 1M series resistor, if it was me, I wouldn't be afraid to try it!
THANKS! I just checked it, it seems to work. I haven't checked the accuracy yet with a good DVM, but I will. I should just be able to adjust my code. THANKS!
The general rule for a WeMos D1 mini is to add 100k for every volt above 3.3volt.
A 4S battery shouldn't be more than 16.8volt, so 16.8 - 3.3 = 12.7 *100k = 1.27Megohm.
Any value between 1.3 and 1.5Megohm would do.
I would use close to 1.5Meg, because the top end of an ESP A/D is not that good.
You must of course calibrate. float voltage = analogRead(A0) * 0.0168; // calibrate by changing the last digit(s)
Leo..
My plan was to adjust the 1600.9 to calibrate. That is 16.9V but I had to add the 00 to the end and then divide by 100 to get the correct floating numbers. There is probably a better way?
I did check the accuracy with a fluke dvm. It was off by about 100-150mV. I haven't tried adjusting the code to calibrate