Bird
0
0
Raspberry Piprogramming~20 mins

Enabling SPI on Raspberry Pi - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
SPI Master on Raspberry Pi
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
1: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*
ANo such file or directory
B/dev/spi0 /dev/spi1
C/dev/spidev0.0 /dev/spidev0.1
D/dev/spi_master0
Attempts:
2 left
💡 Hint
SPI devices appear as spidev nodes under /dev after enabling.
🧠 Conceptual
intermediate
1: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?
A/etc/modules
B/boot/config.txt
C/etc/spi.conf
D/boot/cmdline.txt
Attempts:
2 left
💡 Hint
This file lists kernel modules to load at startup.
🔧 Debug
advanced
2: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)
ASPI clock speed is set too high
BPython spidev library is not installed
CSPI pins are used by another device
DSPI interface is not enabled in raspi-config or device tree
Attempts:
2 left
💡 Hint
The device file /dev/spidev0.0 must exist for spidev to open it.
📝 Syntax
advanced
1:30remaining
Which command correctly enables SPI via device tree overlay?
To enable SPI by editing /boot/config.txt, which line is correct?
Adtoverlay=spi0-2cs
Bdtoverlay=spi0-1cs
Cdtoverlay=spi-bcm2835
Ddtoverlay=spi1-1cs
Attempts:
2 left
💡 Hint
The overlay name specifies SPI bus and chip selects.
🚀 Application
expert
2: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?
A
spi.clock_hz = 1000000
print(spi.clock_hz)
B
spi.max_speed_hz = 1000000
print(spi.max_speed_hz)
C
spi.speed = 1_000_000
print(spi.speed)
D
spi.set_speed(1000000)
print(spi.get_speed())
Attempts:
2 left
💡 Hint
spidev uses max_speed_hz attribute to set clock speed.