Arduino uno R3 internalReference 1.1V not working

Hello,
I'm using the ADC on A1 and when using the default 5V as the reference this works fine. I'm trying to use the internal 1v reference but that does not seem to work.

analogReference(INTERNAL); // internal 1V ref

After setting the reference to Internal, I wait 10-20 ms to allow setting time but this has not helped.
Any suggestions?

How are you determining that it doesn't work? Maybe posting your code will uncover something?

Lefty

Very simple code and it is working with 5V.

int InPin = A1;
int sensorValue = 0;

sensorValue = analogRead(InPin);  // this works over 0-5 volts perfectly.

// this portion does not

      analogReference(INTERNAL); // internal 1V ref
      
      delay(10);       // 10ms delay for settling
      
      sensorValue = analogRead(InPin);

After selecting (INTERNAL) I get 0 counts in sensorValue. The DC value of A1 input in this case is about 200 mV.
thanks

Have you tried doing two consecutive analog reads after issuing the reference change? I think the first read after a change of reference is always bad and just having a delay doesn't cure that 'feature'.

Lefty

Actually, yes I tried reading 3 more samples and there was no difference.

Thanks

bluejack:
Actually, yes I tried reading 3 more samples and there was no difference.

Thanks

Well I got nothing then. :wink:

Although I guess I could ask what board type your using as the internal reference options are different for the various arduino boards.

Never mind It's in your post title.

Lefty

OK, found the problem. I found in the docs a mention that analogReference() just sets a global variable that is used when analogRead() is called so a delay is needed after a first read.
so the right sequence is this:

      analogReference(INTERNAL); // internal 1V ref
      sensorValue = analogRead(senseResistorPin);     // dummy   
      
      delay(100);       // 10ms delay for setting
      sensorValue = analogRead(senseResistorPin);     // real read