Esp32

What does I2C do in ESP32?

ESP32 is a development board that can communicate and interconnect with IoT devices wirelessly. It has built-in Wi-Fi and Bluetooth modules. It also has multiple peripherals for communication with other devices. They include SPI, UART, and I2C. This article will briefly explain the role of I2C in ESP32.

What is I2C?

I2C is also written as IIC, and it stands for Inter-Integrated Circuit. This I2C interface in ESP32 uses asynchronous and half-duplex methods of communication. In this method, two-way communication is allowed but not simultaneously. Transmission or Reception of data can happen at a time.

What does I2C do in ESP32?

I2C is responsible for serial communication with other devices. It communicates at low speed and over short distances almost equal to a foot.

It consists of two lines for communication. One is Serial Data Line abbreviated as SDA and the other is Serial Clock Line abbreviated as SCL. The SDA is the GPIO pin 21 and SCL is the GPIO pin 22. These two lines allow bidirectional communication.

The I2C interface allows specific communication, in which every device has its unique ID, and data is protected during communication. Due to this reason, I2C is also used by sensors to communicate with controllers and output devices.

The I2C interface can connect multiple master and slave devices along its data and clock lines. ESP32 can act as either a master device or a slave device when working with other devices.

I2C Interface Specifications

The basic features of the I2C interface are explained below:

  • In standard mode, its communication speed is 100k bits/second
  • In fast mode, its communication speed is 400k bits/second
  • The communication frequency of I2C is 5MHz
  • The address registers or this interface are 7 to 10 bits
  • It can communicate two-way

How to Connect I2C Devices with ESP32?

The ESP32 can be connected to other devices that support serial communication. For example, Liquid Crystal Display LCD can be interfaced with ESP32 using I2C. The method of interfacing is simple connections between LCD and ESP32. You need to connect the SDA and SCL pins of the LCD to GPIO pins 21 and 22 respectively. Similarly, you need to power the LCD by connecting its VCC and GND to the Vin and GND of ESP32. In this way, serial communication is established between LCD and ESP32.

You can get more information about interfacing I2C devices with ESP32

Conclusion

The I2C interface is a very important feature of ESP32 that permits it to be connected with multiple other devices simultaneously. It can connect either as a master or a slave. It can communicate in both ways through SDA and SCL. However, either transmission or reception can happen at a time.

About the author

Kashif

I am an Electrical Engineer. I love to write about electronics. I am passionate about writing and sharing new ideas related to emerging technologies in the field of electronics.