Pages: [1]   Go Down
Author Topic: analogReference Attiny85 on batteries  (Read 664 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Anaheim CA.
Offline Offline
Faraday Member
**
Karma: 47
Posts: 2925
...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

--> 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

0
Offline Offline
Faraday Member
**
Karma: 24
Posts: 3496
20 LEDs are enough
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Check out my experiments http://blog.blinkenlight.net

Pages: [1]   Go Up
Jump to: