Go Down

Topic: analogReference Attiny85 on batteries (Read 696 times) previous topic - next topic

andrepcg

So I'm planning on using the attiny85 as a remote sensor with a photoresistor. It will be running on batteries, possibly 3xAA = 3x1.5V = 4.5V. The problem is that the batteries will always be draining so the voltage applied to the photoresistor will always be going down thus the voltage the analog pin reads will also be going down. I've read that I should use analogReference set to internal to get 1.1V for reference. My question is if I'm using 4.5V on batteries to provide the sensor readings, the voltage applied to the analog pin will oscillate from 0V to 4.5V (not litteraly) depending on the light level so the voltage applied to the analog pin could be higher than the internal reference (1.1V) so the analogRead will read the maximum value of 1023. How can I modify the circuit or the program to get the right values? thank you!

Docedison

Since the 'normal' ADC measurements are ratio-metric with the Vcc as the Analog Vref it would make more sense to use Vcc and not the internal 1.1 V vref because then Vref will be changing as the batteries do and this will preserve the ratio and not the absolute difference which is what you need.

Bob
--> WA7EMS <--
"The solution of every problem is another problem." -Johann Wolfgang von Goethe
I do answer technical questions PM'd to me with whatever is in my clipboard

Udo Klein

You can determine the supply voltage like so: http://blog.blinkenlight.net/experiments/measurements/supply-voltage-measurement/. Once you know the supply voltage you can set the reference to the supply voltage again. Then measure your resistor. It is advicable to wait some cycles after switching the reference. It is also a good idea to switch back and forth between measurements and to smooth the results.
Check out my experiments http://blog.blinkenlight.net

Go Up