First hardware project¶
Copyright © Quectel Wireless Solutions Co., Ltd. 2026. All rights reserved.
This guide walks you through two introductory hardware tutorials using the Quectel Pi H1 development kit: capturing photos with an IMX219 camera and handling onboard button events.
Capture your first photo with the IMX219 camera¶
If you do not have an IMX219 camera module, you can skip this section.
Install the camera¶
Always disconnect power from the Quectel Pi H1 before attaching or removing ribbon cables.
Find the MIPI CSI ribbon connector labeled CAMERA1 or CAMERA2 on the board (the following examples use CAMERA1).
Gently lift the black locking latch, then insert the IMX219 camera ribbon cable with the metal contacts facing down (toward the top surface of the board). Once fully seated, press the latch back down to lock it in place. (Caution: Never insert the cable backward or misaligned at an angle. Doing so may cause an electrical short and damage the board upon boot.)
Verify that the ribbon cable is securely seated and straight, then reconnect power and boot the board.
Capture a photo with the camera¶
Configure the environment¶
Before running the photo capture command, set the plugin path (you must set it again each time you open a new terminal window):
export GST_PLUGIN_PATH=/usr/lib/gstreamer-1.0:$GST_PLUGIN_PATH
Capture a photo¶
Run the following command to capture a photo and save them as JPEG files:
max-files controls both the number of photos captured and the number of files saved locally. With max-files=1, the command captures one photo and saves one JPEG file in /home/pi. Setting max-files=n captures n photos and saves n local files.
sudo -E gst-launch-1.0 -e \
qtiqmmfsrc name=camsrc ! \
'video/x-raw,format=NV12,width=1280,height=720,framerate=30/1' ! \
queue ! videoconvert ! jpegenc ! \
multifilesink location=/home/pi/shot-%05d.jpg max-files=1
When the pipeline state changes to PLAYING, image capture is active. Press Ctrl+ C to stop the pipeline.
Once stopped, run the following command to verify that the photo was captured successfully, or double-click the image directly on the GNOME desktop to view it:
ls -lh /home/$USER/shot-*.jpg
Expected output:
-rw-r--r-- 1 root root 128K Oct 1 10:30 /home/$USER/shot-00000.jpg
Advanced: Capture a photo with Python and OpenCV¶
Install OpenCV:
sudo apt update
sudo apt install -y python3-opencv
Create the file ~/capture.py:
import cv2
# Access the MIPI camera through a GStreamer pipeline
gst_pipeline = (
"qtiqmmfsrc name=camsrc ! "
"video/x-raw,format=NV12,width=1280,height=720,framerate=30/1 ! "
"videoconvert ! video/x-raw,format=BGR ! appsink drop=true max-buffers=1"
)
cap = cv2.VideoCapture(gst_pipeline, cv2.CAP_GSTREAMER)
if not cap.isOpened():
print("Error: Unable to open the camera")
exit(1)
# Skip the first few frames to allow automatic exposure and white balance to settle
for i in range(30):
cap.read()
ret, frame = cap.read()
if ret:
cv2.imwrite("/home/pi/opencv_photo.jpg", frame)
print("Photo captured successfully and saved to /home/pi/opencv_photo.jpg")
else:
print("Error: Unable to read an image frame")
cap.release()
Note
The script saves the photo to /home/pi/opencv_photo.jpg. Edit this path to save the file elsewhere.
Run the script (requires sudo privileges; ensure export GST_PLUGIN_PATH=/usr/lib/gstreamer-1.0:$GST_PLUGIN_PATH is set beforehand):
sudo -E python3 ~/capture.py
Note
The IMX219 is a MIPI CSI-2 image sensor. On the Quectel Pi H1 platform, the camera is managed centrally by the Qualcomm Multi-Media Framework (QMMF) service via the qtiqmmfsrc plugin. This example accesses the camera through a GStreamer pipeline.
Explore GPIO¶
View GPIO pin status¶
Install the GPIO command-line tools:
sudo apt update && sudo apt install -y gpiod
List all GPIO controllers in the system:
sudo gpiodetect
Example output:
pi@quectelpi:/$ sudo gpiodetect
gpiochip0 [c440000.spmi:pmic@8:pinctrl@c00] (12 lines)
gpiochip1 [c440000.spmi:pmic@1:gpio@8800] (10 lines)
gpiochip2 [c440000.spmi:pmic@2:gpio@8800] (9 lines)
gpiochip3 [c440000.spmi:pmic@0:gpio@b000] (4 lines)
gpiochip4 [f100000.pinctrl] (176 lines)
gpiochip5 [33c0000.pinctrl] (15 lines)
View the status of all pins on a specific controller:
sudo gpioinfo --chip gpiochip4
Example output:
pi@quectelpi:/$ sudo gpioinfo --chip gpiochip4
gpiochip4 - 176 lines:
line 0: unnamed input
line 1: unnamed input
line 2: unnamed output active-low consumer=perst
line 3: unnamed input
line 4: unnamed input
line 5: unnamed input
line 6: unnamed output consumer=switch
line 7: unnamed output consumer=enable
line 8: unnamed output
line 9: unnamed output consumer=soc@0:pin40_en_vr
...
Each output line represents a GPIO pin. A pin marked with consumer=xxx is in use by a kernel driver.
Note
The onboard KEY1 and KEY2 buttons are managed by the kernel's gpio-keys and pmic_resin drivers and are exposed to user space as standard Linux input devices. Therefore, use evtest or evdev to read button events instead of manipulating GPIO pins directly.
Troubleshooting¶
The photo capture command reports "no element qtiqmmfsrc".
Set the plugin path first:
export GST_PLUGIN_PATH=/usr/lib/gstreamer-1.0:$GST_PLUGIN_PATH
Then run the photo capture command.
The photo capture command reports "Failed to connect to bus".
Ensure the command includes the sudo -E prefix, as the camera plugin requires root privileges.
If the error persists, the background camera daemon may be in an abnormal state. Restart the media service in the terminal:
sudo systemctl restart qmmf-server
evtest does not display button events.
The device numbers may differ from those in the examples. Run sudo evtest without arguments to list all input devices. Then locate the gpio-keys and pmic_resin devices and use their corresponding event numbers.
The Python script reports a permission error.
Both input devices and the camera require root privileges:
Button script: sudo -E python3 ~/button_monitor.py
Photo capture script: sudo -E python3 ~/capture.py