{"id":61842,"date":"2025-06-10T15:26:01","date_gmt":"2025-06-10T19:26:01","guid":{"rendered":"https:\/\/www.engineersgarage.com\/?p=61842"},"modified":"2025-06-11T12:15:56","modified_gmt":"2025-06-11T16:15:56","slug":"articles-raspberry-pi-i2c-protocol","status":"publish","type":"post","link":"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-i2c-protocol\/","title":{"rendered":"RPi Python Programming 24: I2C explained"},"content":{"rendered":"<p class=\"ai-optimize-6 ai-optimize-introduction\"><span data-preserver-spaces=\"true\">In the <a href=\"https:\/\/www.engineersgarage.com\/microcontroller-projects\/articles-raspberry-pi-neo-6m-gps-module-interfacing\/\"><strong>previous tutorial<\/strong><\/a>, we covered how to interface a NEO-6M GPS module with Raspberry Pi (RPi). The module communicates with RPi over the universal asynchronous receiver\/transmitter or\u00a0<\/span><strong><a class=\"_e75a791d-denali-editor-page-rtfLink\" href=\"https:\/\/www.engineersgarage.com\/raspberrypi\/raspberry-pi-serial-communication-uart-protocol-ttl-port-usb-serial-boards\/\" target=\"_blank\" rel=\"noopener noreferrer\">UART protocol<\/a><\/strong><span data-preserver-spaces=\"true\">.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-7\"><span data-preserver-spaces=\"true\">The UART is the most common point-to-point data communication protocol. But, it\u2019s not the only serial communication protocol. In embedded electronics, I2C and SPI protocols are also widely used for serial data communication. Unlike UART, I2C and SPI are master-slave-type synchronous serial data standards.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-8\"><span data-preserver-spaces=\"true\">In this tutorial, we\u2019ll discuss the basics of the I2C protocol.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-9\"><strong><span data-preserver-spaces=\"true\">What is an I2C?\u00a0<\/span><\/strong><span data-preserver-spaces=\"true\"><br \/>\n<\/span><span data-preserver-spaces=\"true\">An inter-integrated circuit (I2C) or two-wire interface (TWI) is a synchronous serial protocol originally developed by Philips Semiconductors (now NXP). It\u2019s a multi-master, multi-slave serial bus for low-speed devices that only requires two wires for serial data communication between multiple devices. It can easily be implemented with two digital input\/output channels on a device.<\/span><\/p>\n<p class=\"ai-optimize-10\"><span data-preserver-spaces=\"true\">An I2C bus has just two wires over which hundreds of devices can communicate serial data.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-11\"><span data-preserver-spaces=\"true\">As a master-slave type communication standard, at least one device connected to the bus should be the master. It\u2019s the master device that generates a clock signal for synchronous serial communication.<\/span><\/p>\n<p class=\"ai-optimize-12\"><span data-preserver-spaces=\"true\">The slave devices can transfer data to and from the master device(s), which access slave devices by their I2C addresses. The address of each slave device on an I2C bus must be unique. However, the I2C slave devices still must obtain their addresses from NXP.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-13\"><span data-preserver-spaces=\"true\">There are only two wires in I2C where devices can be connected:<\/span><\/p>\n<p class=\"ai-optimize-14\"><span data-preserver-spaces=\"true\"><strong>1.<\/strong> Serial data (SDA) \u2013 the line over which the master and slave devices communicate serial data<br \/>\n<\/span><span data-preserver-spaces=\"true\"><strong>2.<\/strong> Serial clock (SCK) \u2013 the line over which master device(s) generate the clock signal.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-15\"><span data-preserver-spaces=\"true\">The I2C is a half-duplex type of communication. Note: a master device can only read or write data to the slave at one time. Also, the clock signal and the read and write operations are all controlled by the master device(s).\u00a0<\/span><\/p>\n<p class=\"ai-optimize-16\"><span data-preserver-spaces=\"true\">Although there can be an unlimited number of master devices connected to the I2C bus, the maximum number of slave devices can be 112 (in 7-bit addressing) or 1008 (in 10-bit addressing).\u00a0<\/span><\/p>\n<p class=\"ai-optimize-17\"><span data-preserver-spaces=\"true\">The I2C bus drivers are open drain, which means the devices can pull the I2C signal line low but cannot drive it high. By default, both the lines are pulled high by pull-up resistors until the bus is accessed by a master device. This is useful to avoid bus contention.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-18\"><span data-preserver-spaces=\"true\">Since master devices can only pull the signal line low, there can be no conflict between multiple masters \u2014 such as one master pulling the line low while the other drives it high. If at any time, the signal line is low, it means it\u2019s in access to a master device.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-19\"><span data-preserver-spaces=\"true\">Therefore, only one master can access the I2C bus at a time. And the bus master can only read or write data with one slave at a time.<\/span><\/p>\n<p class=\"ai-optimize-20\"><a href=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-01.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-61845 size-full\" src=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-01.jpg\" alt=\"\" width=\"540\" height=\"298\" srcset=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-01.jpg 540w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-01-300x166.jpg 300w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-01-368x203.jpg 368w\" sizes=\"auto, (max-width: 540px) 100vw, 540px\" \/><\/a><\/p>\n<p class=\"ai-optimize-21\"><span data-preserver-spaces=\"true\">The serial data communicated over the I2C is split into 8-bit data packets. The data transfer rate depends on the clock frequency. In the standard mode, the clock frequency is 100 to 400 kHz.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-22\"><span data-preserver-spaces=\"true\">The clock frequency is:\u00a0<\/span><\/p>\n<ul>\n<li class=\"ai-optimize-23\"><span data-preserver-spaces=\"true\">1 MHz in fast mode I2C<\/span><\/li>\n<li class=\"ai-optimize-24\"><span data-preserver-spaces=\"true\">3.4 MHz in high-speed mode\u00a0<\/span><\/li>\n<li class=\"ai-optimize-25\"><span data-preserver-spaces=\"true\">5 MHz in ultra-fast mode\u00a0\u00a0<\/span><\/li>\n<\/ul>\n<p class=\"ai-optimize-26\"><strong><span data-preserver-spaces=\"true\">Advantages of an I2C<br \/>\n<\/span><\/strong><span data-preserver-spaces=\"true\">The UART is the most common serial interface but it does have drawbacks. When using the UART, data communication is only possible between two devices. These devices must also agree to a common protocol and should have nearly the same clocking.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-27\"><span data-preserver-spaces=\"true\">It\u2019s possible to connect more than two devices to UART lines, but that carries a high risk of bus contention. Practically, the maximum data rate achievable with the UART is 230400 bps. And in every 8-bit data transmission, there\u2019s an overhead of 2 bits.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-28\"><span data-preserver-spaces=\"true\">It\u2019s also not easy to implement the UART in software. A feasible UART communication requires an external or built-in UART chip.\u00a0\u00a0<\/span><\/p>\n<p class=\"ai-optimize-29\"><span data-preserver-spaces=\"true\">On the other hand, a serial peripheral interface (SPI) allows for only one master device but multiple slave devices. To connect a slave device, four lines are required. For each slave device, one extra line is needed for the chip select. So, despite a high data rate (of up to 10 Mbps) and full-duplex communication, it\u2019s not practical to connect multiple slave devices over an SPI due to the extra lines required for each slave. This limitation is more evident when the entire circuit is laid out on a PCB.\u00a0\u00a0<\/span><\/p>\n<p class=\"ai-optimize-30\"><span data-preserver-spaces=\"true\">An SPI is typically only good for the high-speed, full-duplex data communication of a master device (such as a microcontroller or embedded computer) with a limited number of slave peripherals (say two or three). However, an SPI is an alternative to the UART for high-speed full-duplex data communication with more than one peripheral device.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-31\"><span data-preserver-spaces=\"true\">Essentially, an I2C represents the best of both the UART and SPI. Although it allows for half-duplex communication, by using an I2C, an unlimited number of master devices can communicate serial data with hundreds of slave devices over just two wires.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-32\"><span data-preserver-spaces=\"true\">Since the master devices can only drive the lines low, bus contention is not a concern. The data rates fall in between those of the UART and the SPI (up to 5 Mbps), and there\u2019s an overhead of only 1 bit (ACK\/NACK) for every byte transmitted through the I2C protocol.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-33\"><span data-preserver-spaces=\"true\">An I2C does still require some complex hardware in comparison to an SPI, but it\u2019s not as complex as with the UART. Also, the software implementation of an I2C is quite feasible.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-34\"><span data-preserver-spaces=\"true\">Additionally, an I2C is particularly useful when low-speed data communication is required with multiple devices or by multiple masters over just two wires. That\u2019s why it\u2019s commonly used by embedded sensors and modules. When using an I2C, a microcontroller (such as Arduino), or an embedded computer (such as Raspberry Pi) can connect and communicate with hundreds of sensors over just two wires while engaging only their two channels\/pins.\u00a0 \u00a0 \u00a0<\/span><\/p>\n<p class=\"ai-optimize-35\"><strong><span data-preserver-spaces=\"true\">Disadvantages of an I2C<br \/>\n<\/span><\/strong><span data-preserver-spaces=\"true\">An I2C allows serial data communication with multiple devices and multiple masters using only two wires, but it has low data-transfer rates and lacks full-duplex capabilities. The I2C is simply not an option when full-duplex communication is required or high data speed is needed.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-36\"><span data-preserver-spaces=\"true\">This means:<\/span><\/p>\n<ul>\n<li class=\"ai-optimize-37\"><span data-preserver-spaces=\"true\">The UART is good for basic, full-duplex communication between two devices with a similar clock.\u00a0<\/span><\/li>\n<li class=\"ai-optimize-38\"><span data-preserver-spaces=\"true\">An SPI is good for full-duplex, high-speed data communication with two or more peripherals.\u00a0<\/span><\/li>\n<li class=\"ai-optimize-39\"><span data-preserver-spaces=\"true\">An I2C is good for slow-speed data communication with multiple devices, among multiple masters over a 2-wire bus.\u00a0 \u00a0<\/span><\/li>\n<\/ul>\n<p class=\"ai-optimize-40\"><strong><span data-preserver-spaces=\"true\">The I2C hardware<br \/>\n<\/span><\/strong><span data-preserver-spaces=\"true\">The implementation of an I2C requires two open-drain (open-collector in TTL terminology) output drivers. Both the wires on an I2C bus must be pulled high with a suitable resistor. The I2C channels on most of the sensors and modules communicate serial data successfully over two to three meters of wire.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-41\"><span data-preserver-spaces=\"true\">For longer-distance data transmission, dedicated I2C breakout boards are required.\u00a0\u00a0<\/span><\/p>\n<p class=\"ai-optimize-42\"><span data-preserver-spaces=\"true\">Most of the microcontrollers and embedded computers have dedicated I2C hardware, which they can operate as an I2C master and an I2C slave. As an I2C slave means they also have an I2C address. With I2C hardware, they can generate start and stop conditions, receive an I2C address, and send and receive serial data over the protocol.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-43\"><span data-preserver-spaces=\"true\">If the I2C address is implemented by the software, the data bits must be sampled at least twice per clock pulse. Most of the microcontrollers have sufficient clock frequency that they can easily sample the I2C data using an internal timer\/counters with or without a pre-scaler.\u00a0\u00a0<\/span><\/p>\n<p class=\"ai-optimize-44\"><strong><span data-preserver-spaces=\"true\">The I2C voltage levels<\/span><\/strong><span data-preserver-spaces=\"true\"><br \/>\n<\/span><span data-preserver-spaces=\"true\">Typical voltages used for the I2C are +5 and +3.3V. The I2C is flexible, however, and can maintain data communication with devices\/interfaces with other voltage levels, too.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-45\"><span data-preserver-spaces=\"true\">When connecting a higher-voltage device with a lower-voltage one over an I2C, caution is required. Sometimes pulling the I2C bus to a lower-voltage device level is sufficient. But there\u2019s still a chance that the higher-voltage device can damage the lower-voltage one. It\u2019s recommended to connect the two devices with different voltage levels over the I2C bus by using a suitable I2C level shifter board.\u00a0\u00a0<\/span><\/p>\n<p class=\"ai-optimize-46\"><strong><span data-preserver-spaces=\"true\">The I2C addresses<\/span><\/strong><span data-preserver-spaces=\"true\"><br \/>\n<\/span><span data-preserver-spaces=\"true\">Master devices on an I2C bus do not need to have an address as they generate the clock signal on an SCL line. The slave devices need to have unique addresses on an I2C bus.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-47\"><span data-preserver-spaces=\"true\">The I2C addresses of slave devices can be 7-bit or 10-bit. Some of these devices have fixed addresses while others have address lines that can be wired to set the address of the device over an I2C interface.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-48\"><span data-preserver-spaces=\"true\">As there are a limited number of I2C addresses (only 112 addresses in 7-bit and 1008 addresses in a 10-bit), there\u2019s a chance that two I2C devices may have the same one. More than one I2C device with the same address can be connected to a controller\/computer using an I2C hub.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-49\"><strong><span data-preserver-spaces=\"true\">The I2C protocol<\/span><\/strong><span data-preserver-spaces=\"true\"><br \/>\n<\/span><span data-preserver-spaces=\"true\">By default, both I2C lines (SDA and SCL) are high. There can be one or more master devices connected to an I2C bus. The data communication is initiated by a master device.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-50\"><span data-preserver-spaces=\"true\">A master device generates a start condition that\u2019s followed by the address of the slave device. The address of the slave device should be unique. In 7-bit addressing, the bit 0 of the address byte indicates whether the master reads or writes to the I2C slave. If the bit 0 of the address byte is 0, the master device writes the data to the I2C slave. If it\u2019s 1, the master device reads data from the I2C slave.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-51\"><span data-preserver-spaces=\"true\">After selecting a slave device, the data frames consisting of 8-bit data and acknowledgment bit are transferred between the master and slave. There can be repeated start conditions from a master to read and write the serial data with one or more I2C slaves.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-52\"><span data-preserver-spaces=\"true\">Once the data communication is complete, the master device must generate a stop condition to end the communication over the I2C bus.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-53\"><span data-preserver-spaces=\"true\">The I2C bus is also free to be used by other master devices. In fact, there can be an unlimited number of master devices connected to an I2C bus, provided the bus capacitance doesn\u2019t exceed 400 pF.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-54\"><strong><span data-preserver-spaces=\"true\"><a href=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-02.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-61848 size-full\" src=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-02.png\" alt=\"\" width=\"536\" height=\"38\" srcset=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-02.png 536w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-02-300x21.png 300w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-02-368x26.png 368w\" sizes=\"auto, (max-width: 536px) 100vw, 536px\" \/><\/a><\/span><\/strong><span data-preserver-spaces=\"true\"> <a href=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-03.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-61849 size-full\" src=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-03.png\" alt=\"\" width=\"586\" height=\"36\" srcset=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-03.png 586w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-03-300x18.png 300w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-03-368x23.png 368w\" sizes=\"auto, (max-width: 586px) 100vw, 586px\" \/><\/a><\/span><\/p>\n<p class=\"ai-optimize-55\"><strong>The start condition<br \/>\n<\/strong>To generate the start condition, a master device has to pull an SDA low while leaving the SCL high.<\/p>\n<p class=\"ai-optimize-56\"><a href=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-04.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-61850 size-full\" src=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-04.png\" alt=\"\" width=\"387\" height=\"292\" srcset=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-04.png 387w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-04-300x226.png 300w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-04-315x238.png 315w\" sizes=\"auto, (max-width: 387px) 100vw, 387px\" \/><\/a><\/p>\n<p class=\"ai-optimize-57\">If two master devices try to access the I2C at the same time, whichever pulls the SDA low first gets the ownership of the bus. This is called arbitration.<\/p>\n<p class=\"ai-optimize-58\"><a href=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-05.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-61851 size-full\" src=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-05.jpg\" alt=\"\" width=\"550\" height=\"318\" srcset=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-05.jpg 550w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-05-300x173.jpg 300w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-05-368x213.jpg 368w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/a><\/p>\n<p class=\"ai-optimize-59\"><span data-preserver-spaces=\"true\">Once there\u2019s a high-to-low transition on an SDA line, the I2C slaves are alerted that a transmission is about to begin. Once the bus is controlled by a master, it can read and write data to one or more of the slave devices by generating repeated start conditions.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-60\"><span data-preserver-spaces=\"true\">Until the stop condition is generated by the current bus master, other master devices cannot gain control of the I2C bus.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-61\"><strong><span data-preserver-spaces=\"true\">Address frames<\/span><\/strong><span data-preserver-spaces=\"true\"><br \/>\n<\/span><span data-preserver-spaces=\"true\">The data is communicated over the I2C bus in 8-bit frames (data-packets). The first frame after the start condition is always an address frame. This frame identifies the slave device that the I2C bus master must communicate with.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-62\"><span data-preserver-spaces=\"true\">In this frame, the 7-bit address of a slave device is transmitted by the master, starting with the MSB of the I2C address. It\u2019s followed by an R\/W bit, which determines whether the master will read from or write data to the slave. If the R\/W bit is 0, the master device writes data to the I2C slave. If it\u2019s 1, the master device reads data from the I2C slave.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-63\"><span data-preserver-spaces=\"true\">After the start condition, the bus master has to pull the SCL line low. The bits are sampled whenever the SCL line goes high. The data (bits) on the SDA line should remain stable when the SCL is high, otherwise, it will be interpreted as a repeated start or stop condition. The data bits can only change when the SCL is low. After the start condition, the SCL is pulled low by the master, and the data is put on the SDA line. Following this, the data is sampled by the slave at each low-to-high transition of the SCL signal.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-64\"><span data-preserver-spaces=\"true\">Each 8-bit data frame ends with an ACK\/NACK bit. After 8 bits are transferred, the receiving device gets control of the SDA line. If the receiving device pulls the SDA line low before the ninth clock pulse, this means that it has successfully received the 8-bit data frame.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-65\"><span data-preserver-spaces=\"true\">If this does not occur, this means it has failed to receive the data frame or is unable to parse the data according to the I2C protocol. In this case, the receiving device does not pull the SDA line low but, rather, it\u2019s up to the master to end data communication by generating a stop condition or a repeated start condition.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-66\"><a href=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-06.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-61852 size-full\" src=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-06.jpg\" alt=\"\" width=\"550\" height=\"205\" srcset=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-06.jpg 550w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-06-300x112.jpg 300w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-06-368x137.jpg 368w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/a><\/p>\n<p class=\"ai-optimize-67\">In the case of an address frame, the receiving device is always a slave device.<\/p>\n<p class=\"ai-optimize-68\"><a href=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-07.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-61853 size-full\" src=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-07.png\" alt=\"\" width=\"532\" height=\"181\" srcset=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-07.png 532w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-07-300x102.png 300w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-07-368x125.png 368w\" sizes=\"auto, (max-width: 532px) 100vw, 532px\" \/><\/a><\/p>\n<p class=\"ai-optimize-69\"><strong>Data frames<\/strong><br \/>\nAfter sending an address frame, the bus master will continue sending clock pulses. Depending on the R\/W bit, the data is either read or written by the master device. After each 8-bit frame, the receiving device pulls the SDA line low in the ninth clock pulse.<\/p>\n<p class=\"ai-optimize-70\">There can be any number of data frames exchanged between a master and slave \u2014 after the master selects a slave and the read\/write operation by sending the start signal and then an address frame.<\/p>\n<p class=\"ai-optimize-71\"><a href=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-08.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-61854 size-full\" src=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-08.png\" alt=\"\" width=\"435\" height=\"164\" srcset=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-08.png 435w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-08-300x113.png 300w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-08-368x139.png 368w\" sizes=\"auto, (max-width: 435px) 100vw, 435px\" \/><\/a><strong>The stop condition<br \/>\n<\/strong>Once a master gains control of the I2C bus, it can read\/write serial data with any number of slaves by generating repeated start conditions.<\/p>\n<p class=\"ai-optimize-72\"><a href=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-09.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-61855 size-full\" src=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-09.jpg\" alt=\"\" width=\"383\" height=\"233\" srcset=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-09.jpg 383w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-09-300x183.jpg 300w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-09-368x224.jpg 368w\" sizes=\"auto, (max-width: 383px) 100vw, 383px\" \/><\/a><\/p>\n<p class=\"ai-optimize-73\">To release the bus, the master must generate a stop condition. The stop condition is generated by pulling the SDA line from high to low, while the SCL line is high.<\/p>\n<p class=\"ai-optimize-74\"><a href=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-10.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-61856 size-full\" src=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-10.png\" alt=\"\" width=\"364\" height=\"293\" srcset=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-10.png 364w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-10-300x241.png 300w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-10-296x238.png 296w\" sizes=\"auto, (max-width: 364px) 100vw, 364px\" \/><\/a><\/p>\n<p class=\"ai-optimize-75\">This is why, the data bits should never change when the clock pulse on SCL line is high. Otherwise, it will be interpreted as a false stop condition or a false repeated start.<\/p>\n<p class=\"ai-optimize-76\"><a href=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-11.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-61857 size-full\" src=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-11.jpg\" alt=\"\" width=\"426\" height=\"173\" srcset=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-11.jpg 426w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-11-300x122.jpg 300w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-11-368x149.jpg 368w\" sizes=\"auto, (max-width: 426px) 100vw, 426px\" \/><\/a><\/p>\n<p class=\"ai-optimize-77\"><strong>Clock stretching<\/strong><br \/>\nIf a slave device is not ready or is unable to process the received data, it can pull the SCL line low to indicate that it needs time to receive\/process the data. Once the device is ready, it can drive the SCL line high, indicating that the master can restart serial communication. This is called clock stretching.<\/p>\n<p class=\"ai-optimize-78\">The data bits are always sampled at a low-to-high transition of the clock pulse on an SCL line. The slave devices can only pull the SCL line low after the master releases the I2C bus. When the SCL line is pulled low by a slave device, the master devices on the I2C bus refrain from generating clock pulses or putting data on an SDA line until the SCL line is released by the slave.<\/p>\n<p class=\"ai-optimize-79\"><a href=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-12.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-61858 size-full\" src=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-12.jpg\" alt=\"\" width=\"550\" height=\"321\" srcset=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-12.jpg 550w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-12-300x175.jpg 300w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-12-368x215.jpg 368w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/a><\/p>\n<p class=\"ai-optimize-80\"><strong><span data-preserver-spaces=\"true\">The 10-bit I2C addressing<\/span><\/strong><span data-preserver-spaces=\"true\"><br \/>\n<\/span><span data-preserver-spaces=\"true\">Advanced I2C devices have 10-bit addresses. These can be used with 7-bit address devices as the address frame for 10-bit devices always begins with the 5-bit sequence, 11110.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-81\"><span data-preserver-spaces=\"true\">This sequence indicates a 10-bit address from the master device. For selecting an I2C slave with a 10-bit address, the master device must send two address frames to write the data to the slave, or three address frames to read data from the slave.<\/span><\/p>\n<p class=\"ai-optimize-82\"><span data-preserver-spaces=\"true\">When the master has to write data to a 10-bit address slave, it must send two address frames. The first address frame contains the 5-bit sequence 11110, followed by two bits of the slave address and the R\/W bit. The R\/W bit must be 0 in this case.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-83\"><span data-preserver-spaces=\"true\">After sending the first frame, it must wait for the ACK at the ninth clock pulse. If the acknowledgment bit (an SCL line pulled low by the receiving device) is successfully detected by the master, it sends the remaining 8 bits of the slave address in the next frame.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-84\"><a href=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-13.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-61860 size-full\" src=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-13.png\" alt=\"\" width=\"500\" height=\"96\" srcset=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-13.png 500w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-13-300x58.png 300w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-13-368x71.png 368w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/a><\/p>\n<p class=\"ai-optimize-85\">When a master has to read the data from a 10-bit address slave, the R\/W bit in the first address frame is still 0, but the second address frame is followed by a repeated start condition.<\/p>\n<p class=\"ai-optimize-86\">After the repeated start condition, the first address frame is resent to the slave with the R\/W bit set to 1.<\/p>\n<p class=\"ai-optimize-87\"><a href=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-14.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-61862 size-full\" src=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-14.png\" alt=\"\" width=\"650\" height=\"92\" srcset=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-14.png 650w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-14-300x42.png 300w, https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/24R-14-368x52.png 368w\" sizes=\"auto, (max-width: 650px) 100vw, 650px\" \/><\/a><\/p>\n<p class=\"ai-optimize-88\"><strong><span data-preserver-spaces=\"true\">Advanced I2C protocol<\/span><\/strong><span data-preserver-spaces=\"true\"><br \/>\n<\/span><span data-preserver-spaces=\"true\">Most of the I2C devices have 7-bit addresses and use standard mode, where the data transfer rate is 100 Kbps. Advanced I2C devices operate in fast, high-speed, or ultra-fast mode and generally have 10-bit addresses.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-89\"><span data-preserver-spaces=\"true\">Fast-mode I2C devices have downward compatibility and can also work with slower I2C controllers. High-speed I2C devices use two clock states, SCLH and SCLL, and have spike suppression circuits on both lines of the I2C bus.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-90\"><span data-preserver-spaces=\"true\">The high-speed devices do not use clock stretching or arbitration because they have enhanced line output drivers.\u00a0<\/span><\/p>\n<p class=\"ai-optimize-91\"><em>In the next tutorial, we&#8217;ll discuss synchronous serial communication when using the I2C protocol in Raspberry Pi.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the previous tutorial, we covered how to interface a NEO-6M GPS module with Raspberry Pi (RPi). The module communicates with RPi over the universal asynchronous receiver\/transmitter or\u00a0UART protocol.\u00a0 The UART is the most common point-to-point data communication protocol. But, it\u2019s not the only serial communication protocol. In embedded electronics, I2C and SPI protocols are&hellip;<\/p>\n","protected":false},"author":387,"featured_media":61863,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[1853,3993],"tags":[1724],"class_list":{"2":"type-post","10":"entry","11":"has-post-thumbnail"},"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.2 (Yoast SEO v25.2) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>RPi Python Programming 24: I2C explained<\/title>\n<meta name=\"description\" content=\"An I2C represents the best of both the UART and SPI. An I2C bus has just two wires over which hundreds of devices can communicate serial data.\u00a0\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-i2c-protocol\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"RPi Python Programming 24: I2C explained\" \/>\n<meta property=\"og:description\" content=\"An I2C represents the best of both the UART and SPI. An I2C bus has just two wires over which hundreds of devices can communicate serial data.\u00a0\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-i2c-protocol\/\" \/>\n<meta property=\"og:site_name\" content=\"Engineers Garage\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/engineersgarage\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/Rotator-5.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"834\" \/>\n\t<meta property=\"og:image:height\" content=\"502\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Nikhil Agnihotri\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@EngineersGarage\" \/>\n<meta name=\"twitter:site\" content=\"@EngineersGarage\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nikhil Agnihotri\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"16 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-i2c-protocol\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-i2c-protocol\/\"},\"author\":{\"name\":\"Nikhil Agnihotri\",\"@id\":\"https:\/\/www.engineersgarage.com\/#\/schema\/person\/3c71105e3b40a1fd12c79c15602914b6\"},\"headline\":\"RPi Python Programming 24: I2C explained\",\"datePublished\":\"2025-06-10T19:26:01+00:00\",\"dateModified\":\"2025-06-11T16:15:56+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-i2c-protocol\/\"},\"wordCount\":2888,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.engineersgarage.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-i2c-protocol\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/Rotator-5.jpg\",\"keywords\":[\"raspberrypi\"],\"articleSection\":[\"Featured Contributions\",\"Raspberry pi\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-i2c-protocol\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-i2c-protocol\/\",\"url\":\"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-i2c-protocol\/\",\"name\":\"RPi Python Programming 24: I2C explained\",\"isPartOf\":{\"@id\":\"https:\/\/www.engineersgarage.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-i2c-protocol\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-i2c-protocol\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/Rotator-5.jpg\",\"datePublished\":\"2025-06-10T19:26:01+00:00\",\"dateModified\":\"2025-06-11T16:15:56+00:00\",\"description\":\"An I2C represents the best of both the UART and SPI. An I2C bus has just two wires over which hundreds of devices can communicate serial data.\u00a0\",\"breadcrumb\":{\"@id\":\"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-i2c-protocol\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-i2c-protocol\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-i2c-protocol\/#primaryimage\",\"url\":\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/Rotator-5.jpg\",\"contentUrl\":\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/Rotator-5.jpg\",\"width\":834,\"height\":502},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-i2c-protocol\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.engineersgarage.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"RPi Python Programming 24: I2C explained\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.engineersgarage.com\/#website\",\"url\":\"https:\/\/www.engineersgarage.com\/\",\"name\":\"Engineers Garage\",\"description\":\"Electronic Projects, Electrical Engineering Resources, Makers Articles and Product News\",\"publisher\":{\"@id\":\"https:\/\/www.engineersgarage.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.engineersgarage.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.engineersgarage.com\/#organization\",\"name\":\"Engineer's Garage - WTWH Media\",\"url\":\"https:\/\/www.engineersgarage.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.engineersgarage.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2019\/08\/EGlogo.png\",\"contentUrl\":\"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2019\/08\/EGlogo.png\",\"width\":372,\"height\":52,\"caption\":\"Engineer's Garage - WTWH Media\"},\"image\":{\"@id\":\"https:\/\/www.engineersgarage.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/engineersgarage\",\"https:\/\/x.com\/EngineersGarage\",\"https:\/\/www.youtube.com\/channel\/UC0VITh11JSYk-UW7toLebUw\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.engineersgarage.com\/#\/schema\/person\/3c71105e3b40a1fd12c79c15602914b6\",\"name\":\"Nikhil Agnihotri\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.engineersgarage.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d26b31563fa36169891c8c7d312e9b33de8a0e3da1340ec14ef2de84d5c43497?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d26b31563fa36169891c8c7d312e9b33de8a0e3da1340ec14ef2de84d5c43497?s=96&r=g\",\"caption\":\"Nikhil Agnihotri\"},\"url\":\"https:\/\/www.engineersgarage.com\/author\/nikhil-agnihotri\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"RPi Python Programming 24: I2C explained","description":"An I2C represents the best of both the UART and SPI. An I2C bus has just two wires over which hundreds of devices can communicate serial data.\u00a0","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-i2c-protocol\/","og_locale":"en_US","og_type":"article","og_title":"RPi Python Programming 24: I2C explained","og_description":"An I2C represents the best of both the UART and SPI. An I2C bus has just two wires over which hundreds of devices can communicate serial data.\u00a0","og_url":"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-i2c-protocol\/","og_site_name":"Engineers Garage","article_publisher":"https:\/\/www.facebook.com\/engineersgarage","og_image":[{"width":834,"height":502,"url":"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/Rotator-5.jpg","type":"image\/jpeg"}],"author":"Nikhil Agnihotri","twitter_card":"summary_large_image","twitter_creator":"@EngineersGarage","twitter_site":"@EngineersGarage","twitter_misc":{"Written by":"Nikhil Agnihotri","Est. reading time":"16 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-i2c-protocol\/#article","isPartOf":{"@id":"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-i2c-protocol\/"},"author":{"name":"Nikhil Agnihotri","@id":"https:\/\/www.engineersgarage.com\/#\/schema\/person\/3c71105e3b40a1fd12c79c15602914b6"},"headline":"RPi Python Programming 24: I2C explained","datePublished":"2025-06-10T19:26:01+00:00","dateModified":"2025-06-11T16:15:56+00:00","mainEntityOfPage":{"@id":"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-i2c-protocol\/"},"wordCount":2888,"commentCount":0,"publisher":{"@id":"https:\/\/www.engineersgarage.com\/#organization"},"image":{"@id":"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-i2c-protocol\/#primaryimage"},"thumbnailUrl":"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/Rotator-5.jpg","keywords":["raspberrypi"],"articleSection":["Featured Contributions","Raspberry pi"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.engineersgarage.com\/articles-raspberry-pi-i2c-protocol\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-i2c-protocol\/","url":"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-i2c-protocol\/","name":"RPi Python Programming 24: I2C explained","isPartOf":{"@id":"https:\/\/www.engineersgarage.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-i2c-protocol\/#primaryimage"},"image":{"@id":"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-i2c-protocol\/#primaryimage"},"thumbnailUrl":"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/Rotator-5.jpg","datePublished":"2025-06-10T19:26:01+00:00","dateModified":"2025-06-11T16:15:56+00:00","description":"An I2C represents the best of both the UART and SPI. An I2C bus has just two wires over which hundreds of devices can communicate serial data.\u00a0","breadcrumb":{"@id":"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-i2c-protocol\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.engineersgarage.com\/articles-raspberry-pi-i2c-protocol\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-i2c-protocol\/#primaryimage","url":"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/Rotator-5.jpg","contentUrl":"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/Rotator-5.jpg","width":834,"height":502},{"@type":"BreadcrumbList","@id":"https:\/\/www.engineersgarage.com\/articles-raspberry-pi-i2c-protocol\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.engineersgarage.com\/"},{"@type":"ListItem","position":2,"name":"RPi Python Programming 24: I2C explained"}]},{"@type":"WebSite","@id":"https:\/\/www.engineersgarage.com\/#website","url":"https:\/\/www.engineersgarage.com\/","name":"Engineers Garage","description":"Electronic Projects, Electrical Engineering Resources, Makers Articles and Product News","publisher":{"@id":"https:\/\/www.engineersgarage.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.engineersgarage.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.engineersgarage.com\/#organization","name":"Engineer's Garage - WTWH Media","url":"https:\/\/www.engineersgarage.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.engineersgarage.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2019\/08\/EGlogo.png","contentUrl":"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2019\/08\/EGlogo.png","width":372,"height":52,"caption":"Engineer's Garage - WTWH Media"},"image":{"@id":"https:\/\/www.engineersgarage.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/engineersgarage","https:\/\/x.com\/EngineersGarage","https:\/\/www.youtube.com\/channel\/UC0VITh11JSYk-UW7toLebUw"]},{"@type":"Person","@id":"https:\/\/www.engineersgarage.com\/#\/schema\/person\/3c71105e3b40a1fd12c79c15602914b6","name":"Nikhil Agnihotri","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.engineersgarage.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d26b31563fa36169891c8c7d312e9b33de8a0e3da1340ec14ef2de84d5c43497?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d26b31563fa36169891c8c7d312e9b33de8a0e3da1340ec14ef2de84d5c43497?s=96&r=g","caption":"Nikhil Agnihotri"},"url":"https:\/\/www.engineersgarage.com\/author\/nikhil-agnihotri\/"}]}},"featured_image_src":"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/Rotator-5.jpg","featured_image_src_square":"https:\/\/www.engineersgarage.com\/wp-content\/uploads\/2020\/08\/Rotator-5.jpg","author_info":{"display_name":"Nikhil Agnihotri","author_link":"https:\/\/www.engineersgarage.com\/author\/nikhil-agnihotri\/"},"_links":{"self":[{"href":"https:\/\/www.engineersgarage.com\/wp-json\/wp\/v2\/posts\/61842","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.engineersgarage.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.engineersgarage.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.engineersgarage.com\/wp-json\/wp\/v2\/users\/387"}],"replies":[{"embeddable":true,"href":"https:\/\/www.engineersgarage.com\/wp-json\/wp\/v2\/comments?post=61842"}],"version-history":[{"count":0,"href":"https:\/\/www.engineersgarage.com\/wp-json\/wp\/v2\/posts\/61842\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.engineersgarage.com\/wp-json\/wp\/v2\/media\/61863"}],"wp:attachment":[{"href":"https:\/\/www.engineersgarage.com\/wp-json\/wp\/v2\/media?parent=61842"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.engineersgarage.com\/wp-json\/wp\/v2\/categories?post=61842"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.engineersgarage.com\/wp-json\/wp\/v2\/tags?post=61842"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}