2 years ago

Get started with the new Pi camera

The new 8-megapixel camera is out so here's a refresher on how to use it with your Raspberry Pi Camera Module v2 to take some photos

Find out everything about the new camera in issue 45 

Higher pixel counts. Smaller pixel sensors. Rounded edges. You’ve seen the specs and stats for the new Camera Module, so how do you go about using it? Well, remarkably like the old camera, in fact. However, as we haven’t done a very basic ‘set up your camera’ tutorial in quite some time, we thought we’d update it for 2016 and beyond.

The full article can be found in The MagPi 45 which will be out on Thursday!

At the moment, the maximum resolution for shots taken is 5-megapixel but an update is coming very shortly that will allow you to take photos at the full resolution.

STEP-01 Connecting the camera

Make sure your Pi is switched off before connecting or disconnecting the camera. Pull out the power cable. Take hold of both ends of the plastic slider of the camera connector on the board, and pull it away from the Pi gently but firmly; it will move up a short distance, opening up the connector.

Insert the ribbon cable, with the connector side facing the HDMI port, with the blue side facing the ethernet/USB ports. Push the plastic slider back down, making sure to put pressure on both sides, so that it gently clicks into place.

STEP-02 Camera software

Plug the Raspberry Pi back in and turn it on. Once it’s booted into the desktop, click on the Program Menu and go down to Preferences. Here you’ll find the Raspberry Pi Configuration menu, which you should now click on. On the tab called Interfaces, you’ll find an option to enable the camera; if this isn’t set to Enabled, do sonow. Raspbian doesn’t have the camera enabled by default, so this is required. Now reboot your Pi.

STEP-03 First shots

Point your camera at something interesting, then open a terminal and type in the following:

You’ll see an image of whatever the camera is pointing at appearing on the screen for a moment. If it’s you, you can use the screen to arrange your best smile during the five‐second pause before the picture is taken. Once snapped, the image can be found in the home directory – /home/pi

The lens is the circle here. Obvious to some, maybe not to others - anyway, this is the bit you point towards your subject

The lens is the circle here. Obvious to some, maybe not to others – anyway, this is the bit you point towards your subject

STEP-04 Find the image

You can open the picture and view it from the File Manager, but if you don’t have a Pi 2 or Pi 3, you may want to avoid the unnecessary overhead of running that, and just enter this into the terminal:

If it looks rather blurry, check that you remembered to peel the protective plastic from the Camera Module’s lens!

STEP-05 More advanced commands

The raspistill command has a list of options so long that it borders on the intimidating. Have no fear, though – you won’t need to learn them all, but there are a few that might be useful to you, such as:

The -t option changes the delay before the picture is taken, from the default five seconds to whatever time you give it in milliseconds – in this case, a full twenty-five seconds to get your shot arranged perfectly after you press ENTER. You can find the full list of options in the documentation.

STEP-06 A quick fix

One of the problems with a camera at the end of a ribbon cable is getting it positioned properly. You may end up with the camera upside down or slightly askew. Upside-down Camera Modules can be commanded to flip the picture the right way up with –vflip , or -vf for short. –hflip handles horizontal flipping, should you need a mirror image. And if your camera is lying on its side, use –rotation , or -rot , followed by the number of degrees: 90 or 270.