Arduino Mega 2560 analogReference issues

Hello
Just started with Arduino and for my little project I need to read off analog (chemical) sensor that gives output from 0 to 65mV

While I am waiting for my 16bit ADC board, I was experimenting with my Mega and the sensor, but do not understand where I have the issue.

Physical connection - 1 wire to ground and 1 wire to analog pin 8
Multimeter read - default reading in air = 10.2mV

The way I understood is that if I use default 5V reference voltage, with 10bit ADC it should give me an output of 2 (with about 5mV step)

Problem is that I get 0, instead of 2.

So, reading more on Arduino ADC, I found that there is a way to change analogReference to 1.1-1.2V.
Doing so, I expected to see a result close to my 10.2mV that I saw on a voltmeter, as I should be getting about 1mV = 1.075 step

Problem is that I get values 3 or 4, instead of 9 and 10

There 3 and 4 seem to co-inside with reference voltage of 2.55-2.56V >:(
What did I do wrong or my assumptions are completely incorrect?

Here is my sample code:

int analoginput = 8;

void setup() {
  analogReference(INTERNAL1V1);
  Serial.begin(9600);
  
}


void loop() {

  int sensorValue = analogRead(A8);
  Serial.println(sensorValue);
  delay(1000);        // delay in between reads for stability
}

can you post a schematics with all the part number like your chemical sensor.
Plus can you explain us in easier way like what you want to achieve and what issues are.
Thank you

The way I understood is that if I use default 5V reference voltage, with 10bit ADC it should give me an output of 2 (with about 5mV step)

yes, to be precise 5V / 1024 = 4.9 mV steps with a clean 5V reference

Indeed the mega has 2 built in references INTERNAL1V1 (1.1V) and INTERNAL2V56 (2.56V).

have you let it run long enough? --> From the doc we know that after changing the analog reference, the first few readings from analogRead() may not be accurate --> so I'd do a few read in the setup() to throw away.

Had it running for some time and the values are not changed.
I have measured the AREF pin voltage with multimeter - its 1.1V, so that part of the code is working.
Just don't understand what is wrong with the rest of it.

To the previous question about parts. Does it matter? Its an oxygen sensor that creates voltage via chemical reaction. In air it reads 10.2mV on the multimeter. With 1.1V reference voltage I was expecting roughly the same results, but instead I get 4 as the sensor reading.

With 1.1V reference voltage I was expecting roughly the same results

What does "roughly the same results" mean? Do you mean that you expect the sensor to still output 10.2mV? If so, what does the reference voltage mean, in that context?

If the sensor is outputting 10.2mV, with a reference voltage of 1.1V, I'd expect a reading from the analog pin of around 9 or 10 (10/1023 is 10.7 mV @ 1.1 Vref).

With a 5V reference, I'd expect a reading of 2.

In neither case, would I expect a reading of 4. That reading suggests to me that you have some issues with your circuit or your assumptions or expectations.

Many O2 sensors need about 20 to 30 minutes to preheat or you will get a larger value. Do you have the spec of your sensor?

Also the impedance of your sensor will impact how fast it can evolve see for more information about the built in ADC

Roughly the same numbers to what I see on the multimeter. As you said it - 9 or 10.
The circuit cannot get any simpler - sensor has 2 outputs cables. I plug +ve to A0 and -ve to ground.
With reference set to default (5v) I get 0, not 2.

As to the times it takes - no, O2 sensors do not need to preheat. You confuse them with CO2/CO sensors.
O2 give constant value for a given % oxygen in the air.

My question is - why I cannot get the same numbers on Arduino in comparison to the multimeter?
I know that the sensor gives the same mV, but on Arduino I cannot make it to display it

Another thing I noticed (maybe it was discussed before this is the way it should work) - I printed the values of all analog pins. When sensor is not connected, all pins read 1023. If I connect a sensor to any pin, 2 out of 15 other pins would show lower values (like 900’s and 700’s). Say if sensor is in pin 0, pin 1 may read 743 and pin 2 may read 902, even though nothing is connected to them

even though nothing is connected to them

All that you have learned, then, is to NOT read pins that don't have anything connected to them. It makes no sense to do that.

I still have not seen a link to the sensor you are actually using. I can not imagine an O2 sensor that has only ground and output proportional to O2 %. I'd expect any sensor to need some form of power input.

Power is generated by chemical reaction in the sensor itself when it reacts with oxygen in the air.
I am trying to find specs for it that did talk about recommended load. Just read internal resistance of the sensor - 25 Ohm

PaulS:
All that you have learned, then, is to NOT read pins that don't have anything connected to them. It makes no sense to do that.

I still have not seen a link to the sensor you are actually using. I can not imagine an O2 sensor that has only ground and output proportional to O2 %. I'd expect any sensor to need some form of power input.

Paul - he is kinda correct on that one - that some sensors are self sufficient generating current. But these are in the micro amp range.

The ones I know like the Grove-Gas_Sensor-O2 (and similar). Those units are using the Winsen Electronics O2 Sensor And generate current, not voltage though and need 20/30 min to get ready. The components you can buy embed a current to voltage translation readout which means voltage will evolve with current and can/need also to include an op-Amp with a strong gain factor... the op amp obviously needs to be powered...

Such units usually have a two years shelf life then the module is worn out.

@sergeyau - have you tried connecting it to A0 or A1 - i.e. change the port associated with your analog pin - just to remove any possibility of a board defect. (Assuming you wired your unit appropriately - still waiting for a picture or a link to your sensor)

sergeyau:
Hello
Just started with Arduino and for my little project I need to read off analog (chemical) sensor that gives output from 0 to 65mV

While I am waiting for my 16bit ADC board, I was experimenting with my Mega and the sensor, but do not understand where I have the issue.

Physical connection - 1 wire to ground and 1 wire to analog pin 8
Multimeter read - default reading in air = 10.2mV

The way I understood is that if I use default 5V reference voltage, with 10bit ADC it should give me an output of 2 (with about 5mV step)

You likely have a ground issue - separate ground wire from the Arduino to your sensor is needed, shouldn’t share it with the power connections.

I have tried all the analog inputs (A0 to 15) - same on all.

MarkT - what do you mean? There are 3 different ground pins on the board. I have tried all 3.

still waiting for a picture or a link to your sensor...

PSR-11-39-MD is the sensor that I have.

but do you have a board / circuit around this PSR-11-39-MD?

The ADC is optimized for analog signals with an output impedance of approximately 10 kΩ or less. Do you know the output impedance of your device?

As pointed in my previous post #5, if you look at the way things work with the built-in ADC --> The internal conversion circuit stores the voltage to be measured into a small capacitor (14pF). This means the ADC is not reading the voltage at the pin, but the voltage at the capacitor plates. In order to load the capacitor there is a small current flow, your input has to charge or discharge that 14 pF capacitor. if your device has a high output impedance, it might take a very long time to adjust to minor modifications of the voltage and given you are in the mV range you are likely to be affected by all sorts of parasit signals as well.

You can read about this here

bugger, typed my message an now it gone.
Anyway, have no schematic for the sensor. All I could get is that it requires 10K load, which multimeter and Arduino both can provide.
Hopefully my ADC board will arrive tomorrow