Analog Sensors on Uno

I am working with capacitive moisture sensors and came across a strange phenomena that I don't understand. I am using A0 and A1 as my analog ports. I would have expected that if there was no input, as in nothing connected, Analogread() would return a zero. But without the sensors connected, I am getting approximately equal readings in the 500s on both ports.

If I connect a sensor to either of the ports, the readings on both ports are affected and read approximately the same in the 300s

The analog input on the uno is reading random noise, like an antenna. It needs either a pullup or pulldown resistor if you need a static level. In fact, it is so random that you can use an unconnected analog input on the Uno as a random seed generator.

What you are experiencing is called a "floating" input. The analog inputs have a very high input impedance (resistance) so they will pick up stray fields when not connected to a known voltage level. You can add a high value resistor (100K - 1M) from the input to ground to pull the input down to ground when it is unconnected. That resistor will have little effect on the sensor output voltage when the sensor is connected.

The analog inputs are extremely high impedance
and thus they read the stray "signals" that are
floating around the Arduino board.
Herb

CMOS circuitry typically takes no(*) static current to operate, as its made from FETs with insulated gates. Such
devices sense electric field across a very thin insulating layer of silicon dioxide (which is an exceptionally good
insulator even in extremely thin layers).

(*) well, there is a current, but its so low you need extremely specialized test gear as it can be in the
femtoamp range (0.000000000000001 amp = 1 femtoamp = about 6000 electrons per second)