Challenge - 5 Problems
SPI Master on Raspberry Pi
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate1:30remaining
What is the output of checking SPI status after enabling it?
After enabling SPI on Raspberry Pi using raspi-config, you run the command
ls /dev/spi*. What output do you expect?Raspberry Pi
ls /dev/spidev*
Attempts:
2 left
💡 Hint
SPI devices appear as spidev nodes under /dev after enabling.
✗ Incorrect
When SPI is enabled on Raspberry Pi, device files like /dev/spidev0.0 and /dev/spidev0.1 are created. These represent SPI bus 0 with chip selects 0 and 1.
🧠 Conceptual
intermediate1:30remaining
Which file must be edited to enable SPI manually on Raspberry Pi?
To enable SPI without using raspi-config, which file do you edit to load the SPI kernel module on boot?
Attempts:
2 left
💡 Hint
This file lists kernel modules to load at startup.
✗ Incorrect
The /etc/modules file lists kernel modules to load during boot. Adding 'spi-bcm2835' here enables SPI manually.
🔧 Debug
advanced2:00remaining
Why does SPI communication fail after enabling SPI?
You enabled SPI on Raspberry Pi but your Python SPI code raises
FileNotFoundError: [Errno 2] No such file or directory: '/dev/spidev0.0'. What is the most likely cause?Raspberry Pi
import spidev spi = spidev.SpiDev() spi.open(0, 0)
Attempts:
2 left
💡 Hint
The device file /dev/spidev0.0 must exist for spidev to open it.
✗ Incorrect
If SPI is not enabled in raspi-config or device tree, the device files /dev/spidev* do not exist, causing FileNotFoundError.
📝 Syntax
advanced1:30remaining
Which command correctly enables SPI via device tree overlay?
To enable SPI by editing /boot/config.txt, which line is correct?
Attempts:
2 left
💡 Hint
The overlay name specifies SPI bus and chip selects.
✗ Incorrect
The overlay 'spi0-2cs' enables SPI bus 0 with 2 chip selects, which is the common default for Raspberry Pi SPI.
🚀 Application
expert2:00remaining
How to verify SPI communication speed in Python on Raspberry Pi?
You want to set and verify the SPI clock speed in your Python code using spidev. Which code snippet correctly sets the speed to 1 MHz and prints it?
Attempts:
2 left
💡 Hint
spidev uses max_speed_hz attribute to set clock speed.
✗ Incorrect
The spidev library uses the attribute max_speed_hz to set and get SPI clock speed. Methods like set_speed or attributes like speed do not exist.
