What Is I2C?
How Does I2C Communication Work?
Each gear connected to the I2C bus has a unique address that identifies it during communication.
Communication is initiated by the master unit, and incorrect addressing of slave devices can cause errors in transfer.
Check out our in-depth guide onhow UART, SPI, and I2C serial communications workto give you some context.
Devices that operate at different voltage levels can still communicate effectively with the help of voltage shifters.
Image Credit:Arduino I2C documentation
This means that devices operating at 3.3V need voltage shifters to connect to a 5V I2C bus.
It uses two pinsSDA and SCLon the Arduino board for I2C communication.
The Wire library provides functions to initiate communication with an I2C unit, send data, and receive data.
Connect the pull-up resistors between theSDAandSCLpins and the5Vpower rail on the breadboard.
Finally, connect the two breadboards together using jumper wires.
Then use theWire.read()function to get data from the slave equipment.
The master board can then read the value we sent, then display it on the serial monitor.
Use the following code to identify any slave devices address present on the I2C bus.
Image Credit:Arduino I2C documentation