Thanks for both of you.The relevant code is I already posted in 1st post.
All your problems will vanish if you go through this.
https://code.google.com/archive/p/tinkerit/wikis/SecretVoltmeter.wiki
But I still didn't get a proper reply..!!
Thanks for both of you.The relevant code is I already posted in 1st post.
All your problems will vanish if you go through this.
https://code.google.com/archive/p/tinkerit/wikis/SecretVoltmeter.wiki
But I still didn't get a proper reply..!!
No.
This is snippet.
We need ALL OF CODE FROM YOUR SKETCH.

![]()
I guarantee that the same thing can be done with ATtiny85 using another code, but this page proves that this code doesn't work with ATtiny85.
This is because even if the registers are the same, the values to be set are slightly different for both uCs.
Didn't work for you apparently.
Anyway, with the hints that @chrisknightley gave, it should be easy. Have you tried his suggestion yet?
You got excellent replies from @chrisknightley
I think you're rather ungrateful.
You are very kind man, because you come back and respond to he. ![]()
I'm sure that you was easily understood the this measurement method instantly.
So would it be alright if I left that rest to you? ![]()
OK I thank you for both of you for spending time on this.
Hi, I have a doubt on this function call
int getVCC() {
return min(11264/analogRead(12),99);
}
I tried out to find out from the sketches & it has not defined.(may be it is built in some where but not in the sketches).
The traditional analogread is followed by the analog pin..!! but here 12 has mentioned is it analog12 pin? ATTINY85 theres no pin 12..!!!
I think analogRead() from the ATTinyCore can use an ADC pin number or input channel for the parameter. Using analogRead(12) is just setting the MUX bits to 12 (B1100), this selects Vbg as the input, as per table 17-4 in reply #8. It should work, though I haven't tried it.
When you say getVCC() returns wrong values, what did you get and what did you expect?
Thanks.Good info though.
I measured my supply voltage is 4.9V.When I load the code to UNO & it shows 4.9V perfectly.
When I apply the code to ATTINY85 it shows 5.7V which is wrong.It must be 4.9V...!!!
You need to adjust the magic 11264 (1.1v * 1024 * 10). I calculate that 9700 should get you closer, then you can try with different voltages to confirm all is working.
I've never seen two chips with the same 1.1v reference, I have to adjust the calculation for each and every chip.
Excellent. After changing the magic constant I got perfect readings.Now its working superbly.
One last thing can you tell me what is this 99 in below function?
int getVCC() {
return min(11264/analogRead(12),99);
}
The min() function has been used to limit the return value to 99 (representing 9.9v). I would guess that it prevents the return value having an extra digit (100+), which the OLED display routine can't handle.
One thing I didn't mention before is that when the ADC channel is changed you need to give it time to settle. It's good practice to discard the first value returned and read it a second time.
Wonderull information.Everything is clear.Really happy on that.
Thank for everybody who helped throughout the thread.
Cheers.