Cameras for Raspberry Pi

  1. Home
  2. Docs
  3. Cameras for Raspberry Pi
  4. PTZ Camera
  5. 13MP PTZ Camera

13MP PTZ Camera

0. Introduction

The Arducam 13MP PTZ camera mainly consists of the following two systems:

  • An Arducam 13MP OBISP MIPI Camera Module
  • A driver-board-based PTZ controlling system for Pan-tilt servos and Lens motors (Zoom and Autofocus)

It comes in two models with different package items. The following table shows their differences.

Camera w/ Zoom LensPTZ Control SystemPan-Tilt ServosServo Mounting Platform
B016713MPIncludedIncludedPrepare your ownPrepare your own
B0167B13IncludedIncludedIncludedIncluded
Arducam 13MP PTZ Camera Variations

This instruction is mainly about operating the pan-tilt-zoom on the Raspberry Pi. If you want to use it with the Jetson Nano, refer to the last chapter.

We recommend you to go through this quick start carefully. If you encounter any issues while using this product, contact us or post in our forum.

1. Hardware Assembly

1.1 Connect the camera module to RPi with Ribbon Cable

The camera module connects to the RPi with a ribbon cable.

  • To connect to the standard RPi, such as Pi 4, use the included 15pin-15pin white ribbon cable.
  • To connect to Pi Zero and Compute Module, prepare a 15pin-22pin cable on your own.

The ribbon cable establishes a connection to the RPi and camera module with the help of metal contacts.

  • The ribbon cable comes with metal contacts on both ends, but different sides.
  • The camera module comes with metal contacts on the camera connector, beside the lens mount
  • The RPi also comes with metal contacts on its CSI camera connector, beside the HDMI connector
white camera ribbon cable contacts
Contacts on the white ribbon cable
camera ribbon cable contacts
Contacts on the gold ribbon cable
metal contacts camera connector 2
Contacts on the Pi’s camera connector
camera connector contacts
Contacts on the cam module’s connector

Therefore, to ensure we are connecting the components in the correct way, just make sure the metal contacts of the ribbon cable are touching those of the camera module and the RPi on both ends.

1.1.1 Cable connection to the camera module

pull the clip of the connectors
  1. Gently pull down on the edges of the connector’s plastic clip and avoid pulling it off.
  2. Insert the ribbon cable. Make sure the metal contacts are facing up to the lens instead of the camera board. Do not bend the flex cable, and make sure it’s firmly inserted.
  3. Push the plastic clip up. Do it while holding the flex cable still, until the connector’s clip is back in place.

1.1.2 Cable connection to the Raspberry Pi

connect camera
Source: Raspberry Pi Projects
  1. Locate the camera port (CSI). It’s between the HDMI and audio port of the Raspberry Pi board.
  2. Gently pull up on the edges of the connector’s plastic clip and avoid pulling it off.
  3. Insert the ribbon cable. Make sure the metal contacts are facing the HDMI connectors. Do not bend the flex cable, and make sure it’s firmly inserted.
  4. Push the plastic clip down. Do it while holding the flex cable still, until the connector’s clip is back in place.

1.2 Connect the servo motors

Connect the 3-pin plug of the servo motors to the two sockets of the driver controller board.

  • The left socket is for the pan servo, and the right socket is for the tilt servo.
  • Note the color of the 3-pin plug. It’s brown, red and yellow from left to right.

You can refer to Picture 1.2.

ptz camera servo connection
Picture 1.2: Servo plug connection

1.3 Connect the driver controller board jumpers

The jumpers of the driver controller board can be separated into 3 pairs, and they are mainly for two purposes: I2C control signals and power supplies.

  1. The 1st pair connects to external power, with Pin#1 being Servo VCC and Pin#2 GND.
  2. The 2nd pair connects to the RPi’s GPIO pins for power, with Pin#3 being 5V and Pin#4 GND.
  3. The 3rd pair also connects to the RPI’s GPIO pins for I2C, with Pin#5 being SCL and Pin#6 SDA.

You can refer to Picture 1.3.

servo jumper connection pan tilt zoom ptz camera

Picture 1.3 : Driver controller board jumpers connection

Please note that In this illustrator, the different colors of the jumper wires are just to make it easier to distinguish them from each other. The order of those colors varies from item to item, so it may not match the one you’ve received. Therefore, instead of its color, you should rely on the position of the wire to correctly connect the jumpers.

1.4 Overview of all the hardware connections

After you finish the hardware assemble process, refer to Picture 1.4 to review the connections you’ve made.

HardwareConnection pan tilt zoon camera raspberry pi
Picture 1.4: Connection Overview

2. Driver Installation for the Camera Module

Only 3 image sensors are natively supported by the Raspberry Pi and won’t require extra drivers, and they are:

  1. V1 5MP OV5647
  2. V2 8MP IMX219
  3. HQ 12MP IMX477

Other than that, you need to install a driver for a camera to work with your Raspberry Pi. The Arducam OBISP MIPI camera is of no exception. It runs with a V4L2 (Video4Linux2) driver, and we must install the camera driver in this step.

2.1 Download and Extract the OBISP Driver Package

  • Connect to the Internet, open your terminal with Ctrl+Alt+T, type the following command, and then hit Enter.
wget https://github.com/ArduCAM/Arducam_OBISP_MIPI_Camera_Module/releases/download/v1.0/Release.tar.gz
  • Type the following command, and then hit Enter to extract the archive.
tar zxvf Release.tar.gz
  • Type the following command, and then hit Enter to enter the extracted folder.
cd Release/

2.2 Install the Driver and Reboot

  • Type the following command, and then hit Enter to install the camera driver.
./install_driver.sh
  • Press y, and then hit Enter to reboot when the terminal prompts you to.

2.3 Check and Test the Camera

After the reboot, we can check and test the camera to make sure the camera is running successfully. If your Arducam camera module cannot be detected during this step, please go over the first 2 steps again to make sure there are no hardware or driver installation errors.

2.3.1 List the video device

The OBISP MIPI camera modules are emulated as a standard video device under /dev/video* node, so you can use the ls command for listing the contents in the /dev folder.

  • Open your terminal with Ctrl+Alt+T, type the following command, and then hit Enter.
ls /dev/video0
2.3.2 List the available video modes

Since the camera module is V4L2 compliant, you can use the V4l2 controls to list the supported color space, resolutions, and frame rates.

  • Type the following command, and then hit Enter to install the camera driver.
v4l2-ctl --list-formats-ext

3. Using the Arducam PTZ Camera Example

Arducam offers example codes for pan, tilt, zoom, and auto-focus the camera module. You can also modify the example code to better suit your applications.

3.1 Prerequisites

3.1.1 Enable I2C on the Raspberry Pi

As we mentioned above, the driver controller board need I2C as the control signal. Therefore, we have to enable the I2C on the Raspberry Pi first.

We will edit the config.txt to enable the I2C on RPi.

  • In your Terminal, type the following command then hit Enter:
sudo nano /boot/config.txt

Now we will edit the config.txt file.

  • Use to navigate to the bottom of the config.txt file, and
  • Add the following line to it as the picture shows.
dtparam=i2c_arm=on

Save the change and exit.

  • Press Ctrl+o to save the changes, then hit Enter
  • Press Ctrl+x to exit.

After you exit Nano, go back to the Terminal and reboot so the changes can take effect.

  • In your Terminal, type the following command then hit Enter:
sudo reboot

3.1.2 Install python-opencv

  • In your Terminal, type the following command then hit Enter:
sudo apt-get install python-opencv

3.2 Download and run the examples

Firstly, we will download the Arducam_OBISP_MIPI_Camera_Module library.

  • In your Terminal, type the following command then hit Enter to download the library:
git clone https://github.com/ArduCAM/Arducam_OBISP_MIPI_Camera_Module.git
  • In your Terminal, type the following command then hit Enter to enter the target folder:
cd Arducam_OBISP_MIPI_Camera_Module/ptz_focus_example/
  • In your Terminal, type the following command then hit Enter to run the demo:
python FocuserExample.py 

Here are some tips for using the demo example:

  1. After you run the focuser example, you will see instructions in the terminal. Read through the instructions for how to operate with the keys.
  2. Press R to reset the lens before pressing Enter to start autofocus.

4. Use it on the NVIDIA Jetson Nano

Similar to the Raspberry Pi, we need to go through the following steps to use it on the Nano:

  1. Hardware assembly
  2. Driver Installation
  3. Download the PTZ examples to operate

Please first refer to the Jetson OBISP camera driver installation page and then to the Jetson PTZ example page.

Was this article helpful to you? Yes No