{"id":25916,"date":"2022-02-13T20:57:19","date_gmt":"2022-02-13T13:57:19","guid":{"rendered":"https:\/\/tom.ji42.com\/?p=25916"},"modified":"2022-02-13T20:57:19","modified_gmt":"2022-02-13T13:57:19","slug":"uart-vs-i2c-vs-spi-communication-protocols-and-uses","status":"publish","type":"post","link":"https:\/\/tom.tomwork.net\/?p=25916","title":{"rendered":"UART vs I2C vs SPI \u2013 Communication Protocols and Uses"},"content":{"rendered":"<p>When we\u2019re talking communication protocols, a UART, SPI and I2C are the common hardware interfaces people use in microcontroller development.<\/p>\n<p>This article will compare the various interfaces: UART, SPI and I2C and their differences. We will be comparing them with various factors through their protocols, advantages and disadvantages of each interface, etc and we will be providing some examples of how these interfaces are being used in microcontrollers.<\/p>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" onerror=\"this.src='https:\/\/tom.tomwork.net\/wp-content\/uploads\/2020\/11\/no-picture-available-icon-1.png'\" src=\"https:\/\/blog.seeedstudio.com\/wp-content\/uploads\/2019\/09\/Capture-1.jpg\" alt=\"\" width=\"429\" height=\"416\" \/><\/figure>\n<\/div>\n<p><!--more--><\/p>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<hr class=\"wp-block-separator\" \/>\n<h2><strong>UART Interface<\/strong><\/h2>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h3>What is UART?<\/h3>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<ul>\n<li>Stands for\u00a0<strong>Universal Asynchronous Reception and Transmission (UART)<\/strong><\/li>\n<li>A simple serial communication protocol that allows the host communicates with the auxiliary device.<\/li>\n<li>UART supports bi-directional, asynchronous and serial data transmission.<\/li>\n<li>It has two data lines, one to transmit (TX) and another to receive (RX), which are used to communicate through digital pin 0, digital pin 1.<\/li>\n<li>TX and RX are connected between two devices. (eg. USB and computer)<\/li>\n<li>UART can also handle synchronization management issues between computers and external serial devices.<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h3>How does it work?<\/h3>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<ul>\n<li>It can operate between devices in 3 ways:\n<ul>\n<li>Simplex = data transmission in one direction<\/li>\n<\/ul>\n<ul>\n<li>Half-duplex = data transmission in either direction but not simultaneously<\/li>\n<\/ul>\n<ul>\n<li>Full-duplex = data transmission in both directions simultaneously<\/li>\n<\/ul>\n<\/li>\n<li>Once connected, data flows from TX of the transmitting UART to RX of the receiving UART.<\/li>\n<li>As UART is an asynchronous serial transmission protocol = No clocks<\/li>\n<li>Transmitting UART converts parallel data from the master device (eg. CPU) into serial form and transmit in serial to receiving UART. It will then convert the serial data back into parallel data for the receiving device<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" onerror=\"this.src='https:\/\/tom.tomwork.net\/wp-content\/uploads\/2020\/11\/no-picture-available-icon-1.png'\" class=\"wp-image-24762\" src=\"https:\/\/blog.seeedstudio.com\/wp-content\/uploads\/2019\/09\/1-1.jpg\" sizes=\"auto, (max-width: 440px) 100vw, 440px\" srcset=\"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2019\/09\/1-1.jpg 587w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2019\/09\/1-1-300x122.jpg 300w\" alt=\"\" width=\"440\" height=\"179\" \/><figcaption>Ref: Basics of UART communication.<\/figcaption><\/figure>\n<\/div>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<ul>\n<li>As UART has no clocks, UART adds start and stop bits that are being transferred to represent the start and end of a message.<\/li>\n<li>This helps the receiving UART know when to start and stop reading bits. When the receiving UART detects a start bit, it will read the bits at the defined BAUD rate.<\/li>\n<li>UART data transmission speed is referred to as BAUD Rate and is set to 115,200 by default (BAUD rate is based on symbol transmission rate, but is similar to bit rate).<\/li>\n<li>Both UARTs must operate at about the same baud rate. If the difference of BAUD rate is more than 10%, the timing of bits may be off and render the data unusable. The user must ensure UARTs are configured to transmit and receive from the same data packet.<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h3>UART Working Protocol<\/h3>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<ul>\n<li>A UART that is transmitting data will first receive data from a data bus that is sent by another component (eg. CPU).<\/li>\n<li>After getting the data from the data bus, it will add a start bit, a parity bit, and a stop bit to create the data packet.<\/li>\n<li>The data packet is then transmitted at the TX pin where the receiving UART will read the data packet at its RX pin. Data is sent until there is no data left in the transmitting UART.<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h4>Data Transmission and Receiving<\/h4>\n<ul>\n<li>Once data is being transmitted by the transmit FIFO, the FIFO \u2018BUSY\u2019 flag will be asserted and active during the process.\n<ul>\n<li>FIFO = First in, First out. It\u2019s a UART buffer that that forces each byte to be passed in sequence to the receiving UART.<\/li>\n<\/ul>\n<\/li>\n<li>The \u2018BUSY\u2019 bit will only be inactive after data is finished transmitting, the FIFO is emptied and every bit has been transmitted including the stop bit.<\/li>\n<li>When the UART receiver is idle and if the data input is low after start bit is received, the receive counter will start running and expect to receive data in the 8th cycle of BAUD16.<\/li>\n<li>If RX is still low during the 8th cycle of Baud16 while the start bit is valid, it would be processed as the wrong start bit and thus ignored.<\/li>\n<li>If the start bit is valid, data bits are sampled every 16th cycle of Baud16 based on the length of the data character.\u00a0If the parity mode is enabled, the parity bit is also detected.<\/li>\n<li>If RX is high, a valid stop bit will be acknowledged. Otherwise, a framing error will occur.<\/li>\n<li>When a complete data packet is received, the data is stored in the receiving FIFO.<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h4>Interrupt Control<\/h4>\n<ul>\n<li>The goal of interrupts is to send the content of a buffer automatically.<\/li>\n<li>User can use interrupts in the event of:\n<ul>\n<li>FIFO Overflow Error<\/li>\n<\/ul>\n<ul>\n<li>Line-break error (RX signal remains 0 including the check and the stop bit.)<\/li>\n<\/ul>\n<ul>\n<li>Parity error<\/li>\n<\/ul>\n<ul>\n<li>Frame error (Stop bit not 1)<\/li>\n<\/ul>\n<ul>\n<li>Receiving timeout (receiving FIFO has data but not full and subsequent data does not transmit)<\/li>\n<\/ul>\n<ul>\n<li>Transmitting<\/li>\n<\/ul>\n<ul>\n<li>Receiving<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h3>FIFO Operation<\/h3>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<ul>\n<li>UART module of the Stellaris family of ARM CPUs contain two 16-byte FIFOs: one for transmission and one for the reception.<\/li>\n<li>They can be configured to trigger interrupts at various depths. For example, 1\/8, 1\/4, 1\/2, 3\/4, and 7\/8 depth.<\/li>\n<li>If the receiving FIFO triggers an interrupt at 1\/4, a receive interrupt is triggered when the UART receives 4 data.<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<p><strong>Working process of\u00a0transmitting\u00a0FIFO:<\/strong><\/p>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<ol>\n<li>The process is initiated as soon as data is entered. The transmission is time-consuming, thus, other data that needs to be sent can continue to enter the transmitting FIFO.<\/li>\n<li>When the transmitting FIFO is full, the user will have to wait, or you will lose your data.<\/li>\n<li>The transmitting FIFO will send the data bit by bit until the transmitting FIFO is completely empty. After transmitted data is clear, an extra slot will be added in the transmitting FIFO.<\/li>\n<\/ol>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<p><strong>Working process of\u00a0receiving\u00a0FIFO:<\/strong><\/p>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<ol>\n<li>When the hardware receives the data, it will be stored into the receiving FIFO.\u00a0The program will retrieve and erase the data automatically from the receiving FIFO, so there will be space in the receiving FIFO.\u00a0If the data in the receiving FIFO is not erased and the receiving FIFO is full, the data will be lost.<\/li>\n<li>The transceiver FIFO is to solve the issue regarding the CPU being inefficient and the UART transceiver being interrupted too frequently. Using UART communication, the interrupt mode is simpler and more efficient than the polling method.\u00a0With no transceiver FIFO, each data will be interrupted once and become inefficient.\u00a0With a transceiver FIFO, it can generate an interrupt and constantly transmit and receive data (up to 14), which improves the transmission and reception efficiency.<\/li>\n<li>Data loss would not occur as a result of the FIFO as it has already foreseen any problems in the process of sending and receiving. As long as the UART is initialized, the interrupt routine will do everything automatically.<\/li>\n<\/ol>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h4>Loopback<\/h4>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<ul>\n<li>UART has an internal loopback function for diagnostics or debugging where data is sent from TX will be received by the RX input.<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h4>Serial Infrared Protocol<\/h4>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<ul>\n<li>UART has an IrDA Serial Infrared (SIR) encoder\/decoder module.\u00a0The IrDA SIR module translates between an asynchronous UART data stream and a half-duplex serial SIR interface.<\/li>\n<li>It is used to provide a digital coded output and a decoded input to the UART.\u00a0The UART signal pin can be connected to an infrared transceiver for the IrDA SIR physical layer connection.<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h3>Advantages of Using UART<\/h3>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<ul>\n<li>Simple to operate, well documented as it is a widely used method with a lot of resources online<\/li>\n<li>No clock needed<\/li>\n<li>Parity bit to allow for error checking<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h3>Disadvantages of Using UART<\/h3>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<ul>\n<li>Size of the data frame is limited to only 9 bits<\/li>\n<li>Cannot use multiple master systems and slaves<\/li>\n<li>Baud rates of each UART must be within 10% of each other to prevent data loss.<\/li>\n<li>Low data transmission speeds<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<hr class=\"wp-block-separator\" \/>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h3>Examples of UART in Microcontrollers:<\/h3>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h4 id=\"mce_12\"><a href=\"https:\/\/www.seeedstudio.com\/USB-CP2102-Serial-Converter-p-2825.html?utm_source=blog&amp;utm_medium=blog\">USB CP2102 Serial Converter<\/a><\/h4>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><a href=\"https:\/\/www.seeedstudio.com\/USB-CP2102-Serial-Converter-p-2825.html%EF%BB%BF\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" onerror=\"this.src='https:\/\/tom.tomwork.net\/wp-content\/uploads\/2020\/11\/no-picture-available-icon-1.png'\" class=\"wp-image-24764\" src=\"https:\/\/blog.seeedstudio.com\/wp-content\/uploads\/2019\/09\/3-1.jpg\" sizes=\"auto, (max-width: 307px) 100vw, 307px\" srcset=\"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2019\/09\/3-1.jpg 307w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2019\/09\/3-1-300x215.jpg 300w\" alt=\"\" width=\"307\" height=\"220\" \/><\/a><figcaption><\/figcaption><\/figure>\n<\/div>\n<ul>\n<li>Highly-integrated USB to UART bridge controller providing a simple solution for updating RS-232 designs to USB using minimum components and PCB space. It provides USB connectivity to devices with a UART interface.\n<ul>\n<li>It uses a standard USB type A male and TTL 6pin connector<\/li>\n<\/ul>\n<\/li>\n<li>This USB CP2102 Serial Converter is a small adapter for Arduino\/Seeeduino board to accept firmware upgrades from a computer.<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h4><a href=\"https:\/\/www.seeedstudio.com\/USB-To-Uart-5V-p-1833.html?utm_source=blog&amp;utm_medium=blog\">FT232r USB UART \/ USB to UART 5V<\/a><\/h4>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><a href=\"https:\/\/www.seeedstudio.com\/USB-To-Uart-5V-p-1833.html\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" onerror=\"this.src='https:\/\/tom.tomwork.net\/wp-content\/uploads\/2020\/11\/no-picture-available-icon-1.png'\" class=\"wp-image-24830\" src=\"https:\/\/blog.seeedstudio.com\/wp-content\/uploads\/2019\/09\/Capture.jpg\" sizes=\"auto, (max-width: 176px) 100vw, 176px\" srcset=\"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2019\/09\/Capture.jpg 705w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2019\/09\/Capture-300x246.jpg 300w\" alt=\"\" width=\"176\" height=\"145\" \/><\/a><\/figure>\n<\/div>\n<ul>\n<li>Seeed offers a similar product: USB to UART 5V<\/li>\n<li>This is a USB to serial UART interface which simplifies USB to serial designs.<\/li>\n<li>Reduces external component count while operating efficiently with a USB host controller using as little as possible of the total USB bandwidth available.<\/li>\n<li>For the USB to UART 5V, it is based on CH340 which is a USB bus convert chip and it can realize USB convert to a serial interface.\n<ul>\n<li>This USB will convert to IrDA infrared or USB convert to printer interface and can also be used for uploading code or communicating with MCUs.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h4><a href=\"https:\/\/www.seeedstudio.com\/Seeeduino-V4-2-p-2517.html?utm_source=blog&amp;utm_medium=blog\">UART Seeeduino V4.2<\/a><\/h4>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><a href=\"https:\/\/www.seeedstudio.com\/Seeeduino-V4-2-p-2517.html\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" onerror=\"this.src='https:\/\/tom.tomwork.net\/wp-content\/uploads\/2020\/11\/no-picture-available-icon-1.png'\" class=\"wp-image-24766\" src=\"https:\/\/blog.seeedstudio.com\/wp-content\/uploads\/2019\/09\/5.jpg\" sizes=\"auto, (max-width: 434px) 100vw, 434px\" srcset=\"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2019\/09\/5.jpg 578w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2019\/09\/5-300x146.jpg 300w\" alt=\"\" width=\"434\" height=\"211\" \/><\/a><\/figure>\n<\/div>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<ul>\n<li>All Arduino boards have at least one serial port (UART) which communicates on digital pins 0 (RX) and 1 (TX) as well with the computer via USB.<\/li>\n<li>This is an Arduino-compatible board, which is based on ATmga328P MCU. With an ATMEGA16U2 as a UART-to-USB converter, the board can basically work like an FTDI chip and it can be programmed via a micro-USB cable.<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h4><a href=\"https:\/\/www.seeedstudio.com\/Base-Shield-V2.html?utm_source=blog&amp;utm_medium=blog\">Base Shield V2<\/a><\/h4>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><a href=\"https:\/\/www.seeedstudio.com\/Base-Shield-V2.html\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" onerror=\"this.src='https:\/\/tom.tomwork.net\/wp-content\/uploads\/2020\/11\/no-picture-available-icon-1.png'\" class=\"wp-image-24833\" src=\"https:\/\/blog.seeedstudio.com\/wp-content\/uploads\/2019\/09\/Capture4.jpg\" sizes=\"auto, (max-width: 277px) 100vw, 277px\" srcset=\"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2019\/09\/Capture4.jpg 554w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2019\/09\/Capture4-80x80.jpg 80w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2019\/09\/Capture4-300x295.jpg 300w\" alt=\"\" width=\"277\" height=\"272\" \/><\/a><\/figure>\n<\/div>\n<ul>\n<li>Arduino Uno is the most popular Arduino board so far, however, it is sometimes frustrating when your project requires a lot of sensors or LEDs and your jumper wires are in a mess.<\/li>\n<li>The purpose of this product is to help you get rid of the breadboard and jump wires. With the rich grove connectors on the baseboard, you can add all the grove modules to the Arduino Uno very conveniently!<\/li>\n<li>These devices can be connected via UART and I2C (the next communication peripheral which I am going to touch on!)<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<hr class=\"wp-block-separator\" \/>\n<h2><strong>I2C Interface<\/strong><\/h2>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h3>What is I2C?<\/h3>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<ul>\n<li>Stands for\u00a0<strong>Inter-integrated-circuit<\/strong>\u00a0<strong>(I2C)<\/strong><\/li>\n<li>It is a serial communications protocol similarly to UART. However, it is not used for PC-device communication but instead with modules and sensors.<\/li>\n<li>It is a simple, bidirectional two-wire synchronous serial bus and requires only two wires to transmit information between devices connected to the bus.<\/li>\n<li>They are useful for projects that require many different parts (eg. sensors, pin, expansions and drivers) working together as they can connect up to 128 devices to the mainboard while maintaining a clear communication pathway!<\/li>\n<li>This is because I2C uses an address system and a shared bus = many different devices can be connected using the same wires and all data are transmitted on a single wire and have a low pin count. However, the tradeoff for this simplified wiring is that it is slower than SPI.<\/li>\n<li>Speed of I2C is also dependent by data speed, wire quality and external noise<\/li>\n<li>The I2C protocol is also\u00a0used as a two-wire interface to connect low-speed devices like microcontrollers, EEPROMs, A\/D and D\/A converters, I\/O interfaces and other similar peripherals in embedded systems.<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h3>How does it work?<\/h3>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<ul>\n<li>It has 2 Lines which are SCL (serial clock line) and SDA (serial data line acceptance port)<\/li>\n<li>CL is the clock line for synchronizing transmission. SDA is the data line through which bits of data are sent or received.<\/li>\n<li>The master device initiates the bus transfer of data and generates a clock to open the transferred device and any addressed device is considered a slave device.<\/li>\n<li>The relationship between master and slave devices, transmitting and receiving on the bus is not constant. It depends on the direction of data transfer at the time.<\/li>\n<li>If the master wants to send data to the slave, the master must first address the slave before sending any data.<\/li>\n<li>The master will then terminate the data transfer. If the master wants to receive data from the slave, the master must again address the slave first.<\/li>\n<li>The host then receives the data sent by the slave and finally, the receiver terminates the receiving process.\u00a0The host is also responsible for generating the timing clock and terminating the data transfer.<\/li>\n<li>It is also necessary to connect the power supply through a pull-up resistor.\u00a0When the bus is idle, both lines operate on a high power level.<\/li>\n<li>The capacitance in the line will affect the bus transmission speed. As the current power on the bus is small,\u00a0when the capacitance is too large, it may cause transmission errors.\u00a0Thus, its load capacity must be\u00a0400pF, so the allowable length of the bus and the number of connected devices can be estimated.<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h3>I2C Working Protocol<\/h3>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h4>Data Transmission Method<\/h4>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<ul>\n<li>The master sends the transmitting signal to every connected slave by switching the SDA line from a high voltage\u00a0level to a low voltage level and\u00a0SCL line from high to low after switching the SDA line.<\/li>\n<li>The master sends each slave the 7 or 10-bit address of the slave and a read\/write bit to the slave it wants to communicate with.<\/li>\n<li>The slave will then compare the address with its own. If the address matches, the slave returns an ACK bit which switches the SDA line low for one bit. If the address does not match its address, the slave leaves\u00a0the SDA line high<\/li>\n<li>The master will then send or receive the data frame. After each data frame has been transferred, the receiving device returns another\u00a0ACK bit to the sender to\u00a0acknowledge successful transmission.<\/li>\n<li>To stop the data transmission, the master sends a stop signal to the slave by switching\u00a0SCL high before switching SDA high<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h4>Clock Synchronisation<\/h4>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<ul>\n<li>All masters generate their own clocks on the SCL line to transmit messages on the I2C bus.<\/li>\n<li>Data is only valid during the high period of the clock.<\/li>\n<li>Clock synchronization is performed by connecting the I2C interface to the SCL line where the switch goes from high to low. Once the device\u2019s clock goes low, it keeps the SCL line in this state until it reaches the high level of the clock.<\/li>\n<li>If another clock is still in a low period, the low-to-high switch does not change the state of the SCL line. The SCL line is always held low by the device with the longest low period.\u00a0At this time, the device with a short and low period will enter a high and waiting state.<\/li>\n<li>When all relevant devices have completed their low period, the clock line goes high.<\/li>\n<li>After that, there is no difference in the state of the device clock and the SCL line, and all devices begin to count their high period.\u00a0The device that first completes the high period will pull the SCL line low again.<\/li>\n<li>The low period of the synchronous SCL clock is determined by the device with the longest low clock period, while the high period is determined by the device with the shortest high clock period.<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h3>Transmission Modes<\/h3>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h4>Quick Mode:<\/h4>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<ul>\n<li>Fast mode devices can receive and transmit at 400kbit\/s.\u00a0They have to be able to synchronize with a 400kbit\/s transmission and extend the low period of the SCL signal to slow down the transmission.<\/li>\n<li>Fast mode devices are backwards compatible and can communicate with standard mode devices from 0 to 100 kbit\/s I2C bus systems.\u00a0However, as standard mode devices are not upward compatible, they cannot operate in a fast I2C bus system.\u00a0The fast mode I2C bus specification has the following characteristics compared to the standard mode:\n<ul>\n<li>The maximum bit rate is increased to 400 kbit\/s;<\/li>\n<\/ul>\n<ul>\n<li>Adjusted the timing of the serial data (SDA) and serial clock (SCL) signals.<\/li>\n<\/ul>\n<ul>\n<li>Has the function of suppressing glitch and the SDA and SCL inputs have Schmitt triggers.<\/li>\n<\/ul>\n<ul>\n<li>The output buffer has a slope control function for the falling edges of the SDA and SCL signals<\/li>\n<\/ul>\n<ul>\n<li>Once the power supply of the fast mode device is turned off, the I\/O pins of SDA and SCL must be left idle and cannot block the bus.<\/li>\n<\/ul>\n<ul>\n<li>The external pull-up device connected to the bus must be tuned to accommodate the shortest maximum allowable rise time of the fast mode I2C bus.\u00a0For buses with a maximum load of 200pF, the pull-up device of each bus can be a resistor. For a bus with a load between 200pF and 400pF, the pull-up device can be a current source (maximum 3mA) or a switched resistor circuit.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h4>High-Speed Mode:<\/h4>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<ul>\n<li>Hs mode devices can transmit information at bit rates up to 3.4 Mbit\/s and remain fully backwards compatible with fast mode or standard mode (F\/S mode) devices that can communicate bi-directionally in a speed mixed bus system.<\/li>\n<li>The Hs mode transmission has the same serial bus principle and data format as the F\/S mode system except for arbitration and clock synchronization which is not performed.<\/li>\n<li>The I2C bus specification in high-speed mode is as follows:\n<ul>\n<li>In high speed (Hs) mode, the master device has an open-drain output buffer for the high-speed (SDAH) signal and an open-drain pull-down and current source pull-up circuit at the high-speed serial clock (SCLH) output.\u00a0This shortens the rise time of the SCLH signal and at any time, only one host current source is active;<\/li>\n<\/ul>\n<ul>\n<li>In the Hs mode of a multi-master system, arbitration and clock synchronization are not performed in order to speed up the bit processing capability.\u00a0The arbitration process normally ends after the host code is transmitted in the F\/S mode.<\/li>\n<\/ul>\n<ul>\n<li>The Hs mode master device generates a high and low serial clock signal with a ratio of 1:2 which removes the timing requirements for setup and hold time.<\/li>\n<\/ul>\n<ul>\n<li>The Hs mode device can have a built-in bridge.\u00a0During Hs mode transmission, the SDAH and SCLH lines of the Hs mode device are separated from the SDA and SCL lines which\u00a0reduces the capacitive loading of the SDAH and SCLH lines and make rise and fall faster.<\/li>\n<\/ul>\n<ul>\n<li>The difference between Hs mode slave devices and F\/S slave devices is the speed at which they operate.<\/li>\n<\/ul>\n<ul>\n<li>The Hs mode device can suppress glitches, and the SDAH and SCLH outputs also have a Schmitt trigger;<\/li>\n<\/ul>\n<ul>\n<li>The output buffer of the Hs mode device has a slope control function for the falling edges of the SDAH and SCLH signals.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h3>Advantages of using I2C<\/h3>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<ul>\n<li>Has a low pin\/signal count even with numerous devices on the bus<\/li>\n<li>Flexible, as it supports multi-master and multi slave communication.<\/li>\n<li>Simple as it only uses 2 bidirectional wires to establish communication among multiple devices.<\/li>\n<li>Adaptable as it can adapt to the needs of various slave devices.<\/li>\n<li>Support multiple masters.<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h3>Disadvantages of using I2C<\/h3>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<ul>\n<li>Slower speed as it requires pull-up resistors rather than push-pull resistors used by SPI.\u00a0 It also has an open-drain design = limited speed.<\/li>\n<li>Requires more space as the resistors consume valuable PCB real estate.<\/li>\n<li>May become complex as the number of devices increases.<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<hr class=\"wp-block-separator\" \/>\n<h3>Examples of I2C in Microcontrollers<\/h3>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h4><a href=\"https:\/\/www.seeedstudio.com\/Grove-I2C-Hub-6-Port-p-4349.html?utm_source=blog&amp;utm_medium=blog\">Grove \u2013 I2C Hub (6 Port)<\/a><\/h4>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" onerror=\"this.src='https:\/\/tom.tomwork.net\/wp-content\/uploads\/2020\/11\/no-picture-available-icon-1.png'\" class=\"wp-image-27048\" src=\"https:\/\/blog.seeedstudio.com\/wp-content\/uploads\/2019\/11\/image-67.png\" sizes=\"auto, (max-width: 211px) 100vw, 211px\" srcset=\"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2019\/11\/image-67.png 412w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2019\/11\/image-67-300x272.png 300w\" alt=\"\" width=\"211\" height=\"192\" \/><\/figure>\n<\/div>\n<ul>\n<li>I2C is a very popular communication protocol. In the Grove system, I2C is used by 80+ sensors for communication, 19 of which are related to environmental monitoring.<\/li>\n<li>Today more and more MCUs uses 3.3V communication levels, but the traditional ArduinoUno still uses 5V, which leads to many modules, especially sensor modules, needing to be levelled when using them.<\/li>\n<li>We actually worked on this area, and now most of the Grove sensor modules have a level shifting function, and users do not need to consider the use of 3.3V or 5V MCU when using it. This is in line with Grove\u2019s motto; plugin, and use it, it\u2019s that simple. For a more detailed sensor review compatibility, you can view our\u00a0<a href=\"https:\/\/www.seeedstudio.com\/blog\/2019\/09\/04\/grove-selection-guide\/\">Grove Selection Guide<\/a>.<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h4><a href=\"https:\/\/www.seeedstudio.com\/4-Channel-16-Bit-ADC-for-Raspberry-Pi-ADS1115-p-2829.html?utm_source=blog&amp;utm_medium=blog\">4-Channel 16-Bit ADC for Raspberry Pi (ADS1115)<\/a><\/h4>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><a href=\"https:\/\/www.seeedstudio.com\/4-Channel-16-Bit-ADC-for-Raspberry-Pi-ADS1115-p-2829.html\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" onerror=\"this.src='https:\/\/tom.tomwork.net\/wp-content\/uploads\/2020\/11\/no-picture-available-icon-1.png'\" class=\"wp-image-24832\" src=\"https:\/\/blog.seeedstudio.com\/wp-content\/uploads\/2019\/09\/Capture3.jpg\" sizes=\"auto, (max-width: 298px) 100vw, 298px\" srcset=\"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2019\/09\/Capture3.jpg 596w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2019\/09\/Capture3-300x220.jpg 300w\" alt=\"\" width=\"298\" height=\"219\" \/><\/a><\/figure>\n<\/div>\n<ul>\n<li>This product by Seeed is fully compatible with Raspberry Pi.<\/li>\n<li>It is used for a Raspberry Pi without an analog-to-digital converter, or when you need a more accurate ADC.<\/li>\n<li>We provide 4-channel 16-bit ADC for Raspberry Pi (ADS1115) over I2C, a 4-channel ADC based on Texas Instrument ADS1115, which is a high-precision, low-power, 16-bit ADC chip.<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h4>I2C Arduino<\/h4>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<ul>\n<li>I2C communication can also be used between two Arduino boards<\/li>\n<li>Used only for short-distance communication and uses a synchronised clock pulse.<\/li>\n<li>Mainly used to communicate with sensors or other devices which have to send information to a master.<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h4><a href=\"https:\/\/www.seeedstudio.com\/I2C-Driver-Adapter-Easily-Driver-I2C-Devices-p-4022.html?utm_source=blog&amp;utm_medium=blog\">I2C Driver\/Adapter-Easily Driver I2C Devices<\/a><\/h4>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><a href=\"https:\/\/www.seeedstudio.com\/I2C-Driver-Adapter-Easily-Driver-I2C-Devices-p-4022.html\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" onerror=\"this.src='https:\/\/tom.tomwork.net\/wp-content\/uploads\/2020\/11\/no-picture-available-icon-1.png'\" class=\"wp-image-24896\" src=\"https:\/\/blog.seeedstudio.com\/wp-content\/uploads\/2019\/09\/I2C-Driver-10.gif\" alt=\"\" width=\"500\" height=\"317\" \/><\/a><\/figure>\n<\/div>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<ul>\n<li>I\u00b2C Driver is an easy-to-use, open-source tool for controlling I\u00b2C devices. It works with Windows, Mac, and Linux, and has a built-in colour screen that shows a live \u201cdashboard\u201d of all the I\u00b2C activity.<\/li>\n<li>With the built-in display shows a heatmap of all active network nodes, you are able to observe from an I\u00b2C network with multiple devices which ones are the most active.<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><a href=\"https:\/\/www.seeedstudio.com\/I2C-Driver-Adapter-Easily-Driver-I2C-Devices-p-4022.html\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" onerror=\"this.src='https:\/\/tom.tomwork.net\/wp-content\/uploads\/2020\/11\/no-picture-available-icon-1.png'\" class=\"wp-image-24897\" src=\"https:\/\/blog.seeedstudio.com\/wp-content\/uploads\/2019\/09\/I2C-Driver-11.gif\" alt=\"\" width=\"500\" height=\"317\" \/><\/a><\/figure>\n<\/div>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<ul>\n<li>When an I\u00b2C Driver is connected to an existing I\u00b2C bus, it \u201csnoops\u201d the traffic and displays it on the screen.<\/li>\n<li>This provides an excellent tool for debugging I\u00b2C issues because you can listen in on the conversation as it happens.<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h4>MCP 23017<\/h4>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" onerror=\"this.src='https:\/\/tom.tomwork.net\/wp-content\/uploads\/2020\/11\/no-picture-available-icon-1.png'\" class=\"wp-image-24768\" src=\"https:\/\/blog.seeedstudio.com\/wp-content\/uploads\/2019\/09\/7.jpg\" alt=\"\" width=\"214\" height=\"156\" \/><figcaption>Ref: Electronicwings, MCP23017 16-bit GPIO Expander.<\/figcaption><\/figure>\n<\/div>\n<ul>\n<li>16-bit, general-purpose parallel I\/O expansion for the I2C bus. Similar to MCP23S17 except for serial interface (I2C vs SPI).<\/li>\n<li>Port expander that gives the user virtually identical ports compared to standard microcontrollers.<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h4>PCF 8574<\/h4>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><img loading=\"lazy\" decoding=\"async\" onerror=\"this.src='https:\/\/tom.tomwork.net\/wp-content\/uploads\/2020\/11\/no-picture-available-icon-1.png'\" class=\"wp-image-24769\" src=\"https:\/\/blog.seeedstudio.com\/wp-content\/uploads\/2019\/09\/8.jpg\" alt=\"\" width=\"188\" height=\"144\" \/><figcaption>Ref: PCF8574 Serial Interface Module Board LCD Converter.<\/figcaption><\/figure>\n<\/div>\n<ul>\n<li>Provides general-purpose remote I\/O expansion via the two-wire bidirectional I2C-bus (serial clock (SCL), Serial Data (SDA)).<\/li>\n<li>Seeed will be using this in our future products, do keep a lookout!<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h4><a href=\"https:\/\/www.seeedstudio.com\/Grove-Base-Hat-for-Raspberry-Pi.html?utm_source=blog&amp;utm_medium=blog\">Grove Base Hat for Raspberry Pi<\/a><\/h4>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><a href=\"https:\/\/www.seeedstudio.com\/Grove-Base-Hat-for-Raspberry-Pi.html\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" onerror=\"this.src='https:\/\/tom.tomwork.net\/wp-content\/uploads\/2020\/11\/no-picture-available-icon-1.png'\" class=\"wp-image-24835\" src=\"https:\/\/blog.seeedstudio.com\/wp-content\/uploads\/2019\/09\/Capture5-1.jpg\" sizes=\"auto, (max-width: 401px) 100vw, 401px\" srcset=\"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2019\/09\/Capture5-1.jpg 802w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2019\/09\/Capture5-1-300x217.jpg 300w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2019\/09\/Capture5-1-768x554.jpg 768w\" alt=\"\" width=\"401\" height=\"290\" \/><\/a><\/figure>\n<\/div>\n<ul>\n<li>What is Grove?\n<ul>\n<li>It is a modular, standardized connector prototyping system. Grove takes a building block approach to assemble electronics. which makes it easier to connect, experiment and build and simplifies the learning system.<\/li>\n<\/ul>\n<\/li>\n<li>Today, the grove series of sensors, actuators, and displays have grown into a large family and today we introduce the Raspberry Pi to the whole Grove System.<\/li>\n<li>The Grove Base Hat for Raspberry Pi provides Digital\/Analog\/ I2C\/ PWM\/UART port to meet all your needs.<\/li>\n<li>With the help of the build-in MCU, a 12-bit\u00a0 8 channel ADC is also available for Raspberry Pi. Currently, more than 60 groves have supported the Grove Base Hat for Raspberry Pi.<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<hr class=\"wp-block-separator\" \/>\n<h2><strong>SPI Interface<\/strong><\/h2>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h3>What is SPI?<\/h3>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<ul>\n<li>Stands for<strong>\u00a0Serial Peripheral Interface<\/strong>\u00a0(SPI)<\/li>\n<li>It is similar to I2C and it is a different form of serial-communications protocol specially designed for microcontrollers to connect.<\/li>\n<li>Operates at full-duplex where data can be sent and received simultaneously.<\/li>\n<li>Operate at faster data transmission rates = 8Mbits or more<\/li>\n<li>It is typically faster than I2C due to the simple protocol. Even if data\/clock lines are shared between devices, each device will require a unique address wire.<\/li>\n<li>Used in places where speed is important. (eg. SD cards, display modules or when info updates and changes quickly like thermometers)<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h3>How does it work?<\/h3>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<ul>\n<li>Communicate with 2 ways:\n<ol>\n<li>Selecting each device with a Chip Select line. A separate Chip Select line is required for each device. This is the most common way RPi\u2019s currently use SPI.<\/li>\n<li>Daisy chaining where each device is connected to the other through its data out to the data in line of the next.<\/li>\n<\/ol>\n<\/li>\n<li>There is no limit to the number of SPI device that can be connected. However, there are practical limits due to the number of hardware select lines available on the main device with the chip select method or the complexity of passing data through devices in the daisy-chaining method.<\/li>\n<li>In point-to-point communication, the SPI interface does not require addressing operations and is full-duplex communication, which is simple and efficient.<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h3>SPI Working Protocol<\/h3>\n<ul>\n<li>The SPI communicates via 4 ports which are:\n<ul>\n<li>MOSI \u2013 Master Data Output, Slave Data Input<\/li>\n<\/ul>\n<ul>\n<li>MISO \u2013 master data input, slave data output<\/li>\n<\/ul>\n<ul>\n<li>SCLK \u2013 clock signal, generated by the master device, up to fPCLK\/2, slave mode frequency up to fCPU\/2<\/li>\n<\/ul>\n<ul>\n<li>NSS \u2013 Slave enabled signal, controlled by the master device, some ICs will be labelled as CS (Chip select)<\/li>\n<\/ul>\n<\/li>\n<li>In a multi-slave system, each slave requires a separate enable signal, which is slightly more complicated on hardware than the I2C system.<\/li>\n<li>The SPI interface is actually two simple shift registers in the internal hardware. The transmitted data is 8 bits. It is transmitted bit by bit under the slave enable signal and shift pulse generated by the master device. The high bit is in the front and the low bit is in the back.<\/li>\n<li>The SPI interface is synchronous serial data transmission between the CPU and the peripheral low-speed device. Under the shift pulse of the master device, the data is transmitted bit by bit. The high bit is in the front and the low bit is in the back. It is full-duplex communication, and the data transmission speed is overall faster than the I2C bus and can reach speeds of a few Mbps.<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h3>Advantages of using SPI<\/h3>\n<ul>\n<li>The protocol is simple as there is no complicated slave addressing system like I2C.<\/li>\n<li>It is the fastest protocol compared to UART and I2C.<\/li>\n<li>No start and stop bits unlike UART which means data can be transmitted continuously without interruption<\/li>\n<li>Separate MISO and MOSI lines which means data can be transmitted and received at the same time<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h3>Disadvantages of using SPI<\/h3>\n<ul>\n<li>More Pin ports are occupied, the practical limit to a number of devices.<\/li>\n<li>There is no flow control specified, and no acknowledgement mechanism confirms whether data is received unlike I2C<\/li>\n<li>Uses four lines \u2013 MOSI, MISO, NCLK, NSS<\/li>\n<li>No form of error check unlike in UART (using parity bit)<\/li>\n<li>Only 1 master<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<hr class=\"wp-block-separator\" \/>\n<h3>Examples of SPI in Microcontrollers:<\/h3>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h4><a href=\"https:\/\/www.seeedstudio.com\/8-Channel-12-Bit-ADC-for-Raspberry-Pi-STM32F030-p-2830.html?utm_source=blog&amp;utm_medium=blog\">MCP 3008 \/ Grove I2C ADC<\/a><\/h4>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><a href=\"https:\/\/www.seeedstudio.com\/8-Channel-12-Bit-ADC-for-Raspberry-Pi-STM32F030-p-2830.html\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" onerror=\"this.src='https:\/\/tom.tomwork.net\/wp-content\/uploads\/2020\/11\/no-picture-available-icon-1.png'\" class=\"wp-image-24831\" src=\"https:\/\/blog.seeedstudio.com\/wp-content\/uploads\/2019\/09\/Capture2.jpg\" sizes=\"auto, (max-width: 311px) 100vw, 311px\" srcset=\"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2019\/09\/Capture2.jpg 621w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2019\/09\/Capture2-300x236.jpg 300w\" alt=\"\" width=\"311\" height=\"245\" \/><\/a><\/figure>\n<\/div>\n<ul>\n<li>Seeed does offer a similar product which has the same functions: Grove I2C ADC but its communication peripheral is I2C.<\/li>\n<li>It is 10 bit 8-channel analogue-to-digital converter (ADC).<\/li>\n<li>For the MCP 3008, it connects to the Raspberry Pi using an SPI serial connection. Done by using the hardware SPI bus or any four GPIO pins and software SPI to connect to the MCP 3008.<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h4><a href=\"https:\/\/www.seeedstudio.com\/Serial-CAN-BUS-Module-based-on-MCP2551-and-MCP2515.html?utm_source=blog&amp;utm_medium=blog\">Serial CAN-BUS Module based on MCP2551 and MCP2515<\/a><\/h4>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><a href=\"https:\/\/www.seeedstudio.com\/Serial-CAN-BUS-Module-based-on-MCP2551-and-MCP2515.html\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" onerror=\"this.src='https:\/\/tom.tomwork.net\/wp-content\/uploads\/2020\/11\/no-picture-available-icon-1.png'\" class=\"wp-image-24771\" src=\"https:\/\/blog.seeedstudio.com\/wp-content\/uploads\/2019\/09\/10.jpg\" sizes=\"auto, (max-width: 254px) 100vw, 254px\" srcset=\"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2019\/09\/10.jpg 338w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2019\/09\/10-300x178.jpg 300w\" alt=\"\" width=\"254\" height=\"151\" \/><\/a><\/figure>\n<\/div>\n<ul>\n<li>This Seeed product: Serial CAN Bus module provides your Arduino with CAN bus capabilities and allows you to hack your vehicle. It lets you read and write messages to the CAN bus.<\/li>\n<li>CAN bus is a messaging protocol system that lets various microcontrollers and sensors within a vehicle to talk to each other. CAN provides long-distance, medium communication speed, and high reliability.<\/li>\n<li>This Serial CAN Bus module can also be connected to your Arduino through the on-board Grove connector.<\/li>\n<li>Interfaces with microcontrollers via SPI.<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h4><a href=\"https:\/\/www.seeedstudio.com\/Seeeduino-V4-2-p-2517.html?utm_source=blog&amp;utm_medium=blog\">SPI Seeeduino V4.2<\/a><\/h4>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><a href=\"https:\/\/www.seeedstudio.com\/Seeeduino-V4-2-p-2517.html\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" onerror=\"this.src='https:\/\/tom.tomwork.net\/wp-content\/uploads\/2020\/11\/no-picture-available-icon-1.png'\" class=\"wp-image-24772\" src=\"https:\/\/blog.seeedstudio.com\/wp-content\/uploads\/2019\/09\/11.jpg\" sizes=\"auto, (max-width: 329px) 100vw, 329px\" srcset=\"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2019\/09\/11.jpg 438w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2019\/09\/11-300x242.jpg 300w\" alt=\"\" width=\"329\" height=\"265\" \/><\/a><\/figure>\n<\/div>\n<ul>\n<li>SPI serial communication can be used with Arduino for communication between two Arduinos where one Arduino will act as master and another one will act as a slave.<\/li>\n<li>Used to communicate over short distances at high speed.<\/li>\n<li>This is the same product: Arduino v4.2 from the above UART example<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h4><a href=\"https:\/\/www.seeedstudio.com\/ENC28J60-OVERLAYS-HAT-for-Raspberry-pi-p-3045.html?utm_source=blog&amp;utm_medium=blog\">ENC28J60 OVERLAYS HAT for Raspberry pi<\/a><\/h4>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><a href=\"https:\/\/www.seeedstudio.com\/ENC28J60-OVERLAYS-HAT-for-Raspberry-pi-p-3045.html%EF%BB%BF\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" onerror=\"this.src='https:\/\/tom.tomwork.net\/wp-content\/uploads\/2020\/11\/no-picture-available-icon-1.png'\" class=\"wp-image-24774\" src=\"https:\/\/blog.seeedstudio.com\/wp-content\/uploads\/2019\/09\/12.jpg\" sizes=\"auto, (max-width: 413px) 100vw, 413px\" srcset=\"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2019\/09\/12.jpg 413w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2019\/09\/12-300x132.jpg 300w\" alt=\"\" width=\"413\" height=\"182\" \/><\/a><\/figure>\n<\/div>\n<ul>\n<li>The Pi zero ENC28J60 is a simple Network Adapter module for Pi zero that is very easy to assemble and configure.<\/li>\n<li>It allows your Raspberry Pi zero to access the network smoothly, and it is easy to do system updates and software installation operations.<\/li>\n<li>Microchip\u2019s ENC28J60 is a 28-pin, 10BASE-T stand-alone Ethernet controller with an SPI interface.<\/li>\n<li>The SPI interface serves as a communication channel between the host controller and the ENC28J60.<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h4><a href=\"https:\/\/www.seeedstudio.com\/SPI-Driver-Adapter-Easily-Driver-SPI-Devices-p-4023.html?utm_source=blog&amp;utm_medium=blog\">SPI Driver\/Adapter-Easily Driver SPI Devices<\/a><\/h4>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><a href=\"https:\/\/www.seeedstudio.com\/SPI-Driver-Adapter-Easily-Driver-SPI-Devices-p-4023.html\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" onerror=\"this.src='https:\/\/tom.tomwork.net\/wp-content\/uploads\/2020\/11\/no-picture-available-icon-1.png'\" class=\"wp-image-24894\" src=\"https:\/\/blog.seeedstudio.com\/wp-content\/uploads\/2019\/09\/SPI-Driver-4.gif\" alt=\"\" width=\"500\" height=\"317\" \/><\/a><\/figure>\n<\/div>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<ul>\n<li>This is a similar product as the\u00a0<a href=\"https:\/\/www.seeedstudio.com\/I2C-Driver-Adapter-Easily-Driver-I2C-Devices-p-4022.html\">I2C Driver\/Adapter-Easily Driver I2C Device<\/a>\u00a0but for SPI instead. It is an easy-to-use tool for controlling SPI devices. It works with Windows, Mac, and Linux, and has a built-in colour screen that shows a live logic-analyzer display of all SPI traffic.<\/li>\n<li>Similarly, it uses a standard FTDI USB serial chip to talk to the PC, so no special drivers need to be installed. The board includes 3.3 and 5 V supplies with voltage and current monitoring.<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter is-resized\"><a href=\"https:\/\/www.seeedstudio.com\/SPI-Driver-Adapter-Easily-Driver-SPI-Devices-p-4023.html\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" onerror=\"this.src='https:\/\/tom.tomwork.net\/wp-content\/uploads\/2020\/11\/no-picture-available-icon-1.png'\" class=\"wp-image-24895\" src=\"https:\/\/blog.seeedstudio.com\/wp-content\/uploads\/2019\/09\/SPI-Driver-3.gif\" alt=\"\" width=\"500\" height=\"317\" \/><\/a><\/figure>\n<\/div>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<ul>\n<li>SPI flash is very common, and by using a test clip, SPIDriver makes it convenient to read and write SPI flash in-circuit. A short script is all it takes to read or write an Atmel\u2019s flash and SPI LED strips are also easy to hook up to the SPI Driver, You can also be able to control them directly which makes them much more fun!<\/li>\n<li>Using SPI in this secnario is fast enough to smoothly animate long strips and achieve POV effects. Short strips can also be powered directly by the SPIDriver\u2019s beefy 470 mA built-in supply.<\/li>\n<\/ul>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<h2>So, which of these communication peripherals is the \u201cbest\u201d? UART, SPI or I2C?<\/h2>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<p>Unfortunately, there is no \u201cbest\u201d communication peripheral. Each communication peripheral has its own advantages and disadvantages.<\/p>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<p>Thus, a user should pick a communication peripheral that suits your project the best. For example, you want the fastest communication peripheral, SPI would be the ideal pick. On another hand, if a user wants to connect many devices without it being too complex, I2C will be the ideal pick as it can connect up to 127 devices and it is simple to manage.<\/p>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<hr class=\"wp-block-separator\" \/>\n<h2><strong>Summary<\/strong><\/h2>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<p>In summary, I have compiled all the various advantages\/disadvantages and functions of the various communication protocols and compared them so you can easily pick which is the best for your project.\u00a0<strong>Do keep in mind that the device, accessory, module or sensor you are using must support the communication protocol as well.<\/strong><\/p>\n<div class=\"wp-block-spacer\" aria-hidden=\"true\"><\/div>\n<table class=\"tg\">\n<colgroup>\n<col \/>\n<col \/>\n<col \/>\n<col \/><\/colgroup>\n<thead>\n<tr>\n<th class=\"tg-ri3q\">Protocol<\/th>\n<th class=\"tg-ri3q\">UART<\/th>\n<th class=\"tg-btmp\">I2C<\/th>\n<th class=\"tg-btmp\">SPI<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td class=\"tg-fymr\">Complexity<\/td>\n<td class=\"tg-lboi\">Simple<\/td>\n<td class=\"tg-cly1\">Easy to chain multiple devices<\/td>\n<td class=\"tg-cly1\">Complex as device<br \/>\nincreases<\/td>\n<\/tr>\n<tr>\n<td class=\"tg-fymr\">Speed<\/td>\n<td class=\"tg-lboi\">Slowest<\/td>\n<td class=\"tg-cly1\">Faster than UART<\/td>\n<td class=\"tg-cly1\">Fastest<\/td>\n<\/tr>\n<tr>\n<td class=\"tg-fymr\">Number of devices<\/td>\n<td class=\"tg-lboi\">Up to 2 devices<\/td>\n<td class=\"tg-cly1\">Up to 127, but gets complex<\/td>\n<td class=\"tg-cly1\">Many, but gets complex<\/td>\n<\/tr>\n<tr>\n<td class=\"tg-fymr\">Number of wires<\/td>\n<td class=\"tg-lboi\">1<\/td>\n<td class=\"tg-cly1\">2<\/td>\n<td class=\"tg-cly1\">4<\/td>\n<\/tr>\n<tr>\n<td class=\"tg-fymr\">Duplex<\/td>\n<td class=\"tg-lboi\">Full Duplex<\/td>\n<td class=\"tg-cly1\">Half Duplex<\/td>\n<td class=\"tg-cly1\">Full Duplex<\/td>\n<\/tr>\n<tr>\n<td class=\"tg-1wig\">No. of masters and slaves<\/td>\n<td class=\"tg-cly1\">Single to Single<\/td>\n<td class=\"tg-cly1\">Multiple slaves and masters<\/td>\n<td class=\"tg-cly1\">1 master, multiple slaves<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>When we\u2019re talking communication protocols, a UART, SPI and I2C are the common hardware interfaces people use in microcontroller development. This article will compare the various interfaces: UART, SPI and I2C and their differences. We will be comparing them with various factors through their protocols, advantages and disadvantages of each interface, etc and we will [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[13],"tags":[],"class_list":["post-25916","post","type-post","status-publish","format-standard","hentry","category-13"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6cOVM-6K0","_links":{"self":[{"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=\/wp\/v2\/posts\/25916","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=25916"}],"version-history":[{"count":1,"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=\/wp\/v2\/posts\/25916\/revisions"}],"predecessor-version":[{"id":25917,"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=\/wp\/v2\/posts\/25916\/revisions\/25917"}],"wp:attachment":[{"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=25916"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=25916"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tom.tomwork.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=25916"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}