Controlling the Nikon D40 with gphoto2

Written on May 20, 2009 – 5:10 pm | by bluehash |

gphoto2 is a neat little command line interface to talk to digital cameras. The Nikon D40 DSLR is also supported. I was not able to find a good guide on interfacing the D40 to gphoto, so I wrote this down for reference.

Installing gphoto2
1. I have Fedora10 installed on my laptop. Running the following simple command “yum install gphoto2″ as root installs gphoto2.

2. Doing the above however does not install libghoto2 which is the core library designed to allow access to digital cameras by external programs.

  • Goto and download the latest version of libgphoto2. The latest at my time of downloading was 2.4.5.
  • Extract all the contents on the Desktop in a libgphoto folder.
  • Open a terminal. As root, type “make”. If you encounter any errors, it maybe because libgphoto cannot find the packages it needs. I had to install libusb. Doing “yum install libusb” did it. If you are unable to successfully compile it, post in the comments, I’ll try to help.
  • Once compilation is done, type “make install” as root.
  • Close the terminal. Done!

Running gphoto2
1. Gphoto2 is now installed and ready to use. Make sure the camera is in PTP mode. Goto SETUP MENU -> USB and select MTP/PTP mode. Restart your camera.

2. You will see the following pop up. It is very important to click “Unmount.” If you do not, further instructions will not work.

3. To make sure your D40 was correctly detected by your PC, type ” dmesg | tail ” as root. You should see your camera detected in the last two – three lines.

4. Open another terminal and as user type the following:
gphoto2 --list-ports
You should see the mode the camera is connected which is in PTP.

5. To see some more information about your camera, type the following in the same terminal:
gphoto2 --summary

6. Now for capturing, type the following:
gphoto2 --capture-image-and-download
This first saves the file “capt0000.jpg” on you camera in the “store_00010001″ folder. It then copies it to the current folder on your PC and deletes the one on the camera.

For taking shots at intervals, say 10 seconds in a custom folder, say “/home/D40/” try the following command.
gphoto2 --capture-image-and-download --folder="/home/D40" --interval 10

If this guide was helpful or if you need any help, let me know in the comments below and remember to Subscribe

Related Posts

8 Responses to “Controlling the Nikon D40 with gphoto2”

  1. FokusLopss says:

    Good article, Thanks. Thanks.

  2. vasco says:

    is there a -command that lets you control the exposure or aperture of the camera?


  3. adrian says:

    hi! i was just wondering, does gphoto2 supports nikon d40 tethered capture? do you have any list of supported nikon d40 (and up) cameras that supports tethered capture?


Welcome to my place on the web. I note down anything interesting most of them relating to my experiences, Tech, To-dos, How-tos and various hacks. Most of my time is spent in tinkering around with hardware, building robots and working with DSPs.More

Want to subscribe?

 Subscribe in a reader Or, subscribe via Email

Add to Technorati Favorites
Find entries :