Raspberry Pi Camera Module
The Raspberry Pi Camera Module connects directly to the board's CSI ribbon-cable port and is controlled in Python with the modern picamera2 library.
What Is the Camera Module?
The Raspberry Pi Camera Module is an official add-on board built specifically for the Pi. Unlike a USB webcam, it connects through the Camera Serial Interface (CSI) — a dedicated ribbon-cable port present on every full-size Raspberry Pi model — which carries a high-bandwidth video signal directly to the processor with very little CPU overhead. Several versions have shipped over the years, each pairing a different image sensor with the same basic ribbon-cable design, so newer sensors can often be used with older boards and vice versa, sometimes with an adapter cable.
- Plugs into the CSI port, not a USB port — a short flat ribbon cable carries the video signal
- The Camera Module 3 adds autofocus and HDR support compared to earlier fixed-focus versions
- The High Quality (HQ) Camera accepts interchangeable C- and CS-mount lenses for manual focus and zoom
- Pi Zero boards use a narrower CSI connector and need a small adapter ribbon cable
- Modern Raspberry Pi OS controls all of these cameras through the same libcamera/picamera2 software stack
Connecting the Camera to the CSI Port
Power off the Pi completely before connecting or disconnecting the camera. Find the CSI port — a plastic clip connector usually located between the HDMI and audio jacks, though its exact position varies by model, so check your board's silkscreen labelling or documentation. Gently pull the clip's edges up, slide the ribbon cable in with the metal contacts facing the correct direction for your specific board (this varies between models, so verify against the official diagram before powering on), then push the clip back down to lock the cable in place. Ribbon cables are delicate, so handle them by the edges and avoid sharp folds.
Checking the Camera and Installing picamera2
Modern Raspberry Pi OS (Bullseye and later) detects the camera automatically through the libcamera stack, so there's usually no separate 'enable camera' toggle to hunt for in raspi-config. Confirm the Pi can see the camera by running libcamera-hello (or rpicam-hello on the newest OS releases) from a terminal — a preview window should appear. The picamera2 Python library ships preinstalled on current Raspberry Pi OS images; if it's missing, install it with sudo apt install -y python3-picamera2.
Capturing a Still Photo with picamera2
Example
from picamera2 import Picamera2
import time
picam2 = Picamera2()
picam2.configure(picam2.create_still_configuration())
picam2.start()
time.sleep(2) # give the sensor a moment to adjust exposure
picam2.capture_file("photo.jpg")
picam2.stop()
print("Saved photo.jpg")Example
from picamera2 import Picamera2
picam2 = Picamera2()
config = picam2.create_still_configuration(main={"size": (1920, 1080)})
picam2.configure(config)
picam2.start()
picam2.set_controls({"ExposureTime": 20000, "AnalogueGain": 1.5})
picam2.capture_file("bright_photo.jpg")
picam2.stop()Exercise: Raspberry Pi Camera
How does the official Raspberry Pi Camera Module typically connect to the board?