How to Pick, Connect and Use a Camera for Raspberry Pi
Updated: 17 hours ago
To set up a Raspberry Pi for camera work, pick an official camera module that matches your Pi's port, plug its ribbon cable in while the Pi is powered off, and test it with rpicam-still. For most projects, Camera Module 3 is the right choice because it has autofocus and 12 megapixels. The whole job takes about ten minutes, and you can be recording video from the command line or Python in the same sitting.
Most first attempts fail for three small reasons. The ribbon cable has the wrong connector for the board, because the Pi 5 and Pi Zero use a smaller port than older models. The cable is seated backward. Or the module does not suit the scene, such as a fixed-focus lens on a close-up job. Search results tend to give you either a product catalog or a Python tutorial, and rarely both in order.
This guide covers the choice, the wiring, command-line capture, and Python control, in that order. At the end it covers what to do when an official module is not enough. Vadzo Imaging builds MIPI CSI-2 board cameras with driver support for Raspberry Pi 4 and 5, so you will also see where those fit.
What you need before you connect a Raspberry Pi Camera Setup
You need three things: a Pi with a camera connector, a ribbon cable that fits that connector, and a module that suits your scene. Get these right first and the rest of the setup is quick.
Check your port and cable
Official camera modules work with every Raspberry Pi that has a Camera Serial Interface (CSI) connector. The catch is connector size. Flagship models before the Pi 5 use a 15-pin connector. The Pi Zero series, Compute Module IO boards and the Pi 5 use a 22-pin connector. The Pi 5 has two camera ports, so you can run two cameras at once.
Board | Camera connector |
|---|---|
Flagship models before Pi 5 | 15-pin |
Pi Zero series | 22-pin |
Compute Module IO boards | 22-pin |
Pi 5 | 22-pin, two ports |
If you own a Pi 5 or a Zero, you need a ribbon cable with the smaller end. Check this before you order the camera.
Match the ribbon cable to your Pi's connector before you buy the camera.
Pick the right official module
Raspberry Pi's documentation lists five official camera families: Camera Module 2, Camera Module 3, the High Quality (HQ) Camera, the AI Camera and the Global Shutter (GS) Camera. There is no Camera Module 4 in that lineup, and Camera Module 1 has reached end of life.
Module | Still resolution | Focus | Lens | Best for |
|---|---|---|---|---|
Camera Module 2 | 8 MP | Adjustable, approx 10 cm to infinity | Built in | Basic projects, tutorials |
Camera Module 3 | 12 MP | Motorised autofocus, approx 10 cm to infinity | Built in, standard or wide | General use |
HQ Camera | 12.3 MP | Depends on lens | C/CS or M12 mount | Interchangeable lenses |
AI Camera | 12.3 MP | Adjustable, approx 20 cm to infinity | Built in | On-sensor neural networks |
GS Camera | 1.6 MP | Depends on lens | C/CS mount | Fast-moving subjects |
Camera Module 3 comes in a standard version (66 degree horizontal field of view) and a wide version (102 degrees, focusing from about 5 cm). Modules 2 and 3 also come in NoIR versions without an infrared filter. Pair a NoIR module with an infrared light source for night images.
Work through an example
Say you want a doorway camera on a Pi 5. Choose the standard Camera Module 3, since autofocus handles people at different distances. Buy a 22-pin ribbon cable. If the camera will watch a small hallway, take the wide version instead. That is the whole shopping list.
Step 1. Connect the camera to your Pi
Power the Pi off, seat the ribbon cable fully in the camera port, lock the clip, and reboot. Connecting a camera while the board is powered is the quickest way to a confusing error.
Fit the ribbon cable
Shut down the Pi and unplug the power.
Find the camera port. On a Pi 5, use either of the two.
Gently pull up on the edges of the port's plastic clip.
Slide the ribbon in with its metal contacts facing the contacts inside the port.
Push the plastic clip back down to lock the cable.
Plug the power back in and boot.
The cable should sit straight and feel snug. If it tilts or slides out with a light tug, the clip is not closed.
Confirm the Pi detects the camera
Once the desktop loads, open a terminal and list the cameras:
rpicam-hello --list-cameras
You should see your module's name and its supported modes. If the output says no cameras are available, shut down and reseat the cable, checking the orientation. Then confirm you used the right cable for your board. Those two fixes solve most detection problems.
If rpicam-hello --list-cameras shows your module, the hardware side is done.
Step 2. Take pictures and record video
Use rpicam-still for photos and rpicam-vid for video. Both ship with Raspberry Pi OS, so you need no extra install to get a first image.
Capture a still image
Run this to open a preview and save a photo to the Desktop:
rpicam-still -o ~/Desktop/image.jpg
Double-click the file on the Desktop to check it. To shrink the output, add --width and --height:
rpicam-still -o ~/Desktop/image-small.jpg --width 640 --height 480
Record video
Record with rpicam-vid:
rpicam-vid -o ~/Desktop/video.mp4
That command works as written on a Pi 5. On earlier boards, add the libav codec and set a length. The -t value is in milliseconds, so 10000 records for 10 seconds:
rpicam-vid -t 10000 --codec libav --libav-format mp4 -o ~/Desktop/video.mp4
Play the result with vlc ~/Desktop/video.mp4, or double-click the file. Check your module's supported video modes before you pick a size. Camera Module 3, for example, lists 2304 x 1296 at 56 fps as its fastest mode, and Camera Module 2 tops out at 1080p.
Two commands cover the basics: rpicam-still for photos and rpicam-vid for video.
Step 3. Control the camera with Python
Python gives you scripted capture, timed sequences and settings changes in a few lines. The picamzero library, built by the Raspberry Pi Foundation for beginners, is the easiest way in.
Install picamzero and take a photo
Install the library from a terminal:
sudo apt update sudo apt install python3-picamzero
Open Thonny or any Python 3 editor and save a new file as camera.py. Never name it picamzero.py, because Python will import your file instead of the library. Then enter:
from picamzero import Camera cam = Camera() cam.start_preview() cam.take_photo("~/Desktop/new_image.jpg") cam.stop_preview()
The preview shows only if a monitor is attached or you are connected over remote access such as VNC or Raspberry Pi Connect.
Record video and adjust settings
The same cam object records video and takes timed sequences:
cam.record_video("~/Desktop/new_video.mp4", duration=5) cam.capture_sequence("~/Desktop/sequence.jpg", num_images=3, delay=2)
If the image is upside down because of how you mounted the camera, flip it. Combining both flips gives a 180 degree rotation:
cam.flip_camera(hflip=True, vflip=True)
The library also supports greyscale, white balance modes such as daylight and tungsten, exposure, gain and contrast controls, and text or timestamp overlays. Change one setting at a time and re-shoot so you can see its effect.
Start with take_photo and record_video, then add one setting at a time.
When an official module is not enough
Move to a third-party MIPI board camera when you need true 4K video, a global shutter, a wider temperature range, or a camera you can buy in volume and customize. The official modules cover learning and prototypes well. Product designs often need more.
Signs you have outgrown the official range
Watch for these. You need a global shutter on a conveyor or moving robot, but the GS Camera's 1.6 MP is too low. You need 4K video, and Module 3's top listed video mode is 2304 x 1296. Or you are planning a product run and want engineering help with lenses, field of view and image tuning.
One more point. A CSI camera is not a plug-in webcam. If you want your Pi to act as a webcam, use a USB camera that is UVC compliant. Vadzo's UVC cameras work on Windows, Linux and Android without custom drivers.
Vadzo Bolt options for Raspberry Pi
Vadzo's Bolt series are MIPI CSI-2 board cameras on a 38 x 38 mm board that converts to 32 x 32 mm, with S-mount (M12) lenses. Prices below are the "from" prices on each product page.
Model | Sensor | Resolution | Shutter | Chroma | From |
|---|---|---|---|---|---|
onsemi AR1335 | 13 MP, 4K video | Rolling | Color | $165 | |
onsemi AR0234 | 2 MP, VCM autofocus | Global | Color | $190 | |
onsemi AR0235 | 2.3 MP | Global | Color | $202 | |
onsemi AR1335 | 13 MP | Rolling | Mono | $295 |
Volume pricing does not include the lens or cable, so budget for both and confirm the cable fits your Pi's connector. There is no minimum order quantity. Check each product page for the driver status of your exact Pi model and OS release. Vadzo's application engineering team can also help with lens and FOV selection.
Use official modules to learn and prototype, and a board camera when the project needs specs they do not offer.
Get your first frame on screen
Pick the module for your scene, match the cable to your Pi's port, connect with the power off, and confirm detection with rpicam-hello --list-cameras. Then take a still with rpicam-still, record video with rpicam-vid, and script it all in Python with picamzero. Each step builds on the one before, so a failure is easy to trace.
If your project outgrows an official module, because it needs 4K video, a global shutter or volume supply, the next step is a board camera with a driver path for your Pi. You can browse Vadzo's MIPI camera modules and ask the application engineering team to help you match a sensor, lens and cable to your build.



