Controlling your DSLR through Raspberry Pi

When it rains in California, most of us don’t know what to do with ourselves. After brainstorming through a few rainy days, I finally came up with the decision to use my Raspberry Pi to make the process of taking high quality group selfies easy! [Just kidding! But a lot can be done as an extension of this project — I will talk about that in my upcoming blog posts]

Project: Control DSLR with Pi

PARTS

  • A Raspberry Pi model B with Power cable and wifi stick
  • A DSLR and mini USB to connect your Raspberry Pi to the camera
  • A tripod (optional)

INSTALLATION

I used Gphoto2 libraries to achieve my goal. Gphoto2 is an actively updated command-line digital camera controller for linux OS. Before you do anything, make sure your DSLR is supported. I found this page that lists all the cameras supported by gphoto2, the software that we will use to connect our camera module to our Pi- http://www.gphoto.org/proj/libgphoto2/support.php

Step1: Always start with updating the system

sudo apt-get update

Step2: Install associated libraries and dependencies for Gphoto2 to work

sudo apt-get install libltdl-dev libusb-dev libexif-dev libpopt-dev

Step 3: Install libusb

[libusb is an open source C library that provides access to USB devices and facilitates communication/data transfer of Pi with USB hardware, in this case, your camera]

wget http://ftp.de.debian.org/debian/pool/main/libu/libusbx/libusbx_1.0.11.orig.tar.bz2

Common errors on this step: Your Pi is unable to ping http://ftp.de.debian.org. In this case check your wifi connection. You may need to update your /etc/network/interfaces file.

Once the download of the file completes, install it with the following set of commands:

tar xjvf libusbx_1.0.11.orig.tar.bz2

cd libusbx-1.0.11/

./configure

make

make install [you may need to do ‘sudo make install’ if you are not in root]

cd ..

Step 4: Install libgphoto2 2.5.2

wget http://downloads.sourceforge.net/project/gphoto/libgphoto/2.5.2/libgphoto2-2.5.2.tar.bz2

tar xjvf libgphoto2–2.5.2.tar.bz2

cd libgphoto2–2.5.2/

./configure

make

sudo make install

cd ..

Step 5: Install gphoto2 2.5.2

wget http://downloads.sourceforge.net/project/gphoto/gphoto/2.5.2/gphoto2-2.5.2.tar.bz2

tar xjvf gphoto2–2.5.2.tar.bz2

cd gphoto2–2.5.2/

./configure

make

sudo make install

cd ..

TESTING

I found this step a little time consuming. In order to test the camera —

  • First make sure you connect the camera with the Pi using mini USB cable
  • Have the Pi detect your camera by typing this command on the terminal — “gphoto2 --auto-detect”. This should detect the camera and print out a model number and port number on the terminal. If it doesn’t spit out the details on the terminal, try restarting your camera and type in the command again. That seemed to do the trick for me.
  • Image capture from command line — Type in “gphoto2 — capture-image-and-download”. This should take a picture from your camera and store it in /home folder. Now this is where things may get a bit hairy. It took me a while to figure this out, but sometimes image capture using this command doesn’t work. After researching everywhere I found on this thread that mentions the reason why. In order for your camera to be correctly mounted and connected for the Pi to take control of it, there are some files that need to be removed since they interfere with this action. You just have to literally copy and paste the following commands on the terminal —

sudo rm /usr/share/dbus-1/services/org.gtk.Private.GPhoto2VolumeMonitor.service

sudo rm /usr/share/gvfs/mounts/gphoto2.mount

sudo rm /usr/share/gvfs/remote-volume-monitors/gphoto2.monitor

sudo rm /usr/lib/gvfs/gvfs-gphoto2-volume-monitor

  • Restart the camera, re-detect and type in the capture command again.

Should work like a charm!

ps: This link was handy

This was the picture of the lovely view from the window of my living room, that the Pi took from my DSLR —

Image for post
Image for post

Stay tuned for the next phase of my project! :)

Written by

engineer, writer, observer!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store