Setting up a Raspberry Pi 3 Model B+ Camera Module

Zac Sung
5 min readSep 22, 2019

--

Raspberry Pi 3 Model B+ Camera Module

Today, we are going to install a camera module on a Raspberry Pi. (If you haven’t installed Raspberry Pi, you can refer to Setting up a Raspberry Pi 3 Model B+ headless using Mac.)

Here are the devices we use:

  • Raspberry Pi 3 Model B+
  • NoIR Camera(5MP)
  • 3W IR LED x 2
Raspberry Pi 3 Model B+ / NoIR Camera(5MP) / 3W IR LED

We will install hardware devices first and then modify software settings in raspi-config. Finally, we will use commands to take pictures and record video.

Let’s get started!

STEP 1: Hook up IR LED to the camera (optional)

There are generally two types of Raspberry Pi Camera modules. Ones with IR filter and ones without.

The ones with IR filter allow for a more colorized view, but when trying to view night vision, it will filter the IR, and you won’t be able to easily see the night vision on the camera.

The ones without IR filter (NoIR = No Infrared) allow the IR light wavelength to pass through the lens, and the camera module then is able to see the IR light to pass through the lens to the camera module. These will have a slight discoloration because the lens is picking up and sensing IR with all the other visible colors.

This means that pictures you take by daylight will look decidedly curious, but it gives you the ability to see in the dark with infrared lighting.

The camera I used is a NoIR camera, so I will hook up an IR LED which allows me to see in the dark.

NoIR Camera(5MP) / 3W IR LED

What we need is to hook up the two IR LEDs on the left and right sides of the camera with screws. As shown below:

Hook up the IR LED on the left and right sides of the camera

STEP 2: Connect the camera module to Raspberry Pi

Next, we need to connect the camera (with IR LED) to the Raspberry Pi.

Ensure your Raspberry Pi is power off.

  1. Locate the camera module slot.
Camera module slot on Pi

2. Gently pull up on the edges of the slot’s plastic clip. (Don’t pull too hard. It can only pull up about 1~2 mm)

Pull up on the edges of the slot’s plastic clip

3. Insert the camera module cable. Make sure the cable is oriented correctly and inserted flat.

4. Push the plastic clip back into place.

Insert the camera module cable

STEP 3: Enable Camera function in raspi-config

Boot up Raspberry Pi after you installed the camera module properly. Connect to Raspberry Pi via SSH. Then enter the following command on the terminal:

sudo raspi-config

It will display the configure setting page as below.

raspi-config

Select Interfacing Options:

Interfacing Options

Enable Camera:

Enable Camera

When the Camera function is enabled, you will receive a pop-up window asking if you would like to reboot. Just select yes, and the camera will be active when reboot completed.

The pop-up window for reboot Pi

STEP 4: Take pictures and record video via command line

Now, we can do the functionality test for the camera module via the command line.

First, let’s create a folder to store the images and video files. And navigate to the folder.

mkdir ~/Desktop/images/
cd ~/Desktop/images/

Then, use the command raspistill to capture an image and specifies the output filename with -o option.

raspistill -o image.jpg

The LED on the camera module will light up when the camera is active. (This function can be disabled)

The LED lights up when the camera is active

Let’s look for the image via VNC viewer. You can see the resolution is 2592x1944, which equal to 5MP. That’s the ability of our camera.

2592 x 1944 = 5,038,848 ~= 5M pixels

Check image.jpg

Next, use the command raspivid to record a video clip. Specifies the output filename with -o option and specify the length of the video taken with -t option. (default length of time is 5 seconds)

raspivid -o video.h264 -t 10000    # record a 10 seconds of video

We can play the video using the VLC media player by double-clicking the video file.

Play video.h264

That’s it. Now you know how to use the Camera Module on Raspberry Pi. Next, we will try to control the camera with Python code.

REFERENCE

--

--