Creative DIY

How to Set Up a Raspberry Pi Camera Module

Christian Cawley 09-08-2018

Many accessories are available for the Raspberry Pi, but among the most popular is the camera module. But how do you safely connect one, and then get the best out of it?


If you haven’t tried Raspberry Pi photography, now is the time. Here’s how to get started with the Raspberry Pi camera module.

Setting Up the Camera Module

Raspberry Pi Camera Module

Own a Raspberry Pi, and want to get started with the camera module? Perhaps you want to make some time-lapse movies, or build a motion-detecting security camera. Whatever your project, if it requires a camera, your best option is the official camera module. Setup is straightforward, and requires you to:

  • Connect the camera module: A ribbon cable connects the camera to the Raspberry Pi.
  • Enable the camera: This can be done in the configuration screen.
  • Securely mount the camera module: A suitable case is required.
  • Take a picture: Use a simply command line instruction.

Before you get started, however, you’ll need to ensure you have everything you need. A Raspberry Pi camera module v2 can be purchased on Amazon.

Raspberry Pi Camera Module V2-8 Megapixel,1080p (RPI-CAM-V2) Raspberry Pi Camera Module V2-8 Megapixel,1080p (RPI-CAM-V2) Buy Now On Amazon $24.98


What You’ll Need

For the best results, gather together the following:

  • Raspberry Pi (any model will do, although the Raspberry Pi Zero requires a different ribbon cable)
  • Raspberry Pi Camera Module
  • microSD card with Raspbian installed (other Raspberry Pi distros can be used)
  • Ethernet cable/Wi-Fi dongle where required
  • USB Keyboard
  • Suitable Raspberry Pi case (see below)
  • Reliable power supply (either an adaptor, or a portable solution)

With these items collected, it shouldn’t take long to get your Raspberry Pi Camera Module hooked up to the Pi, and start snapping photos. Before you start, make sure you have installed the latest version of Raspbian How to Update Your Raspberry Pi to the Latest Raspbian OS Want to keep your Raspberry Pi up-to-date? Here's how to upgrade Raspbian using a standard update or by upgrading to a new version. Read More on your microSD card.

The Official Raspberry Pi Camera Module

Different versions of the official camera module for the Raspberry Pi have been released over the years. As of 2018, version 2.0 is available, shipping in two flavors.

Standard Raspberry Pi Camera Module: This is the default option, the one you’ll probably choose for standard photos. Color reproduction of this 5MP camera is surprisingly good for what is a comparatively low-cost camera.


NoIR Raspberry Pi Camera Module: The NoIR variant ships without the IR filter, hence the name. This makes it better for night shoots, although a light source is useful.

Connecting the Camera Module

When you unpack your camera module, you’ll find it ships with a ribbon cable. This is usually already connected to the camera itself (although not always) and connects to the Raspberry Pi via a ribbon cable connector.

Insert the camera module cable into this slot

Before connecting the camera to your Raspberry Pi, be sure to take antistatic precautions. This will avoid accidentally damaging the device with static electricity. You should also take the time to identify the camera connection slot on your Raspberry Pi first.


Next, ensure the cable is connected to the camera. Once this is done, it’s time to carefully open the slot connector, ensuring the small T-shaped plastic is loose. The, slot the ribbon into place, the silver side facing the HDMI connector.

With the ribbon in inserted, carefully press the plastic into place to secure it.

Hooking Up the Camera Module and Raspberry Pi Zero

If you’re using the Raspberry Pi Zero, things are a little different.

On this smaller Raspberry Pi, the connecting port is smaller, and so a different ribbon cable is required. Ensure the silver contacts face upwards; they slot under the T-clip. This can be a little bit fiddly with the narrower ribbon cable.


Raspberry Pi Zero camera connector

You can order a suitable cable from Amazon. Also, note that you can find cables of different lengths, which might prove useful for your project.

Arducam 15 Pin 1.0mm Pitch to 22 Pin 0.5mm Camera Cable for Raspberry Pi Zero Version 1.3 Specific (Pack of 2) Arducam 15 Pin 1.0mm Pitch to 22 Pin 0.5mm Camera Cable for Raspberry Pi Zero Version 1.3 Specific (Pack of 2) Buy Now On Amazon $7.99

Powering Up and Enabling the Camera Module

With the camera connected, it’s time to boot up the Raspberry Pi. Whether you’re connected directly to a TV or monitor, or you’re using SSH to remotely access the computer Setting Up Your Raspberry Pi For Headless Use With SSH The Raspberry Pi can accept SSH commands when connected to a local network (either by Ethernet or Wi-Fi), enabling you to easily set it up. The benefits of SSH go beyond upsetting the daily screening... Read More , you’ll need to open the Raspberry Pi Configuration Screen. In the Raspbian PIXEL desktop environment, you’ll find this in the Preferences menu.

