# Sending digital sensor ouput over cable upto 30meters

## Description:

This is a DIY home automation project to use a touch panel to control mains lights.

I am using a Capacitive Touch Breakout board for the AT42QT1010 touch sensor IC (see references below). I need to send it's output over a long cable to an existing relay module. The basic circuit is shown below:

simulate this circuit – Schematic created using CircuitLab

The relay module inputs are described as:

Principle of operation of low-voltage push-buttons: manual input channel is a TTL level (with +5 V and a current of several milliamperes), which expects a circuit to a common signal GND. Channel input is considered activated in a moment when button is pressed. At the same time, channel input is deactivated when button is released. So it is required to use pushbuttons without fixation and with normally open contacts

The above touch IC is perfect for feeding into the relay module as it has a momentary output.

I've built a breadboard implementation that works as expected but in the real world the relay module itself will be up to a max of 25-30 meters away and the touch panels with the AT42QT1010 will be in a wall in a room.

## My question/problem is:

What is the best practice way to reliably transmit the touch IC output signal over cable lengths of up to 30 meters and to ensure no false triggers at the relay end from inductance and other interference from mains cables and storms (and ideally how to protect the touch sensor circuit and the relay module input from said issues)?

References:

## Edits:

1: I should have noted that this diagram is drawn from memory and just an illustration of the two distinct components and how I currently connect them - the config of the transistor switch was how I currently test the system on the breadboard and is open to be changed to handle the long cable issue.

1. The mains lamp is shown for illustrative purposes as that is what I expect the relays to switch in the future.

3: The relay module is an 8 channel device - the input shown doesn't directly drive the relay - there is internal circuitry that does that-the spec says the input is TTL 5v level.

• too bad you left this question open – Tony Stewart Sunnyskyguy EE75 May 24 '17 at 6:23
• I am probably following bad form @TonyStewart.EEsince'75 but I have been waiting for parts to arrive so I can build and verify a working circuit and then mark the question answered based on what worked for me in my situation. – Damien May 24 '17 at 19:42
• hope that includes ferrite balun or CM choke with RF cap – Tony Stewart Sunnyskyguy EE75 May 24 '17 at 21:08

For a cable this long you can transmit current signal instead of voltage. This will be much more immune to noise. This approach is used in MIDI, for example. On the sensor side, use a transistor to drive 5V thru 220 Ohm resistor into the line. On the receiving side, connect a optocoupler LED to the line, so it will light up when you transmit a HIGH level. When optocoupler LED is on, the transistor opens and pulls the output to LOW.
This will also isolate your devices, which is a good thing for safety.

• Since by the description in the question, the input is ALREADY a current loop, that isolator can be on the transmitter side. Also, what you have shown is not inverting compared to the original. – Trevor_G May 11 '17 at 14:01
• @Trevor I've missed that it's already a current loop, not just a TTL-level signal. However, how is my diagram non inverting? When you apply HIGH to the input, the optocoupler will activate, pulling the Out level to LOW. – Volodymyr Smotesko May 11 '17 at 14:05
• That's why I added..."compared to the original" ? BTW if that were an issue you could always hook it up with the opto and resistor switched positions to invert it. – Trevor_G May 11 '17 at 14:07
• Thanks @VolodymyrSmotesko. I did actually look at this approach but wasn't sure it was appropriate or overkill. Why the down vote? – Damien May 11 '17 at 15:40
• @Damien I've not read your relay module datasheet before answerring, so I've missed that you relay control input is already at +5V by itself, and must be pulled down to activate. That's why the downvote. You can still apply this solution, but you don't need to connect the 10k resistor and 5V to the relay module input. Instead, just connect collector of the optocoupler to In (5V) and emitter of optocoupler to In (-ve). And as Trevor pointed out, it will not be inverting, so that's even better. – Volodymyr Smotesko May 11 '17 at 15:57

Your transistor is incorrectly configured. It should pull the relay coil- low and coil+ to 5V with a reverse diode ACROSS the Vce of the NPN. A 1uF cap or similar ceramic cap must be close the transistor coil output connections for 5V and 0V(gnd).

Since the touch screen uses high impedance and low level signals, it is susceptible to noise from the relay coil V= L dI/dt and the switched current on the contacts and stray electric fields of line voltage that may be 100V/m on an open loop wire.

