Using UARTs like serial ports, over distances. Lightning concerns. - Page 1
Forum section: electronics / projects

author: cdev
author_rank: Super Contributor
timestamp: August 25, 2017, 09:02:17 pm
content: What can I do so I can run a cable (10 meters would probably be typical) through walls, etc, to a UART-containing device like a Raspberry Pi, or similar (a generic SBC), and not worry every time there is a lightning storm nearby?What kind of solution would be both cheap and effective?

author: suicidaleggroll
author_rank: Super Contributor
timestamp: August 25, 2017, 09:06:45 pm
content: Are you concerned about the cable actually getting struck by lightning? Or nearby lightning introducing EMI? If you're legitimately worried about it getting struck by lightning, how about a wireless solution like XBee? Or you could bury the cable. If you're more worried about the EMI, I would use RS422 instead of UART. What baud rate are you planning?

author: cdev
author_rank: Super Contributor
timestamp: August 25, 2017, 09:25:12 pm
content: Lightning inducing EMI.The baud rate is not really so important, although recently Ive gravitated to 115,200 just because it seems to handle whatever I throw at it and is supported by most SW.So, no, not planning for direct lightning strikes, just if lightning strikes nearby trees, which there are a lot of.Can't really spend a lot of money. It wouldn't make sense in this context. There wont be any outdoors UART wiring so burying it isn't feasible. Serial consoles are basically what I want to extend.

author: Jeroen3
author_rank: Super Contributor
timestamp: August 25, 2017, 09:30:55 pm
content: Well, the most obvious way is to use RS-232, since that is already directly compatible with the signals of uart. Then you'd only have to add some higher level protocol to handle corrupted data.But, if it's a raspbebrry pi, why no ethernet?

author: cdev
author_rank: Super Contributor
timestamp: August 25, 2017, 09:36:01 pm
content: A level shifter? That would probably offer some protection, would it be enough, though?At this point, I have quite a few non-ethernet containing devices like GPSs that use UART as their main control interface.Also, ethernet isnt the same as a serial console. Console is a privileged space security and debugging wise, that works when the computer is on even if networking is non-operational.

author: Rerouter
author_rank: Super Contributor
timestamp: August 25, 2017, 10:08:48 pm
content: In that case your safest method seeing as the baud rate is low would be to use an rs422 isolated tranceiver on each end and fit a spark gap / mov to mains ground on the transmiision wires.This way even if lightning struck. It would not exceed the isolation voltage. And while the roof side device may be smoked if hit directly, your computer inside would not be.

author: hendorog
author_rank: Super Contributor
timestamp: August 26, 2017, 12:59:01 am
content: Quote from: Rerouter on August 25, 2017, 10:08:48 pmLightning - which has just travelled 1000+ metres through thin air - ain't going to be stopped by no namby pamby isolation or spark gap - if connected to the other end of the 10 metre wire which is hit directly...

author: cdev
author_rank: Super Contributor
timestamp: August 26, 2017, 01:18:05 am
content: We can only do so much, but, s*** happens.I've had lightning kill one tree. Another is still alive, but it created a black stripe right through its core, and basically killed half of it.This was when I was living elsewhere, so it didn't fry all my electronics stuff.But if I was here then, it would have.So, I am looking for stuff on RS422. Can I connect from rs422 to uart on a 3.3 volt device on one end and USB on the other end?I need to keep the cost very low.$20 devices are out of my price range. I would rather buy a breakout board and solder the actual device up myself.

author: hendorog
author_rank: Super Contributor
timestamp: August 26, 2017, 02:42:43 am
content: WTF??

author: Siwastaja
author_rank: Super Contributor
timestamp: August 26, 2017, 07:32:33 am
content: Rpi IOs are very poorly protected, so a 10m cable is absolutely out of question, even without any lightning strikes. Even standard ESD while handling the connections will be an issue.So, you indeed need some sort of protected transceiver. RS232 is probably good enough, I'd probably go for it, but you could indeed use RS422 for even more robustness.If a lightning strike kills your RS232 with normal protection (integrated in MAX232 series, for example), it's quite a hit and will probably kill other electronics, too. An extra TVS, and some series resistance, is of course not hurting.

author: BrianHG
author_rank: Super Contributor
timestamp: August 26, 2017, 07:56:03 am
content: With any driver format, a shielded cable with the shield at each end tied to frame ground will help vastly in every way... Use internal conductors for signal and signal GND...

