analogRead

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 ?

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 ?

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.

I added

analogReference(INTERNAL);

now the value is always 1023...

max777:
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?

My bad...

Thank you for help