Bird
0
0
Raspberry Piprogramming~20 mins

i2cdetect for device scanning in Raspberry Pi - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
I2C Device Scanner Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
1:30remaining
What is the output of this i2cdetect command?

You run the command i2cdetect -y 1 on your Raspberry Pi. The output shows a grid with addresses and some numbers. What does the number 3c in the grid represent?

Raspberry Pi
i2cdetect -y 1
     0 1 2 3 4 5 6 7 8 9 a b c d e f
00:          -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- 3c -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --
AIt means the device at address 0x3c is not responding.
BIt indicates a syntax error in the command.
CIt shows an I2C device is detected at address 0x3c on bus 1.
DIt shows the Raspberry Pi I2C bus is disabled.
Attempts:
2 left
💡 Hint

Look at the grid and what the numbers mean in the i2cdetect output.

🧠 Conceptual
intermediate
1:00remaining
Why do you use the '-y' option with i2cdetect?

When running i2cdetect, what is the purpose of the -y option?

AIt disables interactive mode and runs the scan without asking for confirmation.
BIt enables verbose output showing extra debug information.
CIt specifies the I2C bus number to scan.
DIt resets the I2C bus before scanning.
Attempts:
2 left
💡 Hint

Think about what happens if you run i2cdetect without -y.

Predict Output
advanced
1:30remaining
What error does this i2cdetect command produce?

You run the command i2cdetect -y 3 on a Raspberry Pi that only has bus 0 and 1. What error message will you see?

Raspberry Pi
i2cdetect -y 3
AError: Bus 3 is busy, try again later
BNo error, it scans bus 3 successfully
CError: Permission denied to access I2C bus 3
DError: Could not open file `/dev/i2c-3`: No such file or directory
Attempts:
2 left
💡 Hint

Check which I2C buses exist on a Raspberry Pi by default.

🚀 Application
advanced
2:00remaining
How to scan all I2C buses on a Raspberry Pi?

You want to scan all available I2C buses on your Raspberry Pi to find connected devices. Which script correctly scans buses 0 and 1?

Ai2cdetect -y 0 | i2cdetect -y 1
Bfor bus in 0 1; do i2cdetect -y $bus; done
Ci2cdetect -y 0 && i2cdetect -y 1
Di2cdetect -y 0 1
Attempts:
2 left
💡 Hint

Think about how to run a command multiple times for different bus numbers.

🔧 Debug
expert
2:30remaining
Why does i2cdetect show all addresses as '--' despite devices connected?

You connect an I2C device to your Raspberry Pi and run i2cdetect -y 1. The output shows -- for all addresses, but you are sure the device is connected and powered. What is the most likely cause?

AThe I2C interface is disabled in Raspberry Pi configuration.
BThe device address is outside the scanned range.
CThe device is connected to a different I2C bus number.
DThe device is not powered properly.
Attempts:
2 left
💡 Hint

Check Raspberry Pi settings for I2C interface status.