Bird
0
0
Raspberry Piprogramming~5 mins

Writing commands to I2C device in Raspberry Pi - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is I2C communication?
I2C (Inter-Integrated Circuit) is a simple way for devices to talk to each other using just two wires: one for data and one for clock. It lets many devices share the same wires.
Click to reveal answer
beginner
Which Python library is commonly used on Raspberry Pi to write commands to an I2C device?
The 'smbus2' library is commonly used. It helps send and receive data over I2C easily.
Click to reveal answer
intermediate
What does the 'write_byte_data' function do in I2C communication?
It sends a single byte of data to a specific register (or command) on the I2C device.
Click to reveal answer
beginner
Why do you need the device address when writing to an I2C device?
The device address tells the Raspberry Pi which device on the I2C bus should receive the command, like sending mail to the right house.
Click to reveal answer
beginner
What is the purpose of the 'bus' number in I2C communication on Raspberry Pi?
The 'bus' number selects which I2C channel on the Raspberry Pi you want to use, because some models have more than one I2C bus.
Click to reveal answer
Which two wires are used in I2C communication?
AData and Clock
BPower and Ground
CTransmit and Receive
DReset and Enable
In Python's smbus2 library, which function writes a byte to a device register?
Aread_byte_data
Bwrite_byte_data
Cwrite_word_data
Dread_word_data
What does the device address represent in I2C communication?
AThe size of data packets
BThe speed of communication
CThe voltage level
DThe unique ID of the device on the bus
Why might you need to specify the bus number on a Raspberry Pi?
ATo choose the power source
BTo set the baud rate
CBecause the Pi can have multiple I2C buses
DTo select the GPIO pins for SPI
Which Python code snippet correctly writes the value 0x10 to register 0x01 of an I2C device at address 0x20 on bus 1?
Abus.write_byte_data(0x20, 0x01, 0x10)
Bbus.read_byte_data(0x20, 0x01)
Cbus.write_word_data(0x01, 0x20, 0x10)
Dbus.write_byte(0x01, 0x10)
Explain the steps to write a command to an I2C device using Python on a Raspberry Pi.
Think about setting up communication and sending data.
You got /4 concepts.
    Why is it important to know the device address and bus number when writing commands to an I2C device?
    Compare it to sending a letter to the right house on the right street.
    You got /3 concepts.