Raspberry Pi Zero DSLR Camera control System

I have been working for a while now on a Raspberry Pi based DSLR control system. This post is about my efforts to miniaturise it so that I can easily mount it to the hot shoe of my DSLR camera.

As you can see from the above shot, I’ve 3D printed a case that is the absolute smallest that I can make it, considering that all the included items from the below shot are crammed in there.

I have the following:

  • Pi Zero W
  • 18650 Battery
  • 18650 holder
  • LiPo charge / discharge board
  • Boost board
  • ADC to measure voltage
  • Piezo speaker
  • Power switch

Assembled looks like this:


Basically the LiPo charge board gets its voltage input direct from the 18650 battery, then the charge board output goes to the boost board, boost board output to the Raspberry Pi GPIO pin 4 and 6.
The 18650 and boost board deliver a regulated 5v to the Pi Zero and can power the Pi Zero for almost 6 hours.

When the battery goes under 3.2v the charge board will stop outputting to the boost board and the Pi will be shut down.
By plugging in a micro USB to the charge board, the 18650 will be charged.
You can power the Pi and charge the battery at the same time as well.

I also have the ADC board connected to the SDA and SCL pins on the GPIO, and the analogue input comes from the battery. This allows for reading the battery voltage to display so that I know what the battery percentage is sitting at.

Usage:
This system is used to control a DSLR camera via a web browser, be it laptop, tablet or phone, connected to the Pi Zero via a wifi hotspot on the Pi.
Functions available include:

  • Logging camera and functions to db
  • Set any camera function or value from the web browser
  • Take a preview photo from the web browser and see the image on phone/tablet etc
  • Time-Lapse recording including preview of images and movie
  • Automated exposure to account for ‘holy grail’ day to night or night to day time-lapses
  • Using my other project that is a custom PCB HAT for the Pi, control 3 axis of motors for movement control.

Software
The software solution is based on Raspbian and relies heavily on the Gphoto2 library for all the camera control functions.
When a new camera is connected via USB to the Pi Zero and a User opens the browser page ‘Camera’, all the details of the camera are queried and logged to the database, including the camera type, name, manufacturer and serial number.

In the screen shot above you can see that I set the storage location to Memory Card and set a preview and runtime image quality, this is what the file type will be saved to the camera memory card.
ISO, Exposure time and Aperture can be set and used when the User hits the ‘Preview’ button.

Once the camera takes the image and transfers it to the Pi Zero, the preview is displayed.

The User can also run a quick sequence time-lapse from this Camera screen as well, setting the number of shots and interval between shots.

When a sequence is running, the ‘Main’ screen shows the progress.
Current ISO and Exposure speed are displayed as well as camera free space on the card, and the Pi, Camera battery level and the status of the time-lapse.

A preview of the last taken shot as well as the basic histogram information regarding calculated BINS.
(I’ll explain that later if anyone is interested)

The system included the ability for it to manage the exposure automatically, using some secret sauce, but there’s a method to look at the histogram data and determine if the image is too light or too dark.
If it is not correct then the system increases or decreases the exposure by 1/3 stop.
If the image is too dark, then the exposure is increased rather than the ISO.
If the Image is too light and the exposure is at the recorded max, then the ISO will be decreased.
This allows for the maintaining of lowest possible noise levels in the shot.

That got way more complicated that I intended for a hardware post, but ask me any questions if anyone is interested.

8 Likes

Thanks heaps for sharing this Andrew!

Mad respect for being able to fit so much into a tight space without a custom PCB!

Liam

2 Likes

Hi Andrew, Wow! That’s pretty amazing. I imagine it’d be possible to capture a series at different focal lengths for later focus stacking.

A few questions:

  1. what camera are you controlling? (though I can see gphoto supports my SonyA-6000 :smile:)
  2. is the web control part of gphoto2, or custom?
  3. have you got a link for the software side of things? i.e. what gets installed on the pi

I’ve got a zero 2 w I’d like to try this with. At the moment it’s set up with an auto focus camera, a waveshare screen, and a UPS, the pi is sandwitched between the 2, and a i2c RTC. I’m a bit stuck with it capturing images from the camera reliably, but if I could plug it into my Sony it’d be ideal.

Cheers,
Doug

4 Likes

Hey Doug, thanks!

Funny that you should mention focus stacking, I’ve been wanting to do that for quite a while now.
The issue is that while Gphoto2 supports focus set points and pecking, you cant use it to determine focus without using liveview, and thats out of the bouds of where I wanted to take this for many different reasons.

It is camera specific though, so I dont really have good access to focus controls on the Canon 6D that I use, but it is something that I want to investigate more in the future.

I use this setup mainly for astro photography and night-scapes, so I am using a very wide angle lens (Samyang 14mm) and it’s manual focus, so I havent needed focus control.

The system will support using the either of the three axis for anything that you want though, so the slider channel could be used for a focus motor that drives to whatever set points you want, you’d just need to add a toothed ring to the lens and the same encoder motor that Im using.
Have a look at the other project that I just posted as it compliments this one.

The current software support almost any Canon camera and almost any Nikon Camera, Ive not added any others at this time, however it should be relatively simple to add other manufacturers.
The software is designed to add additional ‘CameraTerminology’ records into the db that lets the system use the specific term that the camera reports to Gphoto2
ie

