I want to use the reset pin of the attiny85 as an analog pin to read the battery voltage, to be used as low level battery indicator.

So there is a lipo battery that will always be connected to this pin.

I need a high-voltage programmer to do so but I read that the reset pin can be simply an analog pin if the voltage to it is above 2.5v . Is it true?

If so, I can program it with Arduino SPI normally as the battery will never go below 2.5v.


Thanks @timemage for your answer, it really has good info.

But I can verify that if you give 5v to the Vcc of the attiny and connect a lipo (above 2.5v) to the reset pin, it will work as an analog pin.

I used a potentiometer and yes it is working, you can see more info about this as well in this post.

The real info starts from Post#10.

It is really a complex situation here as what I did was using the reset pin as reset and as an analog pin at the same time. It is not recommended but it works!

Please if you can review the post in the Arduino forums and rewrite your thoughts here it will be useful for more people to get useful info.


1 Answer 1


The following was in answer to the question in its original form.

This is kind of more on an electronics question. But it may be of some interest people here, mostly because of Digispark clones that still have their reset functionality.

It's easier to answer these in a different order.

I read that pin reset can be simply analog pin of the voltage to it is above 2.5v Is it true? If so, i can program it with arduino spi normally as the battery will never go below 2.5v

Practically speaking the answer is best summarized as "no".

It took me a while to realize what you were talking about, mostly because of this 2.5V number, which I still don't completely understand. Originally I thought you talking about the internal 2.56V reference. The way I'm interpreting this is "As long as I don't actually cause a reset, is it true that I can use the ADC0 channel that is on the ATtiny85 RESET pin."

Practically, I think no. But, this idea is amusing and also more than a little disturbing. It seemed that the answer could be a qualified yes only because it seemed ATMEL would need to have done extra work to make this not possible, even if trying to do it is a bit nuts. Naturally, I had to try it.

In testing I found that yes, the RESET pin still seems to function as an ADC channel. I was able to hook the division point of 2/3rds (ish) voltage divider to the reset and got a reading of 0xAD (as an 8-bit measurement) which is indeed about 2/3rds of 0xFF. At least this is the case with my particular chip under whatever operating conditions.

According to the datasheet the V_RST (nRESET pin voltage threshold) is specified at 3V to be between 0.2 VCC and 0.9 VCC. It doesn't seem like you would have good reason to think the chip is certain to stay out of reset below 0.9 VCC which at 5V is 4.5V. I did not experiment with mine to find out where the threshold happened to be except that 1/3 VCC did trigger a reset.

So, I don't know where your 2.5V comes from except to say it's a number near the middle of the possible V_RST range for an AVR at 5V. Even if you find this is where the threshold is for your chip, it isn't specified to be exactly there. The fact that I got a reading at 2/3rds instead of a reset does not seem specified to happen that way according to the datasheet.

Another thing about this is when the pin is used as RESET has its internal pullup is enabled, which is listed between 30K and 60K. So whatever you connect to your reset pin (your battery) is connected to the AVR VCC through a pullup.

Anyway, it's interesting but is ultimately probably a bad idea.

So there is a lipo battery will be always connected to this pin

If you want to play with this using-RESET-pin-for-ADC-channel thing anyway, definitely don't have your battery connected to reset when you program, at least not without reasonable series resistance. Otherwise when your programmer goes to reset your ATtiny85 it will short your battery to GND through the programmer.

I want to use reset pin of attiny85 as analog pin to read the battery voltage to be used as low level battery indicator

Voltage isn't a great indication of the state of charge of batteries generally. Under some conditions you can get a rough idea with it. The flatter the discharge voltage curve is the less useful voltage is as an indication of charge state. Lithium chemistries are sort of prized for producing fairly flat discharge curves at a voltage level high enough to do useful work. Typically a "coulomb counting" method is used instead. Basically you sample current over time and integrate (sum) this, not reading instantaneous (or short term averaged) battery voltage. And that has its own intricacies with not drifting from true value. Getting a reasonable sense of lipo's state of charge is enough of a pain to do well that there exist metering chips specifically designed to do this. I don't have good recommendations for them, but MAX17043 and MAX17048 are among the first part numbers for this sort of chip found on modules from suppliers of Arduino-related stuff.

I want to use reset pin of attiny85 as analog

For most Arduino users it's really best to leave the reset pin alone. The ATtiny84 is not much larger than an ATtiny85 and gives you an few extra pins and is otherwise very similar. The ATtiny84 also supported by attinycore. If you are hard set on using the ATtiny85 make sure you've exhausted all your options for using your other pins. There are ways to connect multiple switches to a single analogRead() capable pin. There are ways to put LEDs and switches on the same pin if you don't mind the light coming on when you push button, etc.

I need high voltage programmer to do so but

Right, so back onto using non-RESET functionality of the RESET pin the normal way.

Sort of. You don't need high voltage serial programming mode to program your code that use the reset pin onto the chip and then to disable the reset pin and use it via digitalRead()/digitalWrite()/analogRead()/etc.. But you do need high voltage mode to program again after that, either by programming code via high voltage mode or programming (unprogramming really) the RSTDISBL fuse to re-enable RESET functionality that ISP/SPI mode requires. In other words: if you're treating the parts as one-time-programmable then you need only an ISP programmer. But, during development you're probably not going to want to just toss out piles of otherwise perfectly good chips.

If you're determined to use the ADC channel that's on the reset pin, programming RSTDISBL fuse is the thing you want to do. Then you get useful range out of the ADC channel and the ability to disable the pullup, and maybe even fewer random resets.

And yeah, you need a high-voltage mode programmer to recover from that, and you need to be either able to remove the chip from the board or design the board to handle HVSP signals coming to it; in particular to handle 12V that will be applied to reset. Which is also something that should not make its way to your lipo.

  • could you see the edit? Nov 20 at 2:30
  • I am not chasing down a moving target. If you want to know where the forum poster got their 2.5V figure from ask them, I can't get inside their head. If you'd already taken the time to do what I'd dove in verifying that the reset pin behaves the way it manifestly does, then you should have put that in your original question.
    – timemage
    Nov 20 at 16:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.