Home >Industrial IoT>Industrial IoT
RS232/RS485 serial port communication introduction

RS232/RS485 Serial Communications is a type of communication protocol used in serial communication systems. It is a low-level communication protocol used in many different applications.

RS232 is a two-wire, asynchronous serial communication protocol that uses voltage levels to transmit and receive data. It was developed in the late 1960s and is still commonly used today. RS485 is a two-wire, differential serial communication protocol that uses a differential signal to transmit and receive data. It was developed in the 1980s as an improvement to RS232 and is now the most widely used protocol in industrial applications.

On the page :

Related article:


What is RS232 serial communication

1. Overview of RS-232

The RS232 interface conforms to the serial data communication interface standard formulated by the Electronic Industries Alliance (EIA), and the full name of the original serial number is EIA-RS-232 (abbreviated as 232, RS-232). It is widely used in computer serial interface peripheral connection. Connecting cables and mechanics, electrical characteristics, signal functions and transmission processes.



The RS-232-C standard specifies data transfer rates of 50, 75, 100, 150, 300, 600, 1200, 2400, 4800, 9600, 19200 bauds per second.

2. Features of RS232 serial port communication

RS-232 is one of the mainstream serial communication interfaces. Since the RS-232 interface standard appeared earlier, it is inevitable that there are deficiencies, mainly as follows:

(1) The signal level of the interface is relatively high, and the chip of the interface circuit is easily damaged. The voltage of any signal line of the RS-232 interface is a negative logic relationship. That is: logic "1" is -3~-12V; logic "0": +3~+12V, and the noise margin is 2V. That is to say, the receiver is required to recognize a signal higher than +3V as a logic "0", a signal lower than -3V as a logic "1", a TTL level of 5V as a logic positive, and 0 as a logic negative. It is incompatible with TTL level, so it needs to use level conversion circuit to connect with TTL circuit.

(2) The transmission rate is low, during asynchronous transmission, the bit rate is 20Kbps;

(3) The interface uses a signal line and a signal return line to form a common-ground transmission form. This common-ground transmission is prone to common-mode interference, so the anti-noise interference is weak.

(4) The transmission distance is limited. The maximum transmission distance standard value is 50 feet, but in fact it can only be used at about 15 meters.

 What is RS485 serial communication

1. Overview of RS485 interface

When the communication distance is required to be tens of meters to thousands of meters, RS485 serial bus is widely used. The RS485 interface adopts balanced transmission and differential reception, so it has the ability to suppress common mode interference. In addition, the bus transceiver has high sensitivity and can detect the voltage as low as 200mV, so the transmission signal can be recovered beyond a kilometer.


2. Features of RS485 serial port communication

RS485 serial port communication is very convenient for multi-point interconnection, and many signal lines can be saved. RS485 serial port communication can be used to network to form a distributed system. For the shortcomings of RS-232-C, the new standard RS-485 has the following characteristics:

(1) Electrical characteristics of RS485: logic "1" is represented by the voltage difference between the two lines +2V ~ +6V, and logic "0" is represented by the voltage difference between the two lines -6V ~ -2V. The interface signal level is lower than that of RS-232-C, so it is not easy to damage the interface circuit chip, and this level is compatible with TTL level, which is convenient for connection with TTL circuit.

(2) The RS485 interface adopts a combination of a balanced driver and a differential receiver, which has strong anti-common-mode interference ability, that is, good anti-noise performance.

(3) The maximum transmission distance standard value of the RS485 interface is 4000 feet, but it can actually reach 3000 meters.

Refer article : Features of RS485 to LoRaWAN data collector

The difference between RS232 interface and RS485 interface

The RS232 interface is full-duplex, and the RS485 interface is half-duplex.

The transmission method is different. RS-232 communication adopts unbalanced transmission mode (single-ended transmission), and RS-485 communication adopts balanced transmission mode (differential transmission mode).

The communication distance is different. The transmission distance of RS-232 is short (the maximum transmission distance standard value is 15 meters), and the transmission distance of RS-485 is long (the maximum transmission distance is 1200 meters).

The difference in communication lines. RS-232 uses three-core twisted pair, three-core shielded wire, etc. RS-485 uses two-core twisted pair, two-core shielded wire, etc.

Pros and Cons of RS485 and RS232 serial communication interface

Advantages of RS232 serial communication:

RS232 serial port is the most widely used serial interface in computer and communication industry. It works in full-duplex mode and requires three wires: ground, transmit and receive. RS232 can only realize point-to-point communication.

