🛠 Interfacing GPIO and sensors with the Smart Display Module

Raspberry Pi Smart Display Module · intermediaire · Apprenez à connecter et lire un capteur via les GPIO du Smart Display Module pour enrichir vos affichages dynamiques.

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

Étapes

  1. 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.
  1. 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
  1. 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()
  1. 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

Code examples for this board

← Back to the board 🛠 All tutorials