author: SeanB
author_rank: Super Contributor
timestamp: August 26, 2017, 09:58:16 am
content: Use Cat5 STP cable, and ground the shield at both ends to power supply ground ( at least at one end connect to mains ground as well) and use one half of each twisted pair as signal ground for your TX and RX data. If not providing power to the unit over the other 2 pairs ground them as well to signal ground. Driver wise use the option of your choice, either the old 1488/1489 bipolar which are quite robust and pretty well protected , or use one of the Max232 clones and use as per appnotes for layout of the device and any external decoupling and protection components. Preferably make the layout on a part of the board with some separation from the other parts so you can easily rework to replace them, and if using a DIP version use a socket so it is easy to change them out when they get cooked.

author: cdev
author_rank: Super Contributor
timestamp: August 26, 2017, 02:20:05 pm
content: Thank you, this is good advice and its totally doable for me because I have 5 max3232 breakouts on the way (cost: under $2) and it seems that simply adding the level shifter will add substantially to the robustness of the hookup also will provide the lightning gods a cheap sacrificial piece of electronics to destroy.. .Will have to look into STP cable.. I currently use shielded cable (with the shield grounded) on my bench power supplies and it does seem to improve the quality of the power. (HP recommended it in the manual for my smallest PS.)The first run wont be very long, I just have three possible locations where I may set up. I want to have my potential consoles available at all three.For many things I like to have the console. For example, you can't see the boot messages with VNC.. screen, etc.

author: Benta
author_rank: Super Contributor
timestamp: August 26, 2017, 03:05:22 pm
content: TOSLink or Broadcom (HP/Avago) POF would solve all of your issues. Cheap too.The transceivers can run with a UART.You'll have to implement X-on/X-off flow control.

author: cdev
author_rank: Super Contributor
timestamp: August 26, 2017, 03:21:48 pm
content: Optical fiber..That would be much better than wire for lightning resistance!TOSlink has been around for a long time. I have several pieces of equipment that support it for digital audio, but I have never used it.Quote from: Benta onTodayat 09:05:22

author: cdev
author_rank: Super Contributor
timestamp: August 26, 2017, 05:46:50 pm
content: What is a straightforward way to additionally protect 3.3 volt inputs (after the level shifter) that won't break the bank? Something I can solder up myself on vero board or my own PCB? One problem is that the electrical system here was two wire plugs until around ten years ago when it was upgraded to three wire with ground. The ground here is up to code but it could be better. For example, grounding RF equipment increases not decreases the (HF) RF noise level.I have a constant reminder of lightning's power in that one of the trees in my yard was struck by lightning some time ago and one of the two main branches of the tree died.Around the same time another tree was struck and it completely died.Since Ive been here, we've had close strikes which caused computers to reboot but so far I have not had any equipment destroyed. However, Ive been going out of my way to unplug things when I hear them coming. (when the lightning is nearby I always switch to my aging laptop and use its wireless.. )However, I am not always home to unplug things.Like many places, I'm sure, during the summer lightning storms often develop very quickly. Not much in the way of warning at all.The weather definitely does seem to be getting more variable. So, I think its smart to do whatever I can to work around it.Now that I have been working with the RPI I am very aware of the fragility issue. Since the RPIs are so cheap and the GPIOs so useful, I totally appreciate having them and am more than willing to do whatever it takes to protect the RPI's inputs and my own electronics that hook up to them. Its a small price to pay for the huge flexibility of having real GPIOs on SBCs. (which don't exist any more, as far as I know of, on desktop PCs)Quote from: Siwastaja onTodayat 01:32:33

author: nctnico
author_rank: Super Contributor
timestamp: August 26, 2017, 07:52:16 pm
content: Quote from: cdev on August 26, 2017, 02:20:05 pmA TVS diode between ground and the pins of the chip and a small series resistor will help to make things more resillient.

author: cdev
author_rank: Super Contributor
timestamp: August 27, 2017, 04:12:59 am
content: a single max3232 has four bidirectional level shifting channels and I am probably going to use all four, do you mean a TVS diode between each one and ground?

author: Siwastaja
author_rank: Super Contributor
timestamp: August 27, 2017, 07:13:07 am
content: Quote from: cdev on August 26, 2017, 05:46:50 pmSeries resistor (like 470 ohm if speed is not important, or down to 47 ohm if you need the speed, but providing less protection). Then, directly at the IO pin, double schottky diode clamp (available in small dual package), one goes to GND, another to the +3.3V rail.Cost is a few cents per IO, offering a very good tradeoff between low cost and acceptable protection. These components are an absolute must on adev boarddesigned to be used by tinkerers in all kinds of conditions (ESD, etc.), but of course, poorly designed products like the RPi do not include them, so they need to be added externally.

