Apps - SoftwareBasic ElectronicsCommunicationElectrical DesignHow To

Arduino Serial: Serial Communication by Arduino

Arduino Serial: Serial Communication by Arduino

Background of Serial Communication:

When microcontroller or microprocessor need to communicate with the outer world, then they provide data in the form of 8 bits packets, so if one system needs to communicate with the other one, then total 8 wires cable is used and it is not a always a practical solution because the signal will distort when travel to the long distance. it is also expensive because of the high cost of the bundle of 8 wires this protocol is named as parallel communication after this the need of the new protocol is awakened and then designer introduce a new protocol which is named as serial protocol it used only 3 wires to transmit all the data of 8 line.
 

Serial protocol:

In serial protocol, 8 bits data is converted to the serial stream of bits by the parallel in serial out shift register. In the receiving side, it is converted to parallel 8 bits data by serial in parallel out shift register. Serial data communication uses 2 methods synchronous and asynchronous. Synchronous method transfer block of data at the time while asynchronous transfer byte by byte. Mostly asynchronous mode of operation used in serial communication.

There are three types of communication systems in serial communication

  1. Simplex ( only transmit data )
  2. Half duplex (Can transmit or receive data, but not simultaneously)
  3. Full Duplex (can transmit and receive data at the same time)
    three types of communication systems in serial communication
    Types of Communication systems in serial communication
Serial protocol is known as the RS232 protocol in this one byte data is placed between the start and stop bits and this process is called framing. This standard was initially set for Standard PC and many types of equipment many years before the invention of TTL logic. In RS232 logic High is defined by the voltage level -1 to-25 while 0 is represented by +3 to +25 volts to make this compatible with TTL logic a voltage convertor is used and most widely used IC for this purpose is MAX232. Arduino has built in capability to make TTL and Standard PC port compatible.

Programming Arduino for serial Communication:

Arduino has built in library to use Rs232 protocol, so we don’t need to write the whole protocol and take care about the credibility of the data because RS232 library will take care of it.
Have look at the most important functions used in Rs232 communication.
 
Serial.begin(x)
Note: X is the baud rate, different devices have different requirement of baud rate mostly 9600 is used as a baud rate it define how fast data will sent or received. This function comes in void Setup().
 
Serial.available()
This function checks whether serial data is available to receive or not if the return of this function is 0 its mean no serial data available to fetch and if it returns 1 its mean serial data available.
 
Serial.read()
This function reads the data available in the buffer by default when you send data then its data type is char and when you read it will read its decimal value, for example you are sending 1 it will be read as 49 which is the decimal equivalent of char 1.
 
Serial.println(x)
This function prints the data available in the x variable in the serial window of aurdinu IDE and sends it to the port.
 
Serial.flush()
This function will flush out all the garbage values in the serial buffers.

Example of serial port programming in Arduino:

Example of serial port programming in Arduino. Arduino Serial: Serial Communication by Arduino
Example of serial port programming in Arduino:
Run this program and change it for your understanding and practice.
Stay connected for more upcoming tutorials.

Electrical Technology

All about Electrical and Electronic Engineering & Technology. Join us on WhatsApp at Electrical Technology Official Channel, to receive the latest content, articles, and updates. You can also like and follow our social media networks below, or subscribe with your email to receive premium engineering articles in your mailbox.

Leave a Reply

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

Back to top button