To make ensure signal integrity, must understand the long cable must be very low impedance relative to the coupled impedance of stray Electric (V) and Magnetic (I) fields to isolate it from disturbances.

1) Use an appropriate common mode CM choke with twisted pair cable wires.

• this improves the differential signal by balancing the impedance of each wire to reject a difference current or voltage.

• e.g. ground or supply is low impedance relative to signal, such that noise induction is worse on the higher impedance signal.
• Thus a CM choke raises the impedance ($Z=\omega L$ )of both over many decades of frequency so that line noise and some spike energy does not become a differential signal and corrupt it.
• twisted pair and shielding also reduces the interference from stray noise

## So how do you lower the sensor impedance?

• use only the switch sensor detector electronics buffered output and not the sensor signal itself to drive the cable.
• ensure the touch sensor is shielded with some ground plane from radiated noise and ESD as well as decouple supply noise with proper selected shunt caps.

## How low does the impedance need to be, to be reliable?

• Compared to say 100V noise @ 10kohm equiv Z and >=1V signal that only is DC on, off, roughly <200 Ohms is considered Low Z compared to stray impedance coupling.

## Do you need Opto isolation?

• No, but it helps for high speed switching, which does not apply here.

## Do you need twisted pair?

No, but it helps when the pair is close and twisted to reject differential noise and also creates a controlled impedance of 120 to 240 Ohms differential depending on wire gap and insulation.

It also depends on how close relay and contact current wires are separated from drive on/off signal pair. Use twisted pair for everything when possible.

## p.s.

• if your load is a 100 Ohm bulb with 240V, when cold at room temp , it is 1000 Ohms when hot ( 0.24A* 240Vac=58W) and thus the peak surge current can be 10x average when cold, causing EMI current pulse noise of ~2.4A depending on random phase of turn-on N.B.!
• Hi wow thanks for the useful information in your response. Just to clarify (as noted in my edits) some points on my setup; the relay module contains driver circuitry already to turn on the relays plus protection, and the load is shown for illustrative purposes. In the real situation it will be LED lights. – Damien May 11 '17 at 15:27
• My current take away for the connection between the two modules should be shielded CAT5 with only one end of the shield earthed (on the relay end?). What is the best way to power the signal from the touch circuit side? – Damien May 11 '17 at 15:29
• Connect shield to source end only and transistor output is lower impedance than input, so it ought to be at sensor side. You don't really need a relay for this, just a MOSFET rated for >5x current or much lower RdsOn (<5% of) than ESR of LED string. You can power from LED supply with LDO at sensor using CAT5 wires. It will need CM choke or RF cap to gnd (>1nF) to shunt CM noise at sensor. – Tony Stewart Sunnyskyguy EE75 May 11 '17 at 16:01

If those are the only connections between them, and the grounds are not connected elsewhere, then what you have should be ok assuming the wires are heavy enough not to produce a significant voltage drop at that distance. I think I would use a MOSFET and not a transistor though.

However, I would remove the pull-up circuit that contains R2 and simple make it an open-collector output. The target expects only a pull down to it's reference ground. The pull-up will only complicate things and reduce the current drawn from the line.

Since it is talking about milliamps in the circuit loop, mains interference should not be a significant issue. Storm discharges though are something else. Use of transorbs may be warranted, or even a small isolation relay.

If the grounds at both ends are connected to different line-grounds, I'd definitely isolate, either with a relay or a suitably protected opto-coupler.

• If you remove R2, isn't the output a static 5V? – Scott Seidman May 11 '17 at 13:55
• To me, "remove R2" reads "short R2" -- but now I understand that's not what you're saying. – Scott Seidman May 11 '17 at 14:26
• @ScottSeidman sigh... don't you just love English :) Yes in this case I meant remove the pull-up circuit. – Trevor_G May 11 '17 at 14:46
• A series resistor is not needed because the relay module datasheet says the current from Vin is already limited to "several milliamps". – Volodymyr Smotesko May 11 '17 at 16:02
• @Trevor something like the 2N7000? fairchildsemi.com/datasheets/2N/2N7000.pdf – Damien May 11 '17 at 17:02