I am trying to figure out if I can measure the Vcc of attiny13a, but the code I use for arduino's and attiny85 does not work. This is where I got the code from. I know that it works by using the 1.1v reference and the ADC, and in the attiny13a datasheet it says that it has these, but I can't get it to work.
1 Answer
The code you linked to measures the 1.1 V internal reference using Vcc as a reference. The ATtiny13A cannot do that. It does have a 1.1 V internal reference, but it can only use it as a reference for the ADC, not as a measured channel.
What you can do, if you don't mind adding extra hardware, is divide Vcc with some resistors in order to get a voltage proportional to Vcc but lower than 1.1 V. Then use the 1.1 V reference to measure that voltage. In other words, measure a scaled-down Vcc against the 1.1 V reference instead of measuring the 1.1 V reference against Vcc. The datasheet should help you with the details.
-
I tried this and it worked! I don't understand to much about the bit settings on the datasheet but with the help of a tutorial I got it to work Thankyou Oct 16, 2020 at 11:58