Hi guys. I'm still a newbie in electronics and I'm trying to get my Pro Mini 5V to read the remaining voltage of the 3.7-4.2 V 18650 Li-ion battery powering it. The battery's (+) and (-) terminals are first connected to a step-up boost converter's input side to power the Arduino.
But for reading the voltage, I connected the positive terminal of the battery to one of Arduino's analog pins. My code snippet for reading battery voltage takes 20 analog readings from the pin, with a delay of 50 ms after each reading. The readings are totaled and averaged. However, the readings are very inaccurate with a difference of 1 V(max) in readings (w/o the caps I mentioned below).
I have an XBee S2 2mW, LM35, and some bypass capacitors in the ckt (I'll try uploading them later, net connection is very bad). I've used some capacitors, 1 nF and 10 nF between the analog pin and GNd and this is where readings seem to be somehow acceptable but not necessarily accurate (0.5V error max). I don't even know what I'm doing because of the information overload. Hahaha
I've been reading sources online which use RC filters, and I want to know about them. They were talking about samples per second, and the equivalent resistance and capacitance, etc. What do these things do to make readings more accurate and how? Since electronics isn't my forte nor I have some basic knowledge atleast in some of its concepts, what can I do to make the readings more accurate for my circuit?
Thank you. Sorry for the long post. I just want everything said and somehow made clear.
No circuit diagram, no idea!
However, the readings are very inaccurate with a difference of 1 V(max) in readings.
Then you have something seriously wrong with your setup. What that is is hard to say without full details but it might have something to do with the step up regulator.
but not necessarily accurate (0.5V error max).
Do you mean accurate? If so what are you using to to actually measure. My guess is that you don't mean accurate but consistent. the two things are very different.
The voltage of a Li-ion battery is not representative of its capacity.
As you can see, the discharge curve is pretty flat, especially in the middle, and the voltage changes dramatically if you change the current draw. (E.g. when your RF module starts transmitting or when switching heavy loads.)
Commercial devices measure the energy going in and out of the battery to give an estimate of the remaining capacity (i.e. integrating voltage times current over time).
I'm sorry for not having any circuit diagram for this post. I am only on mobile and my phone is an old model, that's why I am limited in making my phones comprehensive by being unable to post pics.
I did a trial and error circuit design and I am glad that the readings were now only having +- 0.08 V difference vs. multimeter readings. I used rlogiacco's Voltage Reference for calibration, then added the Battery Sense library and Low Power library. I made my first setup with only the Arduino and battery on the circuit and reading the battery voltage. Results are accurate.
Noise got added when I included more components like the XBee S2, but then by trial and error by adding bypass caps of diff. values, I was able to achieve an acceptable accuracy.
I'll update maybe if I get into any more trouble. But thanks for those who tried to help.
Thanks, I've read that in some posts I saw online but isn't monitoring the remaining voltage levels the only way to simply determime whether or not your battery's gonna run out of juice anytime? Do you have any suggestions on how to do the actual circuit through simple means?
The ones I've seen were too complicated for my level of experience with Arduino and circuits. Sorry XD