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:
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.
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.
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.
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.
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..
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.
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. 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.
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.
(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.))