Installing the Raspberry Pi Camera Module

The original camera module (v1) is shown here installed into a Raspberry Pi 4. To install, locate the camera connector which should be clearly labelled on the circuit board as “camera”. Pull the black plastic surround on the connector upwards, insert the flat cable and close the surround fimly around the cable. The blue tab and writing on the cable should be facing towards the USB sockets.

Installing the camera module in a Raspberry Pi 4

Note the Raspberry Pi 5 is different. It has two camera connectors labelled Cam/Disp found in roughly the same place on the board (either can be used) but the connectors are narrower than previously. Most (or all) of the official Raspberry Pi cameras available at the time of writing use a wider connector than will fit in the socket, however a simple adapter cable is easily available to convert one to the other. No adapter is required for the Pis prior to the version 5 (except the zero).

The location of the camera connectors on a Raspberry Pi 5

To confirm the camera is installed correctly do:

rpicam-hello --list-cameras

which will produce output like this if it has detected the camera (this is a v1 camera, the output will be different for different camera models).

Available cameras
-----------------
0 : ov5647 [2592x1944 10-bit GBRG] (/base/soc/i2c0mux/i2c@1/ov5647@36)
    Modes: 'SGBRG10_CSI2P' : 640x480 [58.92 fps - (16, 0)/2560x1920 crop]
                             1296x972 [43.25 fps - (0, 0)/2592x1944 crop]
                             1920x1080 [30.62 fps - (348, 434)/1928x1080 crop]
                             2592x1944 [15.63 fps - (0, 0)/2592x1944 crop]

Many guides on the internet refer to raspi-still as a command line tool for taking photos however this was deprecated in releases of the Raspberry Pi OS after bullseye (since roughly 2022) and is no longer installed by default. Some older guides may suggest the camera needs to be enabled in raspi-config, but this is no longer the case and there is no such option on newer versions of the Raspberry Pi OS.

To take a picture:

rpicam-jpeg --nopreview --output test.jpg

This will write the image to the specified file.

Errors and Solutions

rpicam-jpeg attempts to open a preview window. This error is caused by it being unable to display the window, for example when running the Raspberry Pi headless without a display attached. Use the --nopreview option to prevent it opening a preview window.

[0:11:59.959129096] [1890]  INFO Camera camera_manager.cpp:284 libcamera v0.2.0+46-075b54d5
[0:12:00.002459888] [1893]  WARN RPiSdn sdn.cpp:39 Using legacy SDN tuning - please consider moving SDN inside rpi.denoise
[0:12:00.005034975] [1893]  INFO RPI vc4.cpp:447 Registered camera /base/soc/i2c0mux/i2c@1/ov5647@36 to Unicam device /dev/media4 and ISP device /dev/media1
[0:12:00.005154936] [1893]  INFO RPI pipeline_base.cpp:1144 Using configuration file '/usr/share/libcamera/pipeline/rpi/vc4/rpi_apps.yaml'
libEGL warning: DRI3: failed to query the version
libEGL warning: DRI2: failed to authenticate
X Error of failed request:  BadRequest (invalid request code or no such operation)
  Major opcode of failed request:  155 ()
  Minor opcode of failed request:  1
  Serial number of failed request:  16
  Current serial number in output stream:  16