I am working on a product that is essentially a combination of below shown two products:

relay box


There will be a keypad and a separate box containing relays and power supply. A cable will run between the two for power (5 VDC) and signals (3.3 V logic). You can press a button on the keypad and this will turn a relay on/off.

Block diagram is as shown below:

block diagram

I want to use a separate MCU for the relay module in order to minimize the number of connections between keypad and relay box. Keypad can communicate over UART to the relay module.

Since relay module will also connect to 220 VAC wires, there is a very high probability of communication cable running parallel to ac wires.

My questions are as follows:

  1. Will UART work well in such conditions? Its ok if a couple of messages get corrupted. MCU will realize this and packet can be resent.

  2. Are there better alternatives to this approach that come for low cost and don't take a lot of PCB area?

  3. Do I need to worry about induced noise damaging anything? Should I put some TVS diode on all signals?

Some clarifications:

  1. I can't make a single assembly of both PCBs due to some mechanical constraints. Also, I would want to use same keypad for 2-3 different designs of relay module.

  2. I can't use i2c port expanders on back end because my other variants might need to performs some logic on the relay board and MCU is coming for a low cost.

  • 1
    \$\begingroup\$ You know the circumstances a lot better than I do from reading the above. Have you considered (and balanced) the idea of using RS-232 (single-ended) or RS-422 (differential) methods for the communication of data? When you say "UART" I don't know what kind of signalling you mean (5 V digital, 3.3 V digital, RS-232, etc.) So it may help to know what you have considered and eliminated for some reason or another. I'm less worried about the idea of TVS diodes. I am not sure why you think they may be useful here. So some thoughts on why, may help too. \$\endgroup\$
    – jonk
    Commented Sep 20, 2021 at 9:42
  • \$\begingroup\$ What are the two products you refer to? \$\endgroup\$
    – Andy aka
    Commented Sep 20, 2021 at 11:11
  • \$\begingroup\$ @jonk - By UART, I meant 3.3 V digital signal. Same as what arduinos use commonly. My concern is coming from the fact that I will have a signal cable running parallel to ac lines (connected to home appliances). I am not sure to what degree this will impact the communication. \$\endgroup\$ Commented Sep 20, 2021 at 12:05
  • \$\begingroup\$ @andyaka - sorry for not making it very clear in my question. Product 1 is a wireless relay controller and product 2 is a keypad (fancy way of controlling home appliances). I guess I will structure this question better and re-post. \$\endgroup\$ Commented Sep 20, 2021 at 12:08
  • \$\begingroup\$ Links to the devices are probably needed too. \$\endgroup\$
    – Andy aka
    Commented Sep 20, 2021 at 12:09

1 Answer 1


I have done something similar, and even though 30cm doesn't sound long, running in parallel to AC wires is likely to cause noise.

To address your 2nd and 3rd questions.

You can take an approach of incremental "hardening" of the design and see which one works.

  1. The easiest thing to do is use a shielded cable to go between the two boards. Using shielding combined with lower baud rates may be enough to make it, especially if your software is smart enough to use a checksum or something and simply retry if messages get clobbered. In terms of protection, regular AC induced across the wire could hurt a 'sensitive' mCPU as some of these pins don't do well with voltages going over 3.3V. Others have built-in diodes which should offer some protection. I personally would not be comfortable with this option in terms of damage, especially during storms.
  2. Maintain TTL-level UART but use a driver chip, especially one that can drive 5V from the 3.3V and vice versa. You still have to use shielded wire but the driver chips have much better immunity to noise as they are made for that.
  3. Use RS-232; the advantage is that you maintain the same number of wires but it should be almost immune to noise In terms of protection, it will depend on the specific transceiver you use but it is pretty good. The disadvantage is that you now need transceivers on both sides. Shielding is recommended, but optional.
  4. Use RS-422; if you find the right transceiver, you will get the most protection as some of these chips are designed to handle hundreds of volts in spikes. Differential signaling means that noise immunity is very high. You will still need transceivers on both sides and extra wires.

I highly recommend you go with option 3 or 4. As an advantage, if (or rather when) the 30cm ever need to become 300 cm (or more) you are still covered.

  • \$\begingroup\$ Thanks a lot. I was looking for something like this. I'll see what's best I can implement depending upon pcb area. \$\endgroup\$ Commented Sep 20, 2021 at 18:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.