However, it would require some tweaks as I think that it is currently only looking for Canon or Nikon manufacturers. I’ll check that.

The web control part is totally custom.
There’s custom PHP pages that call custom python scripts to perform the actions, Gphoto2 is the library used for the camera interface.

I’ve ben building this system for about 8 years now with a mate, I have Canon, he has Nikon, that is why those are the two supported camera types.
Last month we released the system to someone else that has a lower end Canon and it all worked fine and he is using the system without too many hiccups, so that is a benefit that we didnt expect.
About 4 months ago I tested with someone else that has a lower end Nikon and it also worked without hiccup.

I think that we are getting very close to the point that we want to release to a wider audience, however in order to do that I will need to write up a good set of documentation and we would need to offer support for other camera manufacturers.
If you’re willing to be a guinea pig then I can see what I can do :smiley:

Heres a few pics of my setup for time-lapses.

3 Likes

Happy to test a few things out on my Sony A6000 :slightly_smiling_face:

There’s an app from sony for wifi control, but it’s a bit of a pain. I’ve been taking long exposures (30 seconds) of some bioluminescent fungi, but there’s so much ambient light I have to put the whole thing under a blanket which makes the setup a little tricky. Though the focus control is probably the most important thing. Also being able to take a shot and see how it went without having to unpack everything.

For focus stacking, you can do it on a Pi, but it’s really slow on my zero 2w, I’m thinking of switching to a Pi4 for that, but at this stage it’s just easier to copy the files to a “real” computer and do it there. I can take the photos, but often run out of ram (512Mb is a bit limiting, again a pi4 would be better) so I’m thinking of switching to C++ for the camera control.

pic of fungi (Omphalotus nidiformis - Wikipedia) all manual: ƒ/6.3, 30s, ISO8000, under blanket in the park

3 Likes

That’s uncanny. Bioluminescent fungi is right up the top of my list of targets that Ive not yet got around to. :smiley: great shot!

Yeah I use Pi4 mainly, but this is working fine on a Pi Zero 2 W, I just wish that I could get ANY as I would easily sell these setups I think.

The main issue with focus is needing liveview to preview it as you need to set a start point and end point in order to stack properly. I am looking at including this though, so I will report back :smiley:

3 Likes

Hi Andrew.
Great work. I can easily believe you’ve been at it for several years.

I’m interested in how you’ve arranged the four boards and interconnected them. Do have any pics that show more detail in that regard?

Do you aim to get users do their own 3D printing and assembly?
John.

2 Likes

Should there be any physical connection between the DSLR camera and this control system?

1 Like

Hi John, here’s an earlier version but I can walk you through it.

Top left is +ve from battery holder, top right is -ve.
These go to the +ve and -ve battery terminals of the LiPo charge/discharge control board.

From this board the output, which is whatever voltage the battery is at, goes to the input +ve and -ve of the 5v boost board. (the one in the pic above is a variable output, but Im now using a smaller dedicated 5v output, ie give it almost anything <5v and it will deliver constant 5v output at 500mA.

The output form the boost board -ve is hard wired to the GPIO pin 6 and +ve to GPIO pin 4

I dont have a pic of the ADC board wired up but it is basically connected to the battery holder output, the same as the charge/discharge board and then to GPIO pin 3 (SDA) and GPIO pin 5 (SDL).

I was planning on releasing the STL files for the 3D printed parts, then users can print them themselves, but I am toying with the idea of either making this a kit or a fully assembled product.

1 Like

Yeah I kinda left that out didnt I ? :smiley:

The camera control is all done over USB, so there is a micro to mini USB cable that plugs into the Pi then the camera.

2 Likes

Thank you. I could not understand at first.

2 Likes

Hey @AndrewBG that’s a tidy setup and packed with functionality. Gphoto2 is a winner isn’t it?!

How long do you get out of a battery though, running the Pi all the time?

We faced some similar challenges when designing our similar “intvlm8r” for time-lapse control. In a solar-only setup the Pi sleeps [shut down] except for a daily maintenance window where it powers up, transfers images camera → Pi, then Pi → internet. Firing the shots is triggered by a SparkFun DeadonRTC waking an Arduino Pro Mini for timing and triggering (via the camera’s ‘bulb’ input).

That project’s kinda stalled at the moment with the DeadOn timing chip out of stock globally, not due back in until July NEXT YEAR if we’re lucky. :sob:

Good luck with yours!

- Greig.

2 Likes

Hey Greig,
I get about 5 or 6 hours out of a single 18650 battery running this setup.
It doesnt make sense, but the Pi Zero 2 W just sips that battery.
I have made it so that you can plug it into an external battery via USB and that will both charge the 18650 and run the Pi. In this setup it will run as long as your big battery is big.

I did a 24 hour timelapse the other day with this very unit and had it plugged into my long term AGM battery (12v 100AH) and that was powering the Pi, the Canon DSLR and a dew strap that was permanently on, for 24 hours, and the battery only lost 0.5v.
It’s pretty efficient.

Running the full time-lapse rig on a Pi 4 is another story in battery capacity, with a 3S 18650 pack only lasting an hour or two, however that is what I use the AGM battery for.

intvlm8r looks really good, however I feel your pain, I wanted to roll out this Pi Zero 2 W project but cant them for love or money.

1 Like