Complete the code to import the library needed for I2C communication on Raspberry Pi.
import [1]
The smbus2 library is used to communicate over I2C on Raspberry Pi.
Complete the code to create an I2C bus object on Raspberry Pi.
bus = smbus2.SMBus([1])On Raspberry Pi, I2C bus 1 is commonly used for communication.
Fix the error in the code to write a byte value 0x01 to device address 0x20 on the I2C bus.
bus.write_byte([1], 0x01)
The device address must match the actual I2C device address, here 0x20.
Fill both blanks to read a byte from register 0x01 of device 0x20 using I2C.
data = bus.read_byte_data([1], [2])
The first blank is the device address (0x20), the second is the register address (0x01).
Fill all three blanks to write the value 0xFF to register 0x02 of device 0x20 using I2C.
bus.write_byte_data([1], [2], [3])
The device address is 0x20, register is 0x02, and value to write is 0xFF.
