ok so im going to power a attiny45pu from a single cell lipo battery but i need to make sure i do not over discharge the bat will the internal voltage reference still be correct and have a scale of 0-5v or is the internal voltage reference influenced by the voltage powering it.I don't have a chip to test on right now or i would just see for my self
and have a scale of 0-5v
No the internal reference has a value of 1.1V and so you will not be able to measure voltages greater than this.
The good news is that it is not affected by changes in the chip's power supply voltage.
You could use a voltage divider across your battery to reduce to a volt or so but that would impose an additional drain without switching.
ok thanks for the help so far but dose this mean that the voltage reference is the vcc then and thats why you can do a analog read from 0-5v because the vcc is 5v if so dose this mean that i can use a diode as a voltage reference lets say 1v do a analog read of that and use some maths to calculate the vcc voltage example if the diode returned 342 i would know that the voltage of the vcc is 3v right
at this web page half way down the page there is a section about "Detecting low voltage" that i think is similar to what im talking about
sorry for the poor spilling and grammar im dyslexic and meany other things lol
You can't use a diode as a voltage referance, you need something capable of supplying current to the pin. You can get voltage referance chips.
About 1V is the lowest you can take the referance voltage on an Arduino.
Like Mike says, you cannot use a diode.
You need something similar to this.
oh i thought one could use a zener diode and a resistor to create a voltage reference but any way i think the resistor divider will work i have a spare digital pin i could use that to power the divider so it dose not drain the bat down when not in use. the pin would output the supply voltage im assuming or should/can i sink the digital pin by setting it low are ether of those possible
imjeffd:
Oh I thought one could use a Zener diode and a resistor to create a voltage reference
You could, but a Zener and resistor are not all that accurate anyway and you waste an inordinate amount of current for the function if you are going to be battery powered. Of course, you could use your following concept to switch it on only when necessary, but even then it is a poor approach.
imjeffd:
I have a spare digital pin I could use that to power the divider so it does not drain the bat down when not in use. The pin would output the supply voltage I'm assuming or should/can I sink the digital pin by setting it low are ether of those possible?
That makes perfect sense. Divide the voltage by about four from a pin set as output, HIGH, and compare it to the accurate 1.1V internal reference. You will need to calibrate it in any case which will compensate for the internal resistance of the output pin, either in software or with a trimmer as one part of the divider.