Electronic – Cabling simple sensors 5-20 ft from a uC – tips and gotchas; UTP vs STP cables

cablescmos

The situation: using a simple microcontroller (eg: 5V Arduino Pro Micro) which needs to read a few sensors located about 5 to 20 feet away via cables. (This is a garage/storage area controller).

The sensors: switches (pushbutton or magnetic reed), resistor (Light Dependent Resistor for reading light levels), and PIR motion detectors. Yeah, I could use a wireless network of microcontrollers and just run AC to a power supply for each; or a wired network. But I wanted simple and cheap and quick to build.

I'd like a reality check on my thoughts on how to do this:

1) For reading a remote switch – two wire cable to the switch; at the uC end one wire to ground and the other to an input pin and a pullup resistor to Vcc. Use a lower impedance external pullup rather than the internal pullup, for more noise resistance.

2) For reading a remote LDR – basically the same thing, but using an analog input pin and treating the LDR + pullup as a voltage divider.

3) For reading a remote PIR – three wires: VCC, Ground, and the logic level detection signal back from the PIR and to an input digital pin on the uC. These PIR sensors generally use very little current so voltage drop on the power line is not much concern.

Cables: in the simplest case, just use some 4 conductor phone cable I have a spool of. However I could cut up a Cat 5 ethernet cable (UTP) – using twisted pairs. In the case of the PIR, use two pairs for power/ground and for signal/ground. Would that help?

Or I could get some STP (shielded twisted pair), and wire it the same, except also ground the shield on the uC end only. (Maybe to earth ground?) Would that help by shielding the conductors from RF and 60 Hz, or just add capacitance and make the situation worse?

Also – I'm a little concerned about the signal wire back from a remote PIR – as described it might be fairly high impedance and easily pick up hum. I wonder if a small value in-line resistor would help reduce reflections, or if larger value resistors to ground &/or power would help to disinvite gremlins.

Maybe some large and small caps at the power inputs of the PIR?

Again, I'm talking about 5 – 20 feet, and very low speeds. So it's beyond normal chip to chip or chip to sensor distances, but not getting into mandatory RS-485. In this case I'm thinking it can be done with the right choice of cable, and maybe a few small passives – no need for multiple uCs with multiple power supplies and communication transceivers and a network protocol, just some wire and judicious resistors.

Yes?

Best Answer

This is essentially what commercial alarm systems do: run power, ground, and a couple of signal wires to sensors and keypads. They don't even run twisted pair, because they're not shipping data (except for the keypad, of course, and even then they rarely bother).

Alarm system sensors signal with a simple voltage divider. When the sensor trips the voltage changes from its idle state, and the panel raises the alarm.

schematic

simulate this circuit – Schematic created using CircuitLab

I see no reason why you can't do the same with your switches and PIR (which, if it is a "normal" commercial PIR, should have an NO relay in it that it holds closed until the sensor trips (or loses power)). The LDR can work the same way, but if you want to measure the light level you'll need to pay more attention than just looking for voltage excursions outside the idle range.

Just feed the signals into the toyduino's analog inputs.