Challenge - 5 Problems
I2C Master on Raspberry Pi
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of the command to check I2C devices?
You have enabled I2C on your Raspberry Pi and connected a device. You run the command
i2cdetect -y 1. What output do you expect if a device is connected at address 0x3C?Raspberry Pi
sudo i2cdetect -y 1Attempts:
2 left
💡 Hint
Look for the hexadecimal address 3c in the output grid.
✗ Incorrect
The
i2cdetect -y 1 command scans the I2C bus 1 and shows detected devices by their addresses. If a device is at 0x3C, it appears in the grid at row 30 and column c.🧠 Conceptual
intermediate1:30remaining
Which file enables I2C interface on Raspberry Pi?
To enable the I2C interface on Raspberry Pi, which configuration file do you edit?
Attempts:
2 left
💡 Hint
This file contains boot-time settings for the Raspberry Pi.
✗ Incorrect
The
/boot/config.txt file is used to enable hardware interfaces like I2C by adding lines such as dtparam=i2c_arm=on.🔧 Debug
advanced2:00remaining
Why does this Python I2C code raise an error?
You run this Python code to communicate with an I2C device but get an error:
import smbus bus = smbus.SMBus(0) bus.write_byte(0x3c, 0x00)What is the most likely cause of the error?
Attempts:
2 left
💡 Hint
Check which I2C bus number Raspberry Pi uses by default.
✗ Incorrect
On Raspberry Pi models with newer hardware, I2C bus 1 is used. Using bus 0 causes an error because it does not exist or is not enabled.
📝 Syntax
advanced1:30remaining
Which command correctly loads the I2C kernel module?
You want to load the I2C kernel module manually. Which command is correct?
Attempts:
2 left
💡 Hint
The command to add kernel modules is a common Linux utility.
✗ Incorrect
The correct command to load kernel modules is
modprobe. i2c-dev is the module for I2C device interface.🚀 Application
expert3:00remaining
How to verify I2C is enabled and working on Raspberry Pi?
You want to confirm that I2C is enabled and working on your Raspberry Pi. Which sequence of commands will correctly verify this?
Attempts:
2 left
💡 Hint
Use the Raspberry Pi configuration tool and check kernel modules and device scan.
✗ Incorrect
The recommended way is to enable I2C via raspi-config, reboot, check if the i2c_dev module is loaded with lsmod, and then scan the bus with i2cdetect -y 1.