Enable your Raspberry Pi camera in the raspi-config screen

However, you may prefer to use the command line and enter:

sudo raspi-config

Whatever method you use, find Interfacing Options > Camera option and select Yes. You’ll be prompted to reboot your Raspberry Pi, so do this and wait for it to reboot.

Mounting the Camera in Your Raspberry Pi Case

Many mounting options are available for the Raspberry Pi Camera Module. You could simply use adhesive putty, for instance, although that’s quite a messy option. Probably the best solution is to find a case with a mounting point for the camera module.

Here are three good options:

1. SmartPi Case and Enclosure

One of the top choices for a Raspberry Pi case and Camera Module enclosure on Amazon is the SmartPi, a Lego-compatible case for the Raspberry Pi B+, 2, and 3. While the case has wall-mounting options and Lego plates, the camera module enclosure can be mounted on the case itself. There is also a GoPro compatible mounting connector.

Building Block Compatible SmartiPi Raspberry Pi B+,2, 3, and Pi 3 B+ case w/Camera case and GoPro Compatible Mount – Gray Building Block Compatible SmartiPi Raspberry Pi B+,2, 3, and Pi 3 B+ case w/Camera case and GoPro Compatible Mount – Gray Buy Now On Amazon

2. Smarticase Camera Enclosure

If you already own a SmartPi case, then it makes sense to purchase the Smarticase camera module enclosure, on its own from Amazon. With holes to screw the case to a surface, it also features “building block” compatibility for mounting on the SmartPi, or any Lego you may have.

Smarticase Building Block Compatible case for The Raspberry Pi Official Camera - Gray Smarticase Building Block Compatible case for The Raspberry Pi Official Camera - Gray Buy Now On Amazon

3. Keyestudio Black Case

For a full case solution, ideal for a Raspberry Pi B+, 2, and 3, take a look at this affordable case on Amazon. The Keyestudio case features mounting poles for the Raspberry Pi Camera Module, potentally letting you use the entire Pi as a mountable camera unit.

KEYESTUDIO Black Case Supporting Camera Installation for Raspberry Pi 3 / B+/2 Model B KEYESTUDIO Black Case Supporting Camera Installation for Raspberry Pi 3 / B+/2 Model B Buy Now On Amazon

Snapping a Picture With Your Raspberry Pi

By now you should have a Raspberry Pi hooked up to an enabled camera module, and everything mounted in a case. You’re now ready to take a photo.

Open a terminal window, and enter this simple command:

raspistill -o image.jpg

This test photo can be found in the Pictures directory on your Raspberry Pi desktop. Other commands are possible.

For example, if the photo is upside down, you can use the -vf and -hf flags to flip the vertical and horizontal axes.

raspistill -vf -hf -o image.jpg

For a full list of commands for taking photos, enter the single command:


You Can Even Record Video!

In addition to taking stills, the Raspberry Pi Camera Module can record video. Again, you’ll need to use the right command, this time using the raspivid tool. This command will record a video in HD:

raspivid -o video.h264

(As with raspistill, you can use -vf and -hf if necessary.)

Note that a standard microSD card is likely to be too small for lengthy video recording (although if you have hooked up an external drive, this should provide more than enough space). As such, you might use the -t flag to limit the recording time, using a value in milliseconds:

raspivid -o video.h264 -t 5000

This will record five seconds of footage.

Have Fun With Your Raspberry Pi Camera Module

With your Raspberry Pi connected to its preferred camera option, you’re ready to take photos, and record video. So, what’s next?

Well, you could hook up a thermal printer and create a Polaroid-style instant camera. Or you might use it as the camera in your own stop-motion animation studio.

The choice is yours. For more setup tips, check our unofficial Raspberry Pi setup guide Raspberry Pi: The Unofficial Tutorial Whether you're a current Pi owner who wants to learn more or a potential owner of this credit-card size device, this isn't a guide you want to miss. Read More .

Related topics: DIY Project Ideas, Raspberry Pi.

Affiliate Disclosure: By buying the products we recommend, you help keep the site alive. Read more.

Whatsapp Pinterest

Leave a Reply

Your email address will not be published. Required fields are marked *

  1. Curt
    February 3, 2019 at 6:28 am

    On my 3 B Zero W, the ribbon installs with the silver faced down (not face up as indicated in this post. Not sure the W port is any different than the regular Zero, but I doubt it.