I'm using an ATmega328P based Arduino to prototype reading a TMP36 temperature sensor. I will eventually move this to an ATtiny85 based board with a battery supply. Both the TMP36 and ATtiny85 have a Vcc range from 2.7V to 5.5V so a battery that starts at say 4.5V and slowly drops to 2.7V should not be out of range.

I am expecting to read temperatures in the range -5°C to +30°C which should correspond to a TMP36 output between 0.5 to 0.9V. I am getting 0.74V at around 23°C so this sort of range seems plausible.

The TMP36 outputs 10 mV/°C regardless of Vcc (within 2.7-5.5v). But I suspect the AnalogRead() value will be scaled by the supply voltage and so will slowly change as the battery drains. Is this correct?

Do I need to include an external voltage-regulator / voltage-reference device to supply some fixed voltage (e.g. 2.5V) to AREF?


Following Edgar Bonet's Answer I successfully enabled the internal voltage reference for the ADC.

Initially I added a 100nF bypass capacitor to AREF and tried

#define REFS1 7
#define REFS0 6
#define REFS2 4


//ADMUX = (_BV(REFS1) | _BV(REFS2)); // 2.56V ATtiny85   datasheet §17.3 pp134
ADMUX = (_BV(REFS1) | _BV(REFS0)); // 1.1V  ATmega328P datasheet §23.9 pp217

but didn't get it to work, my code had no effect on values from analogRead(). So after a bit of further reading I instead used


Which worked.

1 Answer 1


The ADC measures a voltage ratio. The conversion result is the rounded value of 1024×V/Vref, where V is the voltage at the input and Vref is the voltage reference.

In the default Arduino configuration, the reference is connected to Vcc. This will not fit your use case, as the voltage you want to read does not vary proportionately to Vcc. You could use an external reference. However, the ATtiny85 has two internal voltage references at 1.1 and 2.56 V. Either of these may be well suited for you application, which should save you having to add an extra part.

See the chapter on the ADC in the datasheet for details on how to select the voltage reference.

  • 1
    Thanks, that quickly led me to a solution - new notes appended to question for those interested. Commented Jun 22, 2020 at 20:47

Your Answer

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

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