Thursday, 23 May 2013

Installing the Raspberry Pi Camera Module - Part 2

Now it's time to connect the camera module to your Raspberry Pi. Shut down your Raspberry Pi and unplug all cables. If like me you use a case to protect your Raspberry Pi then you'll have to open up the case. The camera connector is located just next to the Ethernet network socket. The socket clamps the ribbon cable but before you insert the ribbon cable into the socket you must first "open" the clamp by gently pulling on the small tabs on either end of the socket. The tabs are indicated by the arrows in the following photo.

The next photo shows the camera connector opened and ready to receive the ribbon cable.

Now insert the end of the ribbon cable in to the socket with the metal contacts facing you and close the socket by pushing the clamp back down.

Now you can route the ribbon cable however you want to. The case I use (available from Cut Price Cables) has an opening in the side which is designed to allow access to the GPIO pins. The opening is in the form of a long narrow slot and is ideal for routing the ribbon cable through. I carefully folded the ribbon cable over on itself so that it passed out through the opening as shown in the following photo.

The next photo shows the Raspberry Pi with its case reassembled and the camera module resting on top of the case.

As a temporary measure to keep the camera module from flapping around I attached the camera module to the outside of the case using a couple of double sided sticky foam pads. I also removed the small protective plastic tab on the front of the camera lens.

Now you can boot up your Raspberry Pi as normal. Once you get to the command line prompt you can now take photos using the "raspistill" command or capture video using the "raspivid" command. To see what commmand line options are available for the "raspistill" command type "/opt/vc/bin/raspistill" at the command line prompt and press Enter:

pi@raspberrypi ~ $ /opt/vc/bin/raspistill_

You can take a photo by typing "/opt/vc/bin/raspistill -o test.jpg" at the command line prompt and pressing Enter:

pi@raspberrypi ~ $ /opt/vc/bin/raspistill -o test.jpg_

This will display a 5 second preview of that the camera sees, and then take a photo and save it to the file "test.jpg" in the /home/pi folder on your SD(HC) card. Here is a photo of the view outside my window which was taken using the camera module attached to my Rasperry Pi.

Here is another photo of the map on my office wall. The photo has been cropped using image editing software, but can you spot the slight problem?....

The photo has been mirrored, but this is how the camera took the photo! This problem can be easily corrected using any photo editing software, and there is even a "horizontal flip" command line option that can be used when taking a photo to save the image the right way around in the first place.

In this post I have only scratched the surface of what you can do with the camera module, but I hope that what I have written has been helpful at least in terms of explaining how to connect, setup and use this interesting add-on to the Raspberry Pi.

1 comment:

  1. Hello, this is really useful!

    I was contemplating cutting a slot for the camera connector above the socket (I have a Raspberry Pi Pibow Rainbow case) but your solution would be easier. I just have one concern, the instructions that came with the camera advise not to fold the cable - is it more a case of do not repeatedly flex it...?