Strange problem when reading analog pin

Hello,

I’ve used Arduinos for a while now, and have never run across a problem like this.

I’m using an Arduino Mega 2560, with a probe that reads from 0-40mV. I am amplifying this signal with an INA122 instrumentation amplifier, with a gain of 116. This boosts the range of the signal to around 0-4.64V.

However, when I read the input from the sensor (and do a conversion to voltage) it consistently read 4.96V. I tried changing the gain to 105, and it still reads 4.96V. If I touch the sensor, the signal should drop steadily, and I confirmed this with a voltmeter. The readings when I do this drop quickly to around 1.8V and then goes back to 4.96V, even though I can read the pin with a voltmeter which reads the expected output.

I’ve also tested the pin by connecting it to +5V and GND from the Arduino, which shows correctly.

I’m thoroughly confused, so any help is appreciated. The sketch is trivial but I’ll show it below.

void setup()

{

Serial.begin(9600);

}

void loop()

{

int sensorValue = analogRead(A15);

float voltage = sensorValue*(5.0 / 1023);

Serial.println(voltage);

delay(1000);

}

Thanks

I do not think this is the issue, but the line:

float voltage = sensorValue*(5.0 / 1023);

Would be better written as:

float voltage = (float)sensorValue*(5.0 / 1023.0);

What if you print sensorValue. Is that stuck at 1023? Is the A15 pin available on the Mega? Do you need to define that pin as an input first as it might be setup at first for other functionality?

Please post a schematic. Without that, we’re just guessing how you connected everything…