# ATTINY85 measuring internal voltage

I'm using an ATTINY85 for a portable application that uses a Lithium-ion battery; therefor I need to monitor the battery voltage so I don't kill the battery. Is there a way to go about this without using another pin? or using the reset pin? **NOTE: assume that there will be no regulated voltage such as 3.3V or the like. (this is because the circuit only uses one battery and should never go above spec; and saves on cost)

• The voltage regulation is not an issue since there is an internal voltage reference. You do have to have one of the ADC pins available (Reset is one of them). Using the reset pin as an ADC pin could cause some problems programming the firmware though. – Mike Feb 16 '15 at 17:59
• I've read if I disable it I'll have to use a HVL programmer to program it. – Sam W Feb 16 '15 at 18:13

Setting REFS[2:0] to 0bX00 will use VCC as the voltage reference, and setting MUX[3:0] to 0b1100 will use the internal bandgap voltage as the voltage to measure (see §17.13 from the datasheet). From there, the full range of 1023 will tell you what VCC is in relation to the bandgap voltage. So take (1.1*10*1023=) 11253 (or an appropriately scaled equivalent) and divide it by the measured value in order to get the approximate value of VCC in tenths of volts.