Python GPIO Development

This document describes the basic Python GPIO workflow on Quectel Pi M1/L1.

Environment Check

gpiodetect
ls -l /dev/gpiochip*
gpioinfo
python3 --version

Device Node

Description

/dev/gpiochip0

Currently verified as the main GPIO controller, label 400000.pinctrl

/dev/gpiochip1

Currently verified as the PMIC-related GPIO controller

/dev/gpiochip2

Currently verified as the LPI-related GPIO controller

Install Dependencies

sudo apt update
sudo apt install -y gpiod python3-venv python3-pip
python3 -m venv .venv
source .venv/bin/activate
pip install python-periphery

Read Example

The example uses line 36 on /dev/gpiochip0. Confirm the actual physical pin mapping before wiring.

from periphery import GPIO

chip = "/dev/gpiochip0"
line = 36

gpio = GPIO(chip, line, "in")
try:
    print(gpio.read())
finally:
    gpio.close()

Output Example

from periphery import GPIO
import time

chip = "/dev/gpiochip0"
line = 36

gpio = GPIO(chip, line, "out")
try:
    gpio.write(True)
    time.sleep(1)
    gpio.write(False)
finally:
    gpio.close()

Notes

  • GPIO line offset is not the same as the physical header pin number.

  • Use gpioinfo first; do not take over lines marked with [used].

  • The checked board uses libgpiod v1.6.3 for command-line validation.