Variable number of sensors - how to handle unused pins

Howdy all - I'm working on a project which requires from one to six sensors depending on the dimensions of the space I'm monitoring. I'd like to be able to plug in as many sensors as I need to use without any sort of external action by the user.

If I set the the analog input pin state to low, will this work? Will a simple pulldown resistor work and not affect the reading?

Many Thanks!

I think a very small test sketch can (dis)prove your idea. Have you tried it?

A simple pulldown resistor on the analog inputs will cause analogRead to return zero when you read them, if no sensor is connected, provided that you do not have long wires attached to the inputs pins (because the wires may pick up noise). Whether or not you can distinguish this from a sensor reading depends on whether the sensor ever produces 0V. Whether or not the pulldown resistor will interfere with the sensor reading if it is connected also depends on the type of sensor.

So you need to tell us what the sensors are.

If you have an equivalent number of DI pins left, it is pretty easy. Use a plug/socket that has 4 pins (power, ground, signal, sensor detect).

  • On the sensor side of the plug, short ground and sensor detect.
  • On the arduino side, connect sensor detect to a DI pin (that has pull-up resistor).

When a sensor is plugged in, that sensor detect line will go low.

If you are using plugs/connectors, you can make default/dummy plugs, with the pull down resistor, and plug them in any unused analog channel. then if you want to plug in a sensor, just remove the dummy plug, and replace it with a real sensor.