-
Notifications
You must be signed in to change notification settings - Fork 33
Setting up the Raspberry Pi camera module
Connecting a camera module to the Raspberry Pi is done via a 15-way CSI2 (Camera Serial Interface) ribbon cable which connects to the CSI2 bus found just in front of the Ethernet port.
Image courtesy of The Pi Hut
You can see from the image above that the exposed pins on the ribbon cable are facing away from the Ethernet port. CSI ribbons usually have a blue strip on the opposite side to the pins - to clarify, the blue strip faces the Ethernet port. Your camera module will not work if you install the ribbon cable the wrong way round.
Note: There is another bus on the Raspberry Pi called the DSI bus - this is used to connect displays to the Pi. The ribbon cable will fit on this bus, but the camera will not work.
Now that you've got your new camera module fitted, we now need to configure the Pi to use it. This is a straightforward task, made easy using the raspi-config
tool.
First open up a terminal window and run sudo raspi-config
. This will open a terminal based application which allows you to perform administrative configuration changes to your Pi, such as enabling/disabling peripherals and SSH access.
Select the menu option "5 Interfacing Options" by using the arrow keys and pressing enter. You then need to select the "Camera" menu option. The tool will then prompt you to confirm whether you'd like to enable or disable the camera module - select enable. After doing this, use the tab
key on your keyboard and select <Finish>
. The Pi will then prompt you that it requires a restart before your changes will be applied. Restart your Pi and your camera module should be enabled for use.
To confirm that your have installed the camera module correctly, a useful test is to use the raspistill
application built into Raspbian. This is the officially supported application used to take still photos with the camera and can be found on GitHub.
To use raspistill, first open up a terminal and write the following:
raspistill -o test.jpg
If everything is installed and configured correctly, this will take a still image with the camera, and save a new JPEG to the current working directory of the terminal (usually "/home/pi" on a fresh Raspian install and new terminal instance).
If you received an error during the raspistill test, then below are a number of troubleshooting steps you can try:
- Is the ribbon cable inserted fully and security seated in the CSI connector?
- Make sure the ribbon cable is the right way round. The blue strip commonly found on the ribbon cables should be facing the Ethernet port.
- Is the ribbon cable connected to the CSI connector and not the DSI connector? The ribbon cable will install correctly in both, so it's important you use the right one.
- Check the cable on the camera module itself, which connects the sensor to the PCB. Has this come unconnected? On the v1 module this is labelled "SUNNY", however is blank on the v2 module.
- Try running
sudo apt-get update
andsudo apt-get upgrade
to make sure your firmware is on the latest version. - Have you enabled the camera using the
raspi-config
tool? - Ensure your power supply is powerful enough. The camera module adds around 200-250mA to the power requirements of your Pi.
Sometimes raspistill will provide some specific error codes that will help in the diagnosis of issues:
Error : raspistill command not found This means the application could not be found on your Raspbian OS install. Try running the update/upgrade procedure again.
Error : ENOMEM The memory split needs increasing to give the GPU more memory resources. This is done in the raspi-config
application under the "Advanced" menu option. Increase the memory split to a higher value such as 192. Also ensure you have performed an update/upgrade to update the firmware.
Error : ENOSPC Again, this could be due to the memory split or firmware version. Try performing the steps above.
If you still cannot get your camera module to be recognised by the Raspberry Pi, it is possible you have a defective unit and may need to be replaced. The camera modules are sensitive to ESD, so it's important your correctly earth yourself before handling them.