Go Down

Topic: analogRead (Read 113 times) previous topic - next topic

max777

Aug 19, 2019, 01:35 am Last Edit: Aug 19, 2019, 01:54 am by max777
Hi !

I use miniCore ;

I try to read analog values on ATMega328 ADC7

I have a divider with 2 10K resistors between VCC and GRD ; middle point on ADC7

I read with analogRead(7);

when VCC change I always have the same value : 510

What is my mistake ?

Delta_G

Hi !

I use miniCore ;

I try to read analog values on ATMega328 ADC7

I have a divider with 2 10K resistors between VCC and GRD ; middle point on ADC7

I read with analogRead(7);

when VCC change I always have the same value : 510

What is my mistake ?
Because the reading is ratiometric.  Vcc is always the top of the range.  Half of Vcc is always 512.  It's all relative to Vcc. 

If you want Arduino to be able to read it's own supply power, then use the internal 1V1 reference and a steeper resistor divider. 
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

max777

I added

analogReference(INTERNAL);

now the value is always 1023...


Delta_G

I added

analogReference(INTERNAL);

now the value is always 1023...


Did you change the voltage divider as well?  Or do you now have 2.5V going into an ADC with a 1.1V reference?
|| | ||| | || | ||  ~Woodstock

Please do not PM with technical questions or comments.  Keep Arduino stuff out on the boards where it belongs.

max777

My bad... 

Thank you for help

Go Up