{"id":9469,"date":"2023-05-09T17:26:08","date_gmt":"2023-05-09T15:26:08","guid":{"rendered":"https:\/\/deepbluembedded.com\/?p=9469"},"modified":"2023-08-17T23:50:04","modified_gmt":"2023-08-17T20:50:04","slug":"arduino-serial-communication","status":"publish","type":"post","link":"https:\/\/deepbluembedded.com\/arduino-serial-communication\/","title":{"rendered":"Arduino Serial Communication Tutorial"},"content":{"rendered":"\n

In this tutorial, we’ll discuss the Arduino Serial Communication Ports (Protocols)<\/strong> that we can use for communicating with other sensors, modules, and microcontrollers. The Arduino’s microcontroller supports 3 serial communication ports (UART<\/strong>, SPI<\/strong>, and I2C<\/strong>).<\/p>\n\n\n\n

We’ll get an overview of the serial communication ports (protocols) available in the Arduino, their IO pins, specifications, differences, use cases, and applications. Each serial communication port can be used to establish a communication channel between two Arduino boards, an Arduino with another microcontroller, or between Arduino and various sensors & modules. Which is the most common use case as we’ll see hereafter.<\/p>\n\n\n

Table of Contents<\/h2>\n
    \n
  1. What is Serial Communication?<\/a>\n\n<\/li>\n
  2. Arduino Serial Communication – UART<\/a>\n\n\n<\/li>\n\n
  3. Arduino Serial Communication – SPI<\/a>\n\n\n<\/li>\n\n
  4. Arduino Serial Communication – I2C<\/a>\n\n\n<\/li>\n\n
  5. Arduino Serial Communication Ports Comparison<\/a>\n\n<\/li>\n
  6. Wrap Up<\/a>\n<\/li><\/ol>\n\n\n
    \n\n\n

    What is Serial Communication?<\/strong><\/h2>\n\n\n

    In Embedded Systems, Telecommunication, and Data Transmission applications, Serial Communication<\/strong> is known to be the process of sending data one bit at a time (bit-by-bit) sequentially, over the serial bus. It takes a complete clock cycle in order to transfer each bit from one end to the other. <\/p>\n\n\n\n

    Conversely, parallel communication is known to be the process of sending several bits, even bytes, as a whole only in a single clock cycle. However, even if you transfer fewer data per cycle with a serial transmission, you can do it at much higher frequencies which results in higher net transfer rates than parallel communication.<\/p>\n\n\n\n

    There are so many different serial communication protocols, each of which is working in a unique way. However, they all do share one thing in common. Which is having Shift Registers somehow\/somewhere in their hardware implementation as the working horse (core). <\/p>\n\n\n\n

    Shift Registers<\/strong> are used to shift out the data to be transmitted bit-by-bit each clock cycle. Shift registers are basically some D-Flip-Flops serially connected while sharing the same clock line. Here is a graphical animation that demonstrates how a shift register works.<\/p>\n\n\n\n

    \"Shift<\/figure>\n\n\n\n

    <\/p>\n\n\n\n

    Generally speaking, serial communication at the end of the day comes down to connecting a couple of shift registers together! We just connect the data output of a shift register to the data input of the other shift register enables us of sending digital data serially from one end to another.<\/p>\n\n\n\n

    In the following animation, I\u2019m connecting a couple of 4-Bit shift registers<\/strong>. One at the transmitter device<\/strong> and the other at the receiver device<\/strong>. The serial bus consists of a couple of wires (data line, and clock line). Each clock, a bit is sent from the transmitter’s TX pin and received by the receiver\u2019s RX pin.<\/p>\n\n\n\n

    \"Serial<\/figure>\n\n\n\n

    <\/p>\n\n\n\n

    As you might have noticed, it takes 4 clocks<\/strong> to send the 4-Bit data from the transmitter to the receiver. This is simply the short answer to the \u201cHow does Serial Communication Work?\u201d. This is the basic idea behind serial communication that you need to know first to start building up your understanding of the topic.<\/p>\n\n\n\n

    In fact, there are so many options and configurations for each serial communication protocol that sets it apart from the others. This includes various data transmission rates, operating modes, error detection & correction mechanisms, data flow control, and much more that adds to the overall complexity associated with each protocol. <\/p>\n\n\n\n

    This is more than enough for the scope of this tutorial, but if you want to learn more about serial communication fundamentals, and its underlying hardware, and to go deeper into the topic, then the tutorial linked below is a very good starting point for you.<\/p>\n\n\n

    \n
    ???? Also Read<\/div>\n\n
    \n
    \n\n
    \"UART<\/a><\/figure>\n\n<\/div><\/div><\/div>\n\n
    \n
    Serial Communication Fundamentals (UART)<\/a><\/div>\n\n\n

    This article will give more in-depth information about serial communication fundamentals and UART serial communication ports hardware & software.<\/p>\n\n<\/div><\/div><\/div>\n<\/div>\n<\/div><\/div>\n\n\n


    \n\n\n

    Arduino Serial Communication<\/strong><\/strong> – UART<\/strong><\/h2>\n\n\n

    UART<\/strong> (U<\/strong>niversal A<\/strong>synchronous R<\/strong>eceiver-T<\/strong>ransmitter) is the most popular serial communication protocol in embedded microcontrollers. In Arduino, we typically use the UART module for serial communication with the PC via a USB-TTL converter to print serial messages on the serial monitor.<\/p>\n\n\n\n

    There are actually two forms of UART Hardware as follows:<\/p>\n\n\n\n