Set Up the Raspberry Pi Camera Module for Photos and Video
Every modern Raspberry Pi has CSI camera connectors, and modules range from the cheap Camera Module 3 to the 12-megapixel HQ camera taking interchangeable lenses. Setup takes minutes, and the same pipeline powers time-lapses, security cams, and computer vision projects.
What you need
- Raspberry Pi with a CSI/CSI-2 connector (any current model; Pi 5 has two)
- Camera module and its ribbon cable; note Pi Zero needs a smaller 22-pin cable, usually sold separately
- Small screwdriver for the connector latch
- Raspberry Pi OS Bookworm or newer flashed per [[raspberry-pi-headless-setup]]
Step by step
- Power off the Pi fully before connecting the camera.
- Open the CSI connector by lifting the retaining latch gently; it hinges up a few millimeters, do not pull it out.
- Insert the ribbon cable with metal contacts facing the correct direction: contacts toward the HDMI side on most boards, away from the Ethernet port on Pi 3/4. Check your board diagram.
- Press the latch back down firmly and repeat at the camera end, blue tab facing outward.
- Boot and verify detection with
libcamera-hello --list-cameras, which should print your module and supported modes. - Take a still:
libcamera-jpeg -o test.jpg -w 1920 -h 1080. The preview flashes on any attached display for about five seconds unless you pass-t 1. - Record video:
libcamera-vid -t 10000 -o clip.h264captures ten seconds of 1080p H.264. - Install Python support with
sudo apt install python3-picamera2for programmatic capture; a two-line script grabs JPEGs from any Python project. - For remote setups, stream the preview over the network with
libcamera-vid -t 0 --inline --listen -o tcp://0.0.0.0:8888and view from another machine.
Common mistakes
- Inserting the cable upside down; the camera shows as not found or produces black frames.
- Yanking the latch out entirely, breaking a fragile plastic connector that is awkward to replace.
- Using a Pi Zero with the standard wide cable instead of the narrower zero-specific one.
- Running old raspistill commands copied from pre-2022 tutorials; Bullseye and later replaced them with libcamera equivalents.
Related guides
Combine the camera with motion-triggered GPIO inputs from [[gpio-led-blink-python]] to build an indicator light for captures. Run the whole rig remotely with [[raspberry-pi-headless-setup]] and archive footage onto [[raspberry-pi-network-storage]].