Before getting stuck in to the project, we’ll take
a look at this useful tool to see what it can do.
The desktop environment can try to mount
the camera, and this can cause
Gphoto2
a few problems, so the easiest thing
to do is run without it. Open a terminal
and run
sudo raspi-conf
, and under
Boot Behaviour, select ‘No’ to not start
the windowing system, then reboot.
In the new text-only environment,
plug in your camera and run:
gphoto2 --auto-detect
This will try to find any cameras attached
to the Pi. Hopefully, it will pick up yours.
While it does support an impressive
array, there are a few cameras that
won’t work. If yours is one of the unlucky
few, you’ll need to beg, steal or borrow
one from a friend before continuing.
Not all supported cameras are equal, so
the next step is to see what the camera
can do. To list the available actions, run:
gphoto2 --auto-detect --abilities
There are, broadly speaking, two main
classes of abilities: capture, and upload/
download. The former let you take photos
with your scripts, and are present mostly
on higher-quality cameras. The latter
let you deal with photos stored on the
memory card, and are present on most
supported cameras. In this project, we’ll
deal only with the second set of abilities.
The simplest command we can
send to the camera is to get all the
photos stored on it. This is:
gphoto2 --auto-detect
--get-all-files
Running this will download all the files from
the camera into the current directory. This
would be fine on a normal computer, but
you may not want to do it on a Pi, as you
run the risk of filling up your memory card
pretty quickly. Instead, we’ll copy them on
to a USB stick. To do this in an interactive
session, you could simply use a GUI tool
to mount the stick then run
df -h
to see
where the USB stick is mounted, and
cd
to the directory. However, since this will
run automatically, we need to know where
the device will be. There are a few ways
of doing this, but we’ll keep it simple.
We’ll mount the first partition of the first
serial disk, and store the photos there.
Powering your Pi
The Raspberry Pi gets power from its
micro USB port. This supplies 5V, and the
Raspberry Pi foundation recommends
an available current of at least 600mA.
This can easily be delivered via a
mains adaptor, or a USB cable from a
computer. If you want your Raspberry
Pi to be portable, however, there are
other options. Four AA batteries, for
instance, should provide enough power,
provided you have the appropriate
housing and cables to get the power
into the micro USB port. However,
we found the best solution was to get
a backup power supply for a mobile
phone that plugs directly into the Pi.
23
Raspberry Pi User Guide.indd 23
08/07/2014 14:44