Sending Serial to Computer Over Long Distance With RS232

Hello, I am working on a project where I will be collecting data using an ESP32 about 30 ft away from where I will be with my computer (that needs to graph realtime data). I have a program already written with customizable graphs that parses multiple variables worth of serial data, so I am trying to use RS232 for long distance serial. I am a bit confused by the multitude of adapters that are available, so I wanted to verify that my plan will work before buying the parts. My plan is to connect in the following order:

-ESP32
-TTL to RS232 Female db9
-DB9 Extension Cable (Male to female)
-DB9 to USB C
-Macbook

I do not really know how the protocol works so I am especially wondering whether the DB9 to USB C converter will work or whether I am missing some information about the requirements to convert between. Using this setup, will I be able to read serial as usual? Any advice would be appreciated!

If RS232 is not mandatory for your project you can use plain UART. I have a sensor that is sending serial data with UART by >60 foot cable to the master device, working reliably for a long time.. at 9600 baud. So you don't need any hardware adapter, just send Rx,Tx and GND trough the cable.

Thanks for the tip! I'm looking online, but I'm having trouble finding anything longer than 6ft. Do you have any idea where I could find such a cable?

Three wire cable is all you need for TTL-RS232 (0 to 5V), available from countless suppliers.

24 AWG wire size should work up to several hundred feet, although you may need to lower the Serial Baud rate (e.g. 1200 or 2400) for reliable data transmission.

For shorter distances, 26 AWG 4-conductor "land line" telephone extension cable will work too.

So I can just put tx, rx, and gnd through the 3-pin cable and then on the other end I'll use a ttl to usb adapter like this?

1 Like

I use 3-wire cable :wink:

I don't know anything about that serial-USB adapter, so try it and see.

I would recommend using the RS232 adapters, sending logic over that length of wire is asking for a blasting. You need to be sure it will run on the 3V3 volts on the ESP. The adapter will invert the signal and the RS232 input on your computer will invert it back, this is normal.

Since your ESP32 probably has WiFi and Bluetooth BLE and maybe even classic Bluetooth, one has to wonder why you are having this discussion at all.....

If your host PC is 30 ft away from ESP32, then you need only the following UART/USB Converter (Fig-1); where, the USB end of the converter will be engaged against a USB Port of the PC. Note that raw asynchronous TTL signal can travel up to 50 ft; after that you might need a TTL/RS232 Converter which allows signal to travel up to 150 ft.


Figure-1:

1 Like

Blasting of what? I'm using nearly 30 meters long cable for UART serial communication at 9600 baud and there was no single problem for the last 3 years. The cable is shielded, but there is no problems even if the shield is floating (disconnected). I haven't tried, but I guess, the baud rate could be raised.

1 Like

At what baud rate?
RS232 may not work.

1 Like

Some people get lucky, is that a 3V3 or 5V signal.

First item in your list should work for the esp32..
cable is wrong..
Need a null modem cable..
or a null modem adapter on the straight thru..
Switches the tx and rx lines for you..

good luck.. ~q

A popular choice for serial data (rs232 or otherwise) is flat phone cable. Widely available in 4 conductors (for phones), 6 conductor, or 8 conductor (for Ethernet), it's a commodity item that is probably much cheaper than other types of cable, even if you make it yourself.

For instance, 50ft 4 conductor "phone cord"
You can use the modular jacks (also fine for data), or just cut them off and replace with something else.

Serial/rs232 doesn't need twisted pairs or a CAT-x rating. Cheap flat cable will work fine.

It is expected to work, no luck :slight_smile: It's a 3V3, from ESP8266 to ESP32.

Check this link it will let you what RS232 is, it is not some crippled hack. Check the exceptions. Note the signals are +-.

One "issue" is that I don't have a lot of faith that the "USB/RS232(DB9)" adapters that are on the market actually produce "real" rs232. :frowning: I think some of them (probably the lower cost versions) just send inverted TTL (which is "usually interoperable" with actual rs232 devices.)
You could be more sure with a separate USB/Serial (logic-level) converter and a second logic-level to rs232 converter.

Hi,

I agree, way back I used to service CNC machines, a lot of factories had RS-232 cables from a central PC to each CNC machine for programming.
These were usually 10 to 20m and shielded, 9600 baud and in an industrial environment were very reliable.

Tom... :smiley: :+1: :coffee: :australia:

1 Like

30 m is about 90 ft ( > 50 ft); so, the signal must be of RS232 logic.

(I'm not sure why people think larger distances imply the need for rs232. The higher speed/longer distance serial protocols (RS423, RS422, RS485) tend to have LOWER voltage swings than rs232. I guess the higher voltages of true rs232 would give you higher "noise immunity", probably at lower speed, but it's hard to say if that's an issue in any particular situation. For sure, switching the impedance of a 100ft cable from -12V to +12V ("typical" real rs232 levels) is "harder" than switching from 0 to 5V.))