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
ModuleResolutionFocus
Camera Module v15 MPFixed focus
Camera Module v28 MPFixed focus
Camera Module 312 MPAutofocus + HDR
HQ Camera12.3 MPManual focus via interchangeable lens

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()
Note: The ribbon cable's contacts are fragile — never force it in, and double-check orientation before powering on, since a reversed cable is the most common reason a camera isn't detected. If libcamera-hello reports no cameras were found, re-seat the ribbon at both ends (the CSI port and the camera board itself) before assuming there's a hardware fault.

Exercise: Raspberry Pi Camera

How does the official Raspberry Pi Camera Module typically connect to the board?