author: cdev
author_rank: Super Contributor
timestamp: August 27, 2017, 03:54:04 pm
content: Can you give me either suggestions for a part thats appropriate for both 3.3 volt and 5 volt logic (if not what parts should be used for 3.3 and 5 volt logic) - perhaps a cheap, homebrew-friendly device- or pointer to some good reading on the subject?I want to build something I can use for a while - maybe even a design I can have made using a PCB house so I have them around.(I can actually make a board for a SMD part myself if its not very fine pitch- basically anything bigger than 0.5 mm is okay. I will basically make my own breakout board with big pads that I can drill holes in and solder headers to.)

author: Kalvin
author_rank: Super Contributor
timestamp: August 27, 2017, 04:19:09 pm
content: If a wireless solution is viable, there are some wireless Wifi/Bluetooth modules with TTL UART interface. Personally I have not used them, but if wiring is causing you a headache, probably you can evaluate if the wireless solution is usable. Of course, wireless link will be only "best effort", so if the reliability is your first priority, the wired connection will perform better.

author: cdev
author_rank: Super Contributor
timestamp: August 27, 2017, 04:24:47 pm
content: For test equipment that supports RS232, sensors, etc. wireless is definitely the way to go, and cheap, even if they have to be connected to some kind of power too.

author: cdev
author_rank: Super Contributor
timestamp: August 27, 2017, 04:30:07 pm
content: The problem as I see it with wireless is now it seems vendors of Internet connected tablets, especially, seem to be bending over backwards to create an infinitely complicated mess of services which open up potential security issues. For example, WTF is "googlecast" and why are machines (such as tablets) that emit it (which are NOT being switched as playing devices so one can move from one to another in the middle of a movie) suddenly advertising themselves as Internet proxies on the network. You buy some device but even if you just use it for reading, then you cant turn this off. At least not without some expert help.I don't want any additional things I "need to learn" of this kind, for no good reason, Ive got enough stuff in the queue already -See the problem?The only solution if you embrace wireless is having multiple wireless networks- hosting them on separate hardware. But where does it all end?Too much complexity where its not needed is problematic.

author: cdev
author_rank: Super Contributor
timestamp: August 27, 2017, 04:44:42 pm
content: I want to build as much as I can myself instead of spending $20 here, $20 there, when the damn computers they are protecting only cost $35, it doesn't make sense to spend $20 on an add in.I have the time and like soldering.. (when there is good ventilation, which I try to always have).Quote from: hendorog on 2017-08-25, 20:42:43

author: nctnico
author_rank: Super Contributor
timestamp: August 27, 2017, 04:58:57 pm
content: A bunch of RS232 transceivers (like the MAX3232 or MAX232) and some TVS diodes are very easy to hook up and they will provide the function you need. What is the hold up?http://www.epanorama.net/circuits/rs232_protector.html

author: Kalvin
author_rank: Super Contributor
timestamp: August 27, 2017, 05:00:33 pm
content: The $5 ESP8266 modules are quite popular and they can be setup for a point-to-point mode not requiring any wireless access point. There are quite a few example projects floating in the internet.For a wired solution you could possible get away with four optocouplers isolating the two ends of the wired connection. Using two cheap ($3 each) isolated 1W 5V/5V DC-DC-converters with 2 kV - 4kV isolation and some transistors you should be able to create a simple isolated communication channel for two devices using TTL UART. For improved speed [and range] you can use RS485-transceivers so that the transceivers are behind the optical barrier and get the power supplies from the DC-DC-converters.

author: Siwastaja
author_rank: Super Contributor
timestamp: August 27, 2017, 05:58:19 pm
content: MAX232 on both sides + possible TVS diodes for extra protection cost about $2 total in parts and a few minutes to solder together on a breadboard.I agree that you don't need to spend tens of dollars to protect cheap hardware.It's just that the totally unprotected 3V3 signal is only good for a few inches + no hotplugging, no inductive loops, no lightnings or handling, really. But just $2 gets you far.

author: technix
author_rank: Super Contributor
timestamp: August 27, 2017, 06:07:36 pm
content: If your target device supports some form of wireless TCP/IP network natively (Raspberry Pi, or really anything that runs Linux, over Wi-Fi, Bluetooth PAN or cellular) you can use that wireless medium and modify the program to make use of the pseudo-terminal created by SSH. This way you can put your device anywhere there is wireless reception and let the Internet carry the data for you (if the distance is great, for example from the opposite end of the planet.) To prevent hacking you should set up public key only authentication. THis way either someone broke RSA or AES or ChaCha20 or nobody will be eavesdropping.