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?
Solution
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
analogReference(INTERNAL);
Which worked.