Interfacing with sensors over Inter-Integrated Circuit (I2C)
I2C is a serial communication bus that supports multiple devices on the same line. Devices on the bus use 7-bit addressing. Two lines are needed for the I2C interface: Clock (CLK) and Serial Data (SDA). The master device provides the clock to the bus. The following figure shows a typical architecture of an I2C bus:
Figure 3.3: I2C architecture
The only rule here is that each slave has to have its own unique address on the bus. In other words, two sensors with the same I2C address cannot share a common bus. As defined in the protocol, the master and slaves exchange data over the SDA line. The master sends a command and the addressed slave replies to that command. Now, let’s see an example of I2C communication on ESP32 by implementing a multisensor application.
Developing a multisensor application
The purpose of this example is to develop an application in which we read values from different I2C...