Disadvantages of RS232 serial communication:

1.The interface signal level is relatively high, and the interface circuit chip is easily damaged.

2.The transmission rate is low, the highest baud rate is 19200bps.

3. Poor anti-interference ability.

4.The transmission distance is limited, generally within 15m.

5.Only point-to-point communication can be realized.

RS485 serial port communication characteristics

1. RS485 adopts balanced transmission and differential reception, has good anti-interference ability, and the signal can be transmitted for thousands of meters.
Disadvantages of RS485 serial port communication:
2. RS485 has two wires and four wires. When the four-wire system is used, only point-to-multiple communication can be realized (that is, there can only be one master device, and the rest are slave devices). The four-wire system is rarely used now, and now the two-wire system is mostly used.

3.The two-wire RS485 can only work in a semi-duplex mode, and the sending and receiving cannot be carried out at the same time.

4.RS485 can connect up to 32 nodes on the same bus, which can realize real multi-point communication, but generally adopts the master-slave communication mode, that is, one master has multiple slaves.

5.Because the RS485 interface has good anti-interference ability, long transmission distance and multi-station capability, it becomes the preferred serial interface.

How to convert RS232/RS485 serial port data into Ethernet signal

Today, many devices use serial communication, especially in industrial automation and security monitoring projects. The biggest advantage of serial communication is that it is convenient to plug and play, and it is more common. Moreover, serial communication has the disadvantages of short distance and slow transmission rate.

However, with the rapid development of today's science and technology, a large amount of information and communication data increases, and the requirements for distance are also increasing. It is important to implement remote control and other requirements where serial ports must be tightly connected with Ethernet or fiber optic communications.

Therefore, with the development of the times and the advancement of technology, devices that convert serial signals into Ethernet signals have emerged: from RS232/485 to RJ45 serial servers. From serial port to network port and from network port to serial port, because these products can convert both ways, it is actually the same.

Serial to Ethernet Conversion

It is not a simple conversion between the physical layer and the data link layer. Since the serial port protocol itself has no network layer and transport layer, the data to the Ethernet serial port actually uses the serial port data as TCP/IP application layer data, and uses the TCP/IP packet forwarding method. For example, the user passes The recv() function and send() function of the socket send and receive data that is actually the application layer. This allows the user to send and receive serial data to and from TCPIP over the serial port using the recv() and send() functions. However, TCP/IP is as simple as recv() and send(). Depending on the action mode, it is related to connection, shutdown, monitoring, etc. This is the part that needs to be dealt with after converting the serial port to a network port.

The operation mode of TCPIP is divided into a TCP server mode (TCP server), a TCP client mode (TCP client), and a UDP mode.


In general, a serial port is a UART, and actually only defines the data link layer specification, namely start bits, data bits, and stop bits. However, in different physical layers, it is divided into TTL serial port, RS232 serial port, RS485 serial port and so on.

RS485 serial port

A serial port for long-distance communication that can transmit data over kilometers. This main feature is that by replacing the RS232 common mode signal (the voltage between the signal line and GND) with a differential mode signal (the voltage between the two lines a and b), it is possible to resist common mode interference and realize a longer distance transmission.

UDP mode

UDP mode is based on the connectionless mode, if there is data to send, it can be sent without pre-connection. Therefore, this mode is close to the serial communication mode. However, the UDP protocol cannot guarantee that data will not be lost, and it is easy to cause error codes.


TTL serial port
Serial port for data communication between MCU chips. This represents a 1 with +5V (or +3.3V) and a 0 with GND. RS232 Serial Port: A serial port for communication between devices. Mainly change the signal voltage from 05v to ±15V (actually ±12V). The increase in voltage improves the distance and reliability of data transmission.

If divided into ISO's 7-layer model (physical layer, data link layer, network layer, transport layer, session layer, presentation layer, application layer), the serial port actually only includes the physical layer and data link layer. The TCP/IP protocol must belong to the network layer and the transport layer. Therefore, the serial port for TCP/IP is incorrect. Since Ethernet belongs to the physical layer and the data link layer, the serial port of Ethernet is more precise.

TCP mode

TCP mode uses a reliable data transfer mechanism to ensure that there are almost no error codes and loss of data. In TCP communication, configuration must be done at both ends of the communication. One is a TCP client and the other is a TCP server. The concepts of TCP client and TCP server can be analogized. A TCP client is a hitter, and a TCP server is a connector.

Refer article :

WebSocket is a network protocol for full-duplex communication over a single TCP connection

 Socket connection is an essential mechanism in network communication