🛠 Interfacing GPIO and sensors with the Smart Display Module
Objectifs
This tutorial aims to master low-level hardware interfacing on the Raspberry Pi Smart Display Module (SDM). Although the SDM is optimized for silent 4K display and commercial environments, it retains access to the Compute Module 5's GPIOs. You will learn to configure a GPIO pin to read a simple digital sensor (such as a button or motion detector) to trigger actions on the screen. This skill is crucial for creating interactive kiosks or reactive dashboards in commercial signage or flight information scenarios, where user input must influence displayed content without perceptible latency.
Matériel nécessaire
- Raspberry Pi Smart Display Module (SDM adapter)
- Raspberry Pi Compute Module 5 (CM5)
- Professional SDM-compatible display
- SD card with Raspberry Pi OS Lite (or desktop version)
- Simple digital sensor (e.g., push button or PIR sensor)
- 10kΩ pull-down resistor (if required by the circuit)
- Male-to-female jumper wires
- Compatible power supply for CM5/SDM
Étapes
- Physical preparation: Insert the Compute Module 5 into the Smart Display Module. Connect the SDM to the compatible SDM display. Plug in the power. For the sensor, connect the data pin to a free GPIO (e.g., GPIO 17) and ground (GND) to a GND pin on the exposed GPIO connector or via a compatible adapter for the SDM format.
- Software configuration: Boot the Raspberry Pi and open a terminal. Install the RPi.GPIO library if not present:
sudo apt update
sudo apt install python3-rpi.gpio
- Reading script: Create a Python file to test GPIO reading:
nano gpio_reader.py
Paste the following code:
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
try:
while True:
if GPIO.input(17):
print("Sensor activated")
else:
print("Sensor inactive")
time.sleep(0.1)
except KeyboardInterrupt:
GPIO.cleanup()
- Execution: Run the script:
python3 gpio_reader.py
Press the button or activate the sensor to see changes in the console.
Vérification
The terminal should display "Sensor activated" when GPIO 17 is high (3.3V) and "Sensor inactive" otherwise. Ensure no permission errors appear (use sudo if necessary). The SDM display must remain stable and silent, confirming that the GPIO operation does not interfere with 4K video rendering.
Pour aller plus loin
Integrate this GPIO reading into a Content Management System (CMS) compatible with Raspberry Pi 5. Use sensor data to dynamically change the content displayed on the SDM screen, leveraging the M.2 format for fast media storage.
Other tutorials for this board
- Getting started with the Raspberry Pi Smart Display Module
- Using Smart Display Module GPIOs
- Connect the Smart Display Module to the network for digital signage
- Getting Started with the Raspberry Pi Smart Display Module
- Deploying an autonomous digital signage with M.2 storage
- Getting Started with the Smart Display Module on Compute Module 5
Code examples for this board
gpio-led-blink-python.pyPythondht22-sensor-monitor.pyPythonwifi-status-checker.pyPythonm2-ssd-mount-check.shBashhailo-inference-test.pyPythongpio-led-status-indicator.pyPython