Analog pin reading over 1024 - SOLVED

Hello,

I have a very simple Arduino Nano circuit to measure temperature. A thermistance is powered by a 3v3 pin and connected to an analog pin (see circuit diagram below).

The problem is that I'm having unexpected readings on the analog pin. 1.6V between A7 and ground gives a reading of ~1400, while 3.3V gives a maximum reading of ~2885. This is weird to me, as the reading is supposed to be in 10bits (no higher than 1024).

Here is my code:

int ThermistorPin = A7;
float Vo = 0;

void setup() {
  Serial.begin(19200);
}

void loop() {
  Vo = analogRead(ThermistorPin);
  
  Serial.println(Vo);

}

Notice that I set the baud rate to 19200, and am using 4800 baud in the serial monitor. Other baud rates (like 9600) output gibberish. I believe this is related to my Arduino's clock rate, but I'm not sure if it is related to my current issue.

Any help or guidance would be greatly appreciated, as I am fairly new to Arduino projects. Thank you!

Edit: A 5V voltage gives a 4095 reading. This may just be that my readings are in 12 bit.

When you change Vo to an interger, what do you get?

I get similar results, reading of ~1400 at 1.5V. Thank you for the suggestion

Are you sure it's a Nano?

sp. "no higher than 1023".

Is this a real circuit, with hardware that you can touch?

1 Like

More explanation

Yes, I have the physical circuit on breadboard in front of me.

As you see in the code, I set the Arudino baud rate to 19200 with the line Serial.begin(19200);. However, setting the same baud rate in the serial monitor outputs nonsense:

It is only when setting the baud rate in the serial monitor window to 4x smaller than the one set in the code (19200/4 = 4800) that I get a proper output:

Your readings and diagram don't make sense if you're using the Nano V3.0 in your Fritzing picture.
They do if you're using one of the later Nano models, like the Nano BLE.
"Nano" is used for an extended family of Arduino boards.
Tell us exactly which Nano you have.

Which will damage the board if it's a newer 3.3volt-logic Nano.
Which with 12-bit readings it clearly is.
Leo..

1 Like

Here is the "Board info" I see on my computer. Perhaps it is not an official Arduino, it was given to me.
image

Here is a physical picture of the board (I have two identical boards, hence why nothing is connected here).

I included details and photos of the board in my reply just above.

That's a clone that uses that 32Mhz IC, can't remember the name.

It's the LGT8F328P which indeed has a 12 bit ADC

1 Like

You need to install a new core for that IC:

1 Like

Which tells me that it could be 5volt-logic.
Leo..

Thanks a lot for this information. I have installed the new core and selected the LGT8F328B with 32MHz clock speed.

I can now properly set the baud rate as the same one shown on the serial monitor.

A 1.5V voltage on the analog pin now shows a 320 reading. It seems to now read in 10bit and will not show a reading over 1016.

This isn't necessarily problematic for me, I'm just trying to understand its behavior.

In that first Fritzing thing you posted there is no ground connected to your bread board, so how do you expect it to work?

Sorry about that! The breadboard is indeed connected to the Arduino's ground.

You can set the resolution by:
analogReadResolution(bits)

1 Like

Thank you so much! I am now indeed measuring up to 5V in 12 bits.

I think this officially solves my issue, thanks for your help!