Get Started with the Pi Camera
By Russell Barnes. Posted

In this Raspberry Pi 101, snap photos from your Raspberry Pi using its special, programmable camera
Advertisement
The desktop computer you've been waiting for: Raspberry Pi 500+
The Raspberry Pi has a few mysterious connectors on it that you wouldn’t normally use when hooking it up. We’ve covered the GPIO pins in a previous issue, but now we’re going to move onto the CSI port. You’ll find this located between the HDMI and audio jack on a normal Pi, and on the edge of a Pi Zero. CSI stands for Camera Serial Interface and, as the name suggests, it’s used to connect a camera to the Raspberry Pi. Not just any camera either: specifically, the Raspberry Pi Camera Module.
The Camera Module, so called because it looks like a piece of circuit board and is attached via a ribbon cable, is a special programmable camera for the Raspberry Pi. It can take photos and video, and has many extra functions like time-lapse photography and slow-motion recording. It’s fairly easy to control from the command line, or by using specific code in a Python script.
With the recent addition of a camera port to the Pi Zero, every Raspberry Pi can use the camera for some cool and fun projects. Here’s how to get started with it.
You’ll need
Raspberry Pi
Raspbian
Pi Camera Module
STEP-01 Attach the camera
With the Pi turned off, gently lift up the plastic catch of the CSI connector. Take the end of the ribbon and insert it into the slot, with the silver connectors facing towards the HDMI port, before pushing the catch firmly back down.
STEP-02 Enable the camera
Boot up the Raspberry Pi. Once you’re in the desktop environment, head to Menu > Preferences and select Raspberry Pi Configuration. Go to the Interfaces tab and click the option to enable the camera.
STEP-03 Taking a photo
You can take a photo from the terminal by typing raspistill -o image.jpg. This will show a preview for five seconds, then shoot an image at maximum resolution and save it as image.jpg by default.
STEP-04 Recording video
Video is a little more complex: you need to tell it how long the video is in milliseconds. For ten seconds, use raspivideo -t 10000 -o video.h264. It’ll preview what you’re shooting, and the file will be at 720p.
STEP-05 Python programming
Controlling the camera with Python is easy: all you need to do is import the picamera module at the beginning of your script. There’s some info on how it works online.
STEP-06 Pi Zero
The updated Raspberry Pi Zero adds a special connector to attach the camera. You’ll need to get an adapter cable to plug it in (magpi.cc/2gT2KwE), but otherwise it works the same.

Russell runs Raspberry Pi Press, which includes The MagPi, Hello World, HackSpace magazine, and book projects. He’s a massive sci-fi bore.
Subscribe to Raspberry Pi Official Magazine
Save up to 37% off the cover price and get a FREE Raspberry Pi Pico 2 W with a subscription to Raspberry Pi Official Magazine.
More articles

Raspberry Pi 500+ in Raspberry Pi Official Magazine issue 158
We’re quite taken with Raspberry Pi 500+. But when you don’t need all that processing power, and just want a board that will make a plastic skeleton jump around in a terrifying manner, you’ll find Raspberry Pi Pico more than up to the job. There’s more terror in the magazine (which is only right as […]
Read more →

Win one of five Raspberry Pi SSD 1TB
Raspberry Pi prides itself on high quality hardware, and this 1TB Raspberry Pi SSD is no different. You can use it with a standard Raspberry Pi or even in your desktop PC – the choice is yours. We have five to give away and you can enter below Win 1 of 5 Raspberry Pi SSD […]
Read more →

Dual-screen cyberdeck
Twin screens mean you can code on one screen while watching David Bowie’s 1978 Musikladen show on the other.
Read more →
Sign up to the newsletter
Get every issue delivered directly to your inbox and keep up to date with the latest news, offers, events, and more.