🛠 Getting Started with GPIO on LattePanda Mu Ultra
Objectives
This tutorial aims to familiarize you with the digital General Purpose Input/Output (GPIO) interfaces of the LattePanda Mu Ultra module. We will configure one pin as an output to light up an LED and another as an input to detect a button press. Although the Mu Ultra is optimized for embedded AI with its 115 TOPS, it remains a full x86 computer capable of interacting with the physical world via its Mini Carrier Board.
Materials Needed
- LattePanda Mu Ultra Module (Core Ultra 5 or 7)
- Mini Carrier Board
- Suitable USB-C Power Supply
- 1 Red LED and 1 330 Ω Resistor
- 1 Push Button
- Jumper Wires
- Host computer for SSH access or Monitor/Keyboard/Mouse
Steps
- System Preparation: Ensure your Linux system (Ubuntu 24.04+ recommended) is up to date. Open a terminal and install the
libgpiodlibrary, which facilitates GPIO management on modern Linux.
sudo apt update
sudo apt install gpiod libgpiod2 python3-libgpiod
- Pin Identification: Consult the Mini Carrier Board documentation to identify available GPIO pins. Here, we assume pin 17 is the output (LED) and pin 4 is the input (Button). Note that GPIO voltages are typically 3.3V.
- Wiring: Connect the long leg (anode) of the LED to pin 17 via the resistor. Connect the short leg (cathode) to Ground (GND). For the button, connect one leg to pin 4 and the other to Ground.
- Control Script: Create a file named
test_gpio.py.
import gpiod
import time
chip = gpiod.Chip('gpiochip0')
line_out = chip.get_line(17)
line_out.request(consumer='led', type=gpiod.LINE_REQ_DIR_OUT)
line_in = chip.get_line(4)
line_in.request(consumer='btn', type=gpiod.LINE_REQ_DIR_IN, flags=gpiod.LINE_REQ_FLAG_BIAS_PULL_UP)
try:
while True:
if line_in.get_value() == 0:
print("Button pressed!")
line_out.set_value(1)
else:
line_out.set_value(0)
time.sleep(0.1)
except KeyboardInterrupt:
line_out.release()
line_in.release()
- Execution: Run the script with necessary permissions.
sudo python3 test_gpio.py
Verification
Press the push button. The LED should light up immediately, and the terminal should display "Button pressed!". If nothing happens, check the wiring, LED polarity, and pin numbers in the carrier board documentation.
Going Further
Explore analog inputs if available on your configuration, or use the Intel Arc GPU to process sensor data in real-time, leveraging the Mu Ultra's AI power.
Other tutorials for this board
Code examples for this board
lp-mu-gpio-gpiod.shbashlp-mu-i2c-sensor.pypythonlp-mu-nvme-benchmark.shbashlp-mu-opencv-gpu.pypythonlp-mu-ethernet-monitor.pypythonlattepanda-mu-ultra-npu-inference-onnx-6.inopython