Serial Port Communication Essentials

Well well,
Time to time we need to communicate with SBC (Single Board Computer, eg: Raspberry Pi) or embedded hardware via Serial Port. There are lots of sample codes over GitHub, that’s true. Even a monkey can run a project without knowledge, it can be harsh, but I’m being honest. Just plug VCC, GND, TX, RX and if it doesn’t work invert TX and RX ports woalaa!

Anyway, now I’m trying to explain some terms about serial communication. What is serial communication, first of all? It’s the process of sending data one bit at a time, sequentially, over a communication channel or computer bus. What a great definition right? I’ve took it from Wiki 😀 😀

What are real time examples of serial communication protocol? I’ll drop a few, if you want to hear.

  • ARINC 818 which is common for Aviation.
  • CAN
  • I2C
  • Ethernet, suprised?
  • SPI
  • RS232
Did you remember this? May be you used to plug this to your TV, when you want to play games on your PlayStation 🙂 It’s example of RS232

What about your USB? USB stands for Universal Serial Bus. This communication protocol has saved many generations. Oh mighty USB!

I wanted to have a short entrance and I’m about to make it a long story. I want to talk about some terms like baudrate, parity, flow control and data bits. When you code for a serial communication module, you have to be aware of those terms.

Baudrate: it’s about the capacity of transferring data. Generally baudrates are 1200, 2400, 4800, 9600, 19200, 38400, 57600 and 115200. 9600 baudrate means serial port is capable to transmit 9600 bits of data per second. If you set your device’s baudrate to 9600, then it’s about to transmit 9600 bits/second.

Parity: parity is for error detection. It’s a method. If this method is enabled in serial communication port, then an extra bit is sent with each data character. Parity is always odd or even.

Flow control: It is possible a transmitter can send data faster than receiver able to process it, to prevent that issue serial lines incorporate with handshaking method.

Data bits: It’s to define the number of data bits in each character. Generally 8 bits is used for most of recent applications. it’s range is between 5 and 8 bits.

I want to summarize. In serial communication we can have errors, send data faster than our receiver to process this data. In some cases we can use different baudrates for faster/slower communications due to needs of projects or hardware’s capabilities. We need to know those 4 terms for a decent communication between 2 hardwares to send and receive data.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *