DesignSpark Electrical Logolinkedin
  • Brought to you by
  • RS Components
  • Allied Electronics

May 13, 2013 14:22


Raspberry Pi Camera setup


The camera module comprises of a sensor and lens and needs to get instructions from the Pi in order to act as a camera. It has a 5 megapixel sensor, is capable of taking 2592*1944 images and can record 1080p H.264 video at 30 frames per second, allowing Pi users to build video applications. The board plugs into the CSI socket on the Pi, using I²C for control.

How to set up the camera to work with your Raspberry Pi

Posted 13/05/2013:  We make every effort to keep these instructions upto date,  you can also find these instructions at

Please note:  To use the camera, you will require the latest Raspberry Pi Operating System, find out how to install it.

Instructions from the Raspberry Pi Foundation

Please note that the camera can be damaged by static electricity. Before removing the camera from its grey anti-static bag, please make sure you have discharged yourself by touching an earthed object (e.g. a radiator or water tap).

The flex cable inserts into the connector situated between the Ethernet and HDMI ports with the silver connectors facing the HDMI port. Flex cable connector should be opened by pulling the tabs on the top of the connector upwards then towards the Ethernet port. Flex cable should be inserted firmly into the connector with care taken not to bend the flex at too acute of an angle. The top part of the connector should then be pushed towards the HDMI connector and down while the flex cable is held in place.

The camera may come with a small piece of translucent blue plastic film covering the lens. This is only present to protect the lens and needs to be removed by gently peeling it off.

How to enable camera support in Raspbian

Boot up the Pi and log in as user pi, password raspberry. (Note: if you have changed these from default then you will need to supply your own user/password details).

Run the following commands in a terminal to upgrade the Raspberry Pi firmware to the latest version;

sudo apt-get update


sudo apt-get update upgrade

Access the configuration settings for the Pi by running the following command;

sudo raspi-config

Navigate to "camera" and select "enable"



Select "Finish" and reboot.


How to use the Raspberry Pi camera software

raspivid is a command line application that allows you to capture video with the camera module, while the application raspistill allows you to capture images.

-o or --output specifies the output filename and -t or --timeout specifies the amount of time that the preview will be displayed in milliseconds. Note that this set to 5s by default and that raspistill will capture the final frame of the preview period.

-d or --demo runs the demo mode that will cycle through the various image effects that are available.

Example commands;

Capture an image in jpeg format;

raspistill -o image.jpg

Capture a 5s video in h264 format;

raspivid -o video.h264

Capture a 10s video

raspivid -o video.h264 -t 10000

Capture a 10s video in demo mode

raspivid -o video.h264 -t 10000 -d

To see a list of possible options for running raspivid or raspistill, you can run;

raspivid | less

raspistill | less

Use the arrow keys to scroll and type q to exit

Link to extended documentation 

Note that we recommend that you change SSH password if you are using a camera in order to prevent unwanted access.

How to stream video from the Raspberry Pi camera over a network

To view the feed on Linux;

Install the dependencies by running the following in a terminal;

sudo apt-get install mplayer nc

Find your IP address by running ifconfig. (Your IP address will be listed in the console output and will probably be of the form 192.168.1.XXX).

Run the following command in a terminal to view the feed using mplayer;

nc -l 5001 | mplayer -fps 31 -cache 1024 -

To view the feed on Windows;

Install and run Linux instead.

Find your IP address by running ipconfig. (Your IP address will be listed in the console output and will probably be of the form 192.168.1.XXX).

Download mplayer here 

Download netcat here 

Note that your browser may complain that these files are malicious as they are unsigned executables.

Press the Windows key and the ‘r’ key simultaneously to bring up the “Run” dialog. Enter cmd.exe into the dialog and press enter/return to open a DOS prompt.

Enter the following command at the prompt to view the feed using mplayer;

[Path to nc.exe]\nc.exe -L -p 5001 | [Path to mplayer.exe]\mplayer.exe -fps 31 -cache 1024 -

To view the feed on OSX;

Download mplayer here 

Alternatively you can download mplayer using brew (see: which the foundation recommends.

Find your IP address by running ifconfig. (Your IP address will be listed in the console output and will probably be of the form 192.168.1.XXX).

Run the following command in Terminal to view the feed using mplayer;

nc -l 5001 | mplayer -fps 31 -cache 1024 -

To view the feed on a Raspberry Pi;

Find your IP address by running ifconfig. (Your IP address will be listed in the console output and will probably be of the form 192.168.1.XXX).

Run the following commands in a terminal on the receiving Pi;

mkfifo buffer

nc -p 5001 -l > buffer | /opt/vc/src/hello_pi/hello_video/hello_video.bin buffer

To transmit the feed from the Pi with camera module attached;

After setting up the ‘receiving’ machine as per the instructions above, run the following commands in a terminal on the ‘transmitting’ Pi;

raspivid -t 999999 -o - | nc [insert the IP address of the client] 5001

You can then use the commands listed in the “How to use the Raspberry Pi camera software” section to change the capture time or add a video effect.

How to submit bug reports or see the source code

You can see the source code and submit bug reports for raspivid and raspicam here:

Read Andrew Backs Raspberry Pi Time Lapse Camera Blog using the the Raspberry Pi Camera

For more Raspberry Pi Resources, visit our Raspberry Pi Design Centre


DesignSpark is an engineer and maker community from RS Components, we provide free CAD software, online resources and design support. Our flagship CAD software includes DesignSpark PCB, DesignSpark Mechanical and DesignSpark Electrical. Join our community at

May 13, 2013 14:22



0 Votes

March 18, 2014 06:55

Can you tell about GPIO lines?

0 Votes
Mansoor Ahmed

December 28, 2013 06:00

i have been working in raspberry pi for past 2 months only, i am having a doubt that can i control the brightness and capture of image using GPIO lines , if possible please give me some idea regarding that.

0 Votes

May 26, 2013 11:12

Last evening I spoke to a friend who is using RPi's in a production environment to which he has cameras attached. He had them up and running before the Foundation announced their product.

The camera he uses is a: Minicam 300K 1:2.5 / TDC32

Camera size: 2.1875"x2.6875"x0.5"
Ulead Software Included: Photo Album, Editing, Printing, Sharing&Web studio. +Neckstrap+USB Cable

Dual Function Digital Camera:
Digital Still Camera function: Image Capture
PC Camera function: Video Capturing/Conferencing
AVI function: Movie clips
Sensor: CMOS Sensor
Resolution: 300K Pixels(VGA 640x480)
Memory: 64Mbit SDRAM

He said he last saw them at around USD$7 on E-Bay.


He said he used them complete with their cases and brought ribbon cables out through SD memory connector slots.

0 Votes

May 25, 2013 14:35

The RPi camera was a long time in coming and I have used cameras (carefully) removed from cell handsets to 'bridge the gap' in the delay.

In fact, using a recovered camera has advantages - it comes complete with a bezel and a nice, but oversized, case.

The more modern cell handsets conveniently have two cameras - two for the price of one, with different focal lengths.