Hi, this thread has not been active for a while but I have an application that relates to it and have some questions. I'm using a Moteino 328P, LowPowerLab spec says 16 Mhz clock. The board only has 3.3v pin. My application is using 2 18650 Li-ion batteries in series that puts ~8v at the Moteino's Vin. I want to warn user/protect the batteries....plan on warning when one battery is ~ 3v and shutting down @ 2.5v. I'm assuming that 2 freshly charged batteries will discharge roughly the same so plan on sensing between the two batteries. I played around with the code to measure Vcc....but that only measures what the processor is seeing after the voltage regulator, and if my 2 18650's in series falls below 3.3v, that means that I'm way past where I want to alert the user/shut down.
My current plan is as follows:
1) set ADC reference to AVcc (which should be pretty stable and close to 3.3v)
2) use 2 resisters as voltage divider to bring the center tap of my series batteries to less than 3.3v when batteries are fully charged. That is, read voltage of one battery and scale it to less than 3.3v when fully charged
3) use a digital pin to ground the voltage divider when I want to take a reading. Set the digital pin to input (high impedance) when not reading so there is no current draw through the voltage divider
4) read the voltage via the ADC, adjust result to account for voltage divider and get the voltage across a single 18650 battery. Base warnings and shutdown on that.
Question 1: Any issues with the plan?
Question 2: There was discussion above about ATmega digital pin protection circuit that would shunt over voltage to ground if the voltage on the digital pin was over spec......I'm avoiding this by having the voltage divider output at less than 3.3v max. Does this make sense?
Question 3: Moteino spec says clock is 16 Mhz, so I'm setting the prescaler (ADPS0-2) 20 divide by 128, which makes the ADC clock rate 125 Khz. I didn't see this addressed in the code (that I've looked at) above. Is this the thing to do or is there some default that makes it unnecessary?
Last question: Seems like the Moteino processor is being fed by a 3.3v regulator....correct?
Responses much appreciated. Thanks......jim