Raspberry Pi

Using Camera with Pi

August 19, 2025 MakerWorks Team
Raspberry Pi Camera Module

Add vision to your Raspberry Pi projects! This tutorial shows you how to connect and use the official Raspberry Pi Camera Module to capture photos, record videos, and even stream live footage. This is essential for surveillance systems, robotics, and computer vision applications.

What You'll Need:

  • Raspberry Pi board (any model with a CSI camera connector, which is most of them!)
  • Raspberry Pi Camera Module (V1, V2, or High Quality Camera). The ribbon cable usually comes with the camera.
  • Latest Raspberry Pi OS installed and updated on your Pi.

Step 1: Connect the Camera Module to Your Pi

This is a delicate but straightforward step. Ensure your Raspberry Pi is powered off before you begin.

  1. Locate the CSI (Camera Serial Interface) camera port on your Pi. It's a long, white or black connector, usually near the HDMI ports.
  2. Gently pull up on the small plastic clips/edges on both sides of the connector. Do not pull too hard, just enough to release the clasp.
  3. Carefully insert the ribbon cable from the camera module into the connector. Ensure the silver metallic contacts on the ribbon cable are facing the HDMI port side (for Raspberry Pi 4/5) or away from the Ethernet port (for older Pis like Pi 3/2). Make sure it's straight and fully inserted.
  4. Once inserted, gently push the plastic clips back down to secure the cable firmly in place.
Properly connecting the ribbon cable to the CSI port on your Raspberry Pi.

Step 2: Enable the Camera Interface in Raspberry Pi OS

The camera interface is usually disabled by default for security and resource management.

  1. Power on your Raspberry Pi.
  2. Open a terminal (Ctrl+Alt+T or click the terminal icon).
  3. Run the Raspberry Pi configuration tool:
    
    sudo raspi-config
                            
  4. In the raspi-config menu, navigate using arrow keys:
    • Select "3 Interface Options"
    • Select "P1 Camera"
    • Select "Yes" to enable the camera interface.
  5. Exit raspi-config (Tab to <Finish>, Enter). You'll likely be prompted to reboot your Pi. Select "Yes" to reboot.

Step 3: Capturing Images and Video

After rebooting, your camera should be ready! Newer versions of Raspberry Pi OS (Bullseye and later) use libcamera tools. Older versions used raspistill and raspivid.

For libcamera tools (Recommended for newer OS - Raspberry Pi OS Bullseye or later):

These commands are run in the terminal.

  • Capture a still image:
    
    libcamera-still -o my_first_image.jpg
                            

    This will capture an image and save it as my_first_image.jpg in your current directory.

  • Record a video (e.g., 5 seconds long):
    
    libcamera-vid -o my_first_video.h264 --t 5000
                            

    The --t 5000 specifies the duration in milliseconds (5000ms = 5 seconds). The video will be saved as my_first_video.h264.

  • View a live preview (without saving):
    
    libcamera-preview
                            

For raspistill/raspivid (Older OS - up to Raspberry Pi OS Buster):

  • Capture a still image:
    
    raspistill -o image.jpg
                            

    Captures an image and saves it.

  • Record a video (e.g., 10 seconds long):
    
    raspivid -o video.h264 -t 10000
                            

    Records a video for 10 seconds.

The Raspberry Pi Camera Module opens up incredible possibilities for surveillance, time-lapse photography, security systems, and even basic computer vision projects! Have fun exploring its capabilities!