Well that sounds fine, like I said I'm interested in seeing a schematic for it to try and better understand it, but I also just had this thought that may require only a single resistor. It hinges on two questions though that I can't find the answer to.
First, what is the default AREF voltage for a stand alone atmega328p. Is it the internal 1.1 volts as stated here: http://arduino.cc/en/Reference/AnalogReference?from=Reference.AREF ? Just as a side note I've got my ATMega328p set to brown out at 1.8 volts, right now mainly because the nrf24L01 needs 1.9 volts minimum to operate correctly anyway. Don't know if that makes a difference or not.
Second, the voltage on a digital pin set to high is equal to the power supply voltage isn't it? Since I'm dealing with less than 5v and not using a regulator.
The battery I'm using is most likely going to be a 3v coin cell. If it is the 1.1v internal aref, could I not put a ~367k resistor between a digital pin and an analog pin, set the digital pin to high, and read the analog, then set the digital pin back to low? If my math is correct that should give me roughly 1.1 volts at max power so the analog should read it's max of 1023 correct? And as the supply voltage decreases, the analog read should proportionally decrease, 2v on the power supply should give me ~682 analog reading. This is assuming the voltage going out of the digital pin decreases as the power supply decreases. So that should give me a fairly accurate reading of the power remaining in my battery? That is assuming my math is correct on the resistance value. Also I based all those calculations off something that I read that stated that the analog inputs on the mega328p uses a 100mohm resistor to create the load.
I can try to test this in a bit for myself to see if it works or not, just not at my work bench right now.
Ok, well that doesn't work like I expected, and not exactly sure why. I tested with a steady 3.3v power supply instead of a battery just for testing purposes. My digital output pin is indeed 3.3v, however even with a 330k and a 270k resistor in series the analogRead still resulted in 1023.
I don't understand why this is? 3.3 volts with a 330k resistor should be around 1.08 volts with if I figure a current of 0.0000033 amps (which is what the current is figuring 3.3 volts with a 1megaohm resistor, and I just realized I didn't figure that correctly since what I read was the analogRead pin used a 100megaohm resistor to create the load not a 1megaohm. But if that is the case figuring on that current instead a 330k resistor should be giving me something closer to .01 voltage and near 0 analogRead, not 1023.
I'm guessing I'm just calculating or doing something wrong, or it just doesn't work like I was thinking, but not sure what / which hehe.
EDIT: Just to see if it made a difference I tried a 5mohm resistor between the pins and still got 1023 on the analogRead.