Bewst way to monitr a coin battery
-
- Posts: 6
- Joined: Wed Oct 05, 2022 8:56 pm
Bewst way to monitr a coin battery
Hello,
The board i am designing has an rtc chip and a 1220 3v coin battery as bacup power. I want to monitor the battery voltage using anm ADC pin but i am worried about current leakage. I thought of either putting a voltage divider with 2Mohms and 1 Mohm as resistors and connect the pin there, the other alternative would be to simply put a resistor between the positive of the battery and the ADC pin, i am thnbking 2Mohms.
Would appreciate any suggestions as to which way to go about it.
I considered using a mosfet to switch the connection, but that would require an extra pin and i dont have any to spare with my design
thanks
The board i am designing has an rtc chip and a 1220 3v coin battery as bacup power. I want to monitor the battery voltage using anm ADC pin but i am worried about current leakage. I thought of either putting a voltage divider with 2Mohms and 1 Mohm as resistors and connect the pin there, the other alternative would be to simply put a resistor between the positive of the battery and the ADC pin, i am thnbking 2Mohms.
Would appreciate any suggestions as to which way to go about it.
I considered using a mosfet to switch the connection, but that would require an extra pin and i dont have any to spare with my design
thanks
Re: Bewst way to monitr a coin battery
Since the maximum voltage of the 3V battery is within ESP32's tolerances, you could connect the battery to GPIO32 or 33 through a resistor, and then temporarily enable the internal pulldown on the GPIO to divide the voltage when taking an analog reading.
You would need to measure the internal pulldown resistance to get any kind of accuracy out of this. I don't know how consistent this resistance is, so this might not be feasible for many devices but would only take a minute for one or two.
That being said, looking at a discharge curve for these batteries, it's *very* flat until about 40% capacity, especially at such low discharge rates. So maybe consider not even attempting to gauge the approximate remaining capacity: never enable the pulldown, and simply flag "low battery" when the ADC reading is below maximum value (ie. <2450mV) which looks to be at about 20% remaining based on the curve I'm looking at. And optionally flag "critical" when it gets to some even lower voltage now that it's within measurable range.
You would need to measure the internal pulldown resistance to get any kind of accuracy out of this. I don't know how consistent this resistance is, so this might not be feasible for many devices but would only take a minute for one or two.
That being said, looking at a discharge curve for these batteries, it's *very* flat until about 40% capacity, especially at such low discharge rates. So maybe consider not even attempting to gauge the approximate remaining capacity: never enable the pulldown, and simply flag "low battery" when the ADC reading is below maximum value (ie. <2450mV) which looks to be at about 20% remaining based on the curve I'm looking at. And optionally flag "critical" when it gets to some even lower voltage now that it's within measurable range.
-
- Posts: 6
- Joined: Wed Oct 05, 2022 8:56 pm
Re: Bewst way to monitr a coin battery
Thanks for that info.
Just to confirm, I will use only a 2Mohm resistor between the positive of the battery and the GPIO pin. Then when the value of the ADC falls below 2.45V i will flag the battery as needing replacement. Is that correct?
thanks
Just to confirm, I will use only a 2Mohm resistor between the positive of the battery and the GPIO pin. Then when the value of the ADC falls below 2.45V i will flag the battery as needing replacement. Is that correct?
thanks
Re: Bewst way to monitr a coin battery
You should validate that your desired low battery threshold is <2.45V to make sure this solution is viable, first. Does the RTC have a minimum input voltage? What is the maximum voltage of your specific battery?
Then yes you would connect the battery directly to an ADC pin. The resistor isn't strictly necessary but would be best practice. I would use about 1-10k.
Just to reiterate, in this configuration, you won't be able to determine the actual voltage as long as it's >2.45V. The ADC will always return the maximum value until the voltage falls below that threshold and into the ADC's range at maximum attenuation. If you're happy with that tradeoff then I think this is a neat way to do it with 1 pin and no quiescent current.
Then yes you would connect the battery directly to an ADC pin. The resistor isn't strictly necessary but would be best practice. I would use about 1-10k.
Just to reiterate, in this configuration, you won't be able to determine the actual voltage as long as it's >2.45V. The ADC will always return the maximum value until the voltage falls below that threshold and into the ADC's range at maximum attenuation. If you're happy with that tradeoff then I think this is a neat way to do it with 1 pin and no quiescent current.
-
- Posts: 6
- Joined: Wed Oct 05, 2022 8:56 pm
Re: Bewst way to monitr a coin battery
Hello,
Actually the original reason i started this thread is because i made a board where i connected the battery + directly to the ADC pin. The problem is that when the board was not energized the rtc battery would be drained in less than 2 days.
So that is why i thought of a resistor or a divider. I thought of using really high value resistors to limit the current. If my math is correct with a 10k resistor the current flowing would be 300micro amperes, but it is a permanent connection so i am concerned about the impact on that on the battery life.
The chip i am using is the PCF8563 and the datasheet says that the clock operating voltage is between 1v and 5.5V
The CR1220 battery has a maximum voltage of 3V
The battery i was thinking is this one:
https://data.energizer.com/pdfs/cr1220.pdf
So since the voltage of the battery is 3v if i was to put a voltage divider of 1mohm as R1 and 2mohm as R2 i would get a voltage of 2V into the ADC and if i set the attenuation ofto ADC_ATTEN_DB_11 that will give a maximum of 2.45 which will be within the range of the 2v i would be opassing through the dvider. I could then map that result to a 3v to know the 'actual" voltage. Will that work?
Really appreciate the help
Actually the original reason i started this thread is because i made a board where i connected the battery + directly to the ADC pin. The problem is that when the board was not energized the rtc battery would be drained in less than 2 days.
So that is why i thought of a resistor or a divider. I thought of using really high value resistors to limit the current. If my math is correct with a 10k resistor the current flowing would be 300micro amperes, but it is a permanent connection so i am concerned about the impact on that on the battery life.
The chip i am using is the PCF8563 and the datasheet says that the clock operating voltage is between 1v and 5.5V
The CR1220 battery has a maximum voltage of 3V
The battery i was thinking is this one:
https://data.energizer.com/pdfs/cr1220.pdf
So since the voltage of the battery is 3v if i was to put a voltage divider of 1mohm as R1 and 2mohm as R2 i would get a voltage of 2V into the ADC and if i set the attenuation ofto ADC_ATTEN_DB_11 that will give a maximum of 2.45 which will be within the range of the 2v i would be opassing through the dvider. I could then map that result to a 3v to know the 'actual" voltage. Will that work?
Really appreciate the help
Re: Bewst way to monitr a coin battery
Yes a voltage divider is the usual route. My suggestions were unorthodox but they had their merits. Voltage divider will do fine.
-
- Posts: 6
- Joined: Wed Oct 05, 2022 8:56 pm
Re: Bewst way to monitr a coin battery
Hello,
I read about the attenuation variable when using the ADC. I am just a bit confused. I know that the mac voltage you can apply to a pin is 3.3v, however it seems that there is not really a way to read a voltage higher than 2.45v ? i mean if i apply a voltage of 2.8 to a pin, does that mean that it will always return the same value as if 2.45?
how does one measre 2.7 using the ADC?
thanks
I read about the attenuation variable when using the ADC. I am just a bit confused. I know that the mac voltage you can apply to a pin is 3.3v, however it seems that there is not really a way to read a voltage higher than 2.45v ? i mean if i apply a voltage of 2.8 to a pin, does that mean that it will always return the same value as if 2.45?
how does one measre 2.7 using the ADC?
thanks
-
- Posts: 828
- Joined: Mon Jul 22, 2019 3:20 pm
Re: Bewst way to monitr a coin battery
Attenuating the signal gives you a wider range of measurement. At 0db attenuation, your range will be right around the reference voltage (1100mV). At 12db, the range will be around the source voltage (3300-3600mV). The ADC response is non-linear. This means it is much less accurate at the extremes. Calibration functions are included in the framework to help normalize this, but it is still not at its best near the limit. What boarchuz is recommending is that you use an attenuation where your low point is right in the middle of the range, where it is most accurate, and then when the battery is full, it will be out of range. Since you really just want a binary response (battery good/battery bad), you don't need an exact number. This is all much easier and power efficient is you use a voltage divider and a transistor. If you really feel you need an accurate and low power method here, I would say it is worth it to try to repurpose or double up a gpio functionality, or choose a device with more pins.
-
- Posts: 6
- Joined: Wed Oct 05, 2022 8:56 pm
Re: Bewst way to monitr a coin battery
Well,
Actually my issue is that one but at another level i have a similar problem with the board's sensor terminals.
Here is the design
Because GPIO 32 qnd 33 can be used for digital and analog inputs, i added the 2N7002 so i can connect sensors that are 5v or 3v.
However, i just realised that eventhough you can input uop to 3.3v to a pin in the esp32, the maximum voltage that can be used in an analog pin is 2.45 that is using the maximum attenuation. My question is, how can i modify the design so that the voltage going to the pin is never more than 2.45v? the 3.3v that is being fed to the low side of the transistor comes from the voltage regulator, should i put a divider and bring it down to 2.45 and feed that to the low side? and if i do what happens when i am using a sensor with digital output?
Would love to get some suggestions
thanks
Actually my issue is that one but at another level i have a similar problem with the board's sensor terminals.
Here is the design
Because GPIO 32 qnd 33 can be used for digital and analog inputs, i added the 2N7002 so i can connect sensors that are 5v or 3v.
However, i just realised that eventhough you can input uop to 3.3v to a pin in the esp32, the maximum voltage that can be used in an analog pin is 2.45 that is using the maximum attenuation. My question is, how can i modify the design so that the voltage going to the pin is never more than 2.45v? the 3.3v that is being fed to the low side of the transistor comes from the voltage regulator, should i put a divider and bring it down to 2.45 and feed that to the low side? and if i do what happens when i am using a sensor with digital output?
Would love to get some suggestions
thanks
Who is online
Users browsing this forum: No registered users and 19 guests