How to connect two serial devices to a single COM port

First of all, the question: Can you really connect two devices that communicate over serial (RS232 COM port) to a single PC COM port using nothing but cable (and perhaps a few components)?

The short answer: No!

Slightly extended answer: You shouldn’t try to!

Jump to the end for summarized conclusion if you’re in a hurry!

A while ago a friend of mine asked me if he can connect two code readers to a single computer port using nothing but cable? By code readers, I refer to a DataMatrix (2D) and/or a Barcode (1D) reader – such as those in use usually in supermarkets, warehouses, etc.

The serial protocol is an asynchronous – full duplex one i.e. there’s no need for a synchronization data clock and the two devices may both read and write at the same time (there’s a dedicated TX or transmitting and a dedicated RX or receiving line). In reality though, most devices work in a so called master-slave setup i.e. one device (usually the master) initiates the communication or sends a question while the other device (usually the slave) usually responds by sending the answer. This is why in practice, most serial devices operate or communicate in half-duplex.

For an excellent overview of the topic, refer to this links:

The last two links present ways of creating your own cables for monitoring (only!) an RS232 line!

Remember, when a serial device communicating through RS232 is in idle mode (not transmitting) or during transmitting a zero, the TX line is (usually) at -12V (although the RS232 protocol standard allows for both lower and higher voltage tolerances). When transmitting a one, the voltage level on the TX line (and therefore on the RX line of the receiving end) goes at +12V.

The RS232 serial protocol is a point-to-point/one-to-one/device-to-device protocol – not a bus based protocol (e.g. I2C or SPI). Your two serial devices will be fighting over the lines – even if it’s half duplex, even you may (hardware) trigger them independently, even if you think using signal diodes will provide some form of protection – all you’ll get is – garbage (at best!) or damaged electronics (at worst on both sides but must most likely on the PC side!).

Bottom line, you can’t get away interfacing them directly without facing a certain degree of risk! In fact, I don’t think you should even attempt to.

You might think triggering them independently and always apart would put you on the safe side. You could even go further and use DPDT relays and wire them in a mutually exclusive setup (either both are OFF or while one is ON the other one is OFF) or use a time delay relay with a pair of NO/NC contacts. But that doesn’t change the fact your @$$ is always on the back!

If all you want to do is spy/monitor an existing serial RS232 connection – then yes – you could get away with just a Y cable. Otherwise, you shouldn’t.

Another way of connecting 2 (or more in fact) RS232 devices on a single PC is daisy-chaining them. This however is vendor-specific i.e. not all manufactures support this option. Cognex for example, calls this multi-port connection (Cognex page link if they haven’t removed it?) and has to be specifically enabled on each device in advance (despite the cabling being done!).

Then there’s is the RS232-to-RS422/485 converter option. This in fact, would be the first technically justified option I would personally recommend. There are cheap options available, and then there are not so cheap options as well.

If your RS232 device isn’t really just an RS232 device, and it could be connected to a network using vendor cabling (broadcasting messages either as a client or a master), then this is the other technically justified option I would recommend. If your client software expects an RS232 device only, that’s fine – you can write a small and simple application that “routes” the content read from the device – from Ethernet to the COM port of the PC. I have done this many times in the past.

The last option I would recommend (something I have started doing in the past couple of years) – to get what you want and read from both devices and transmitting the data either as one packet (w/ or w/o IDs) or individually with a delay (w/ or w/o IDs) – without facing any risk of damaging your hardware – is to go from RS232 serial point-to-point protocol to a bus (addressable) serial protocol.

This is one way I’d recommend:

Connecting two RS232 devices to one COM port

If you want to read more about the I2C protocol (and how it compares to say SPI), visit this link on SparkFun’s webpage.

In conclusion:

  1. if all you want is to spy an existing RS232 serial connection – you may use the Y cable option
  2. if you what you really want is to connect 2 (or more!) devices to a single PC COM port, then:
    • if your devices support Ethernet – go for it (you might need to write your own custom software)
    • if your devices support daisy-chaining them – go for that instead
    • if your devices do not support daisy-chaining them – consider an RS232-to-RS422/485 converter
    • finally, consider a custom approach and convert from RS232 to (e.g.) I2C (most likely you will have to write your own custom firmware)