Added a resistor of like ~148K to ground and now it works beautifully to detect any empty pins and it still returns exactly the right values when the sensors are plugged in.
A 10K resistor wasn’t enough and still gave a reading in the 780 range, so I bumped it higher.
As I understand it: the pulldown resistor needs to be very much greater than the impedance of the sensor that you are connecting to the pin.
Consider a “sensor” with is just an ideal 5v battery in series with a 1k resistor. Without any pulldown, your pin will read a full 5v (1023). If you put a 1k pulldown on the pin, the pin will read half that, because the voltage at the pin will be 2.5.
Any sensor will have some sort of internal resistance, because we just don’t live in an ideal world. A simple sensor is a potentiometer - 5v at one end, ground at the other, and a tap moving along a resistor of some particular value. You can see immediately that putting a fixed resistor from the tap to ground will change the voltage everywhere except for the extreme ends of the travel of the knob. The response becomes nonlinear, and the nonlinearity is greatest … I’m not sure. Either in the middle of the range, or when the resistance from one end to the tap matches your pulldown resistance. Some calculus may be required.
The point is:
- adding a pulldown changes the numbers you get from the sensor - it will make them somewhat lower than you’d expect
- The important numbers are the impedance of the sensor, the impedance of an analog input pin, and the value of the pulldown resistor
- if the pulldown is too low compared to the sensor, the “pulling down” effect will cancel out the data you get from the sensor
- if the pulldown is too high compared to the impedance of an analog pin, it will fail to pull down the pin to zero when the pin is unconnected
But according to topic=65134.0, the impedance on an analog pin is 100MΩ, so meh. Slap a big resistor on there and you’re good.