analogRead(A0) always returning 1023

Hi,

I've done some searching, but I can't figure out what I'm doing wrong here. I was wondering whether it's to do with the internal pullup (which I think is 4.7kOhm) on A0.

I've got this circuit (attached below, please ignore the 3.3V pin) which has a potential divider using a 22k and 6,8k resistor to lower the voltage.

The PD across R4 is 1.0 V and R5 is 4.7 V.

When I read the A0 pin, the result is always an unfaltering 1023, whereas I would expect it to be about ~310.

The board is the Arduino Nano RP2040 Connect.

Can anyone help with this? (code also below)

Cheers in advance!
Screenshot 2022-08-09 142938

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

void loop() {
  Serial.println(analogRead(A0));
}

A0 is reading the same voltage as R5 and you stated that was 4.7V which is pretty close to the 5V the nano runs on so 4.7/5 is about 950 counts or so....

1 Like

Your so right! Starting me right in the face haha. Thanks for helping

if I'm not mistaken Rp2040 uses 3.3v logical levels, that all is more than 3.3v will outputs from analogread() as 1023.
Be careful when applying more than 3.3V to the analog input - you can burn the port

Hi,
Welcome to the forum.

What reading do you get if you short A0 to gnd?

If you are using your USB as the 5V supply, you would be better to connect the top of R4 to +5V pin rather than the Vin pin.

I believe there is no internal pullup on the analog pin.

Try adding

pinMode(A0, INPUT);

In setup()
It shouldn't make any difference, but I don't know enough about the RP2040 topography.

Tom.... :smiley: :+1: :coffee: :australia:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.