Unexpected readings from Analog Input pins

I have a simple sketch

uint32_t timestamp = millis();
void setup()
{
  SerialUSB.begin(115200);
  while(!SerialUSB || millis() - timestamp < 2000) ;

  analogReadResolution(12);

  SerialUSB.println("Starting\n");

}

void loop()
{
  SerialUSB.printf("A1 %u\n", analogRead(PIN_A1));
  SerialUSB.printf("A2 %u\n", analogRead(PIN_A2));
  SerialUSB.printf("A3 %u\n", analogRead(PIN_A3));
  SerialUSB.printf("A4 %u\n", analogRead(PIN_A4));
  delay(500);
}

Whose sole responsibility is to output the readings from each of the identified ANALOG pins. Nothing is connected to the XIAO, other than the USB to provide power and get access ot the Serial port.

With nothing connected to any of the XIAO pins, I would expect to get constant readings of 0 from each Analog pin, however I get the following:
image

The current chip is very sensitive so that we can drive it with a small current. Because there are various stray capacitances on the circuit board and there are stray electric fields around, this will affect the chip’s judgment of the pin input. This is a normal phenomenon and is within the error range. Therefore, it is required in the manual to connect unused pins to a fixed voltage or ground, which is also to avoid the unstable situation of such floating pins.

1 Like