RS232 Serial communication protocol

Serial communication is the process of sending data sequentially through a computer, it means that the data has to be transmitted bit by bit. At the other hand in parallel communication the data are transmitted in a byte (8 bit) on several data lines or buses at a time.

However, the serial communication is slower than parallel communication but used for long data transmission due to its lower cost.

Types of Serial Communication:
- Asynchronous communication – The mode in which the bits of data are not synchronized by a clock pulse.

- Synchronous communication– The mode in which the bits of data are synchronized by a clock pulse.

RS232 is a Serial Communication protocol developed by the Electronic Industry Association (EIA) and Telecommunications Industry Association (TIA) for connecting computer and its peripheral devices to allow serial data exchange between them. It is used in serial communication up to 50 feet with the rate of 1.492kbps.

UART is used in connection with RS232 for transferring data between printer and computer. The microcontrollers are not able to handle such kind of voltage levels, connectors are connected between RS232 signals[1][2].
RS422 Protocol
RS422 protocol is a serial data communication that enables higher data rates to be transferred over serial data lines than the RS232 communication protocol. RS422 can provide data rates of up to 10 Mbps at distances up to 50 feet. By using the reduced data rates, RS422 can transmit data up to 4000 feet, the maximum is 100 kbps at this distance[3].
I2C and SPI communication protocol
I2C is bidirectional, and synchronous serial communications interface that operates on two lines in a half-duplex mode. This type of communication uses a single master that can communicate with one or more slave devices where each connected device is selected via a 7 or more bit address. By using a 7 bit addressing mode, I2C can support up to 127 devices. The two lines are called SCL and SDA. SCL is the clock line for synchronizing transmission. SDA is the data line through which bits of data are sent or received. During transmission, the first byte includes the 7 bit address plus a read / write bit. Subsequent bits represent the actual data.

SPI Protocol
SPI stands for Serial Peripheral Interface (SPI) , it is a communication interface bus used to transfer data between microcontrollers and peripherals such as shift registers, sensors,RFID, and SD cards. It uses separate clock and data lines, along with a select line to choose the device you wish to talk to.
SPI is a bidirectional, synchronous, serial communications interface – like I2C. Also like I2C, it is used for relatively short distances. Unlike I2C, however, SPI operates at full duplex, meaning data can be sent and received simultaneously. Additionally, it can operate at faster data transmission rates.
Slave Select (SS)
SPI communication uses a line called SS for Slave Select. This line inform the slave that it should wake up and receive / send data, Furthermore I might be used when multiple slaves are present to select the one you want to talk to.

In SPI communication, always there is only one device/side which generates the clock signal and it is usually called CLK. This side is conventionally called “master” .At the other side the device or devices communicating with master are called “Slave”. There is always only one master which is most of time the microcontroller, but there can be multiple slaves .
The master uses a line called MOSI, for sending data to slave and it is called “Master Out / Slave In“. If the slave needs to send a response back to the master, the master will continue to generate a prearranged number of clock cycles, then the slave will use a third data line called MISO for sending the response, “Master In / Slave Out”[4].
Multiple slaves
In general, each slave will need a separate SS line. To talk to a particular slave, you’ll make that slave’s SS line low.

SPI can communicate with multiple devices through two ways. The first is by selecting each device with a Chip Select line. A separate Chip Select line is required for each device. The second is through daisy chaining where each device is connected to the other through its data out to the data in line of the next. In this case, a single SS line goes to all the slaves [5].

Protocols Comparison

MQTT standards for Message Queuing Telemetry Transport . It is a lightweight communication protocol used by publish and subscribe approach for allowing the exchange of data between clients and server.

A device which is sending the data to the mqtt server on the specific topic is called “Publisher”. The device which retrieve the data from the mqtt server/broker on the specific topic is called the “Subscriber”. In IoT , the pulisher might be any sensor node collecting the environmental data and send them to server. However, the Subscriber, might be any application or user interface like PC or Smart Phone being used to subscribe to the given topic to retrieve the data. Lastly, a broker, is a component which is used for allowing the transmission of data between clients.:….For more info click here
REFERENCES
[1].https://circuitdigest.com/article/rs232-serial-communication-protocol-basics-specifications
[2].https://www.electronicshub.org/rs232-protocol-basics/
[4].https://learn.sparkfun.com/tutorials/serial-peripheral-interface-spi/all
[5].https://www.mbtechworks.com/hardware/raspberry-pi-UART-SPI-I2C.html