DIY intervalometer based on Arduino
..the making of Intervallino..
I would like to share with you my Intervallino project with all the steps and details it involved. When I started looking for similar projects on the web I found extremely useful to have a look at either the circuit schematics or snippets of code or even soldering videos!
For this reason I try here to be the most complete and precise that I can, so to give some hints and ideas to anyone willing to make a similar project.
That said, I assume one has some basic electronics knowledge and is not too afraid of writing a program… Indeed, this is not a manual on electronics nor an arduino programming tutorial but, as the title says, just a detailed “making of” ;)
Part 0 (prerequisite): Motivation
I have seen many beautiful time-lapse photography in the last times (e.g. The mountain or Mountain Light to name just two of the most inspiring) that I wanted to humbly approach this ‘art’ as well. (Un)fortunately my camera (a Leica V-Lux 1) has no intervalometer possibilities built-in but only a jack for an external remote. So I thought I would build one with the features I would like to have.
I thought a do-it-yourself (DIY) intervalometer would perfectly fit as my first electronic project since it would merge many things I like – photography, electronics and programming – into a compact, portable, box!
Part 1: Is it doable?
So, the first thing is to make sure the project is actually doable! This essentially means to find out what is the correct signal the camera expects from the input jack to either focus or shoot. Once found, it would be just a matter of using some electronics magic to take care of the timing.
Googling around I found that most remote shutters have a simple resistance circuit to control the focus/shoot but I did not find any specifics for my camera model. So I preferred to buy an extremely basic and cheap remote for my camera on ebay and reverse-engineer it. As a bonus, the remote came with a pluggable 3.5 audio jack which I could use putting my intervalometer in series in case I also need a manual shot overriding the intervalometer. Essentially, the schematics would be the following:
where the remote looks like this:
that said, the rest is crafting :)
Part 2: Feature wish list
This is the nice step where you just think and write down a list of additional (reasonable) features you would like to have. After disposing the most useless and impracticable, my list turned out to be as follows:
- set sec/min/hours interval for photos (!)
- optional focus before shooting
- different conditions to start (timer, light threshold)
- possibility to shoot on sharp light changes (think of lightnings..)
- be conveniently reprogammable (in case of bugs or new features)
- use either batteries or plug for indoor use
- have a simple and nice interface (LCD) with a navigating menu with possibility to switch off for battery save
- small number (4) of press buttons to navigate the menu/set the values
- be small / light enough to fit in a (jacket) pocket to be carried around
- minor cheap, fairly useless, goodies (a buzz for beeps, a thermistor for measuring the temperature..)
Part 3: What do I need for that ?
Many DIY intervalometers I have seen relies on either an Arduino or its ATmega328 chip. Arduino is very easy to use and gives a lot of options for all the features I had in mind, moreover it has a large community, development tools, it is open… and made in Italy :)
So I ordered my first Arduino UNO board, an electronic starter kit (with LEDs, resistors, transistors..) and programmed a first bare version of the software to make a simple proof of concept test:
I quickly realized a whole Arduino Uno board with a LCD shield would be far overkilling for the project, and I preferred to stick to a more minimal ATmega328 microcontroller and a 16×2 LCD.
So to use the ATmega328 microcontroller as a standalone (or bare arduino) one has to supply some basics electronics: a crystal for the timing and capacitors.
- 1 x ATmega328 microcontroller (with arduino bootloader)
- 1 x DIP socket (to avoid burning the chip upon soldering it)
- 1 x 16 MHz crystal
- 2 x 22 pF radial capacitors
I opted for a 2 lines, 16 characters per line type giving me enough room to display some human readable data (words and sentences!):
- 1 x LCD 16×2 with HD44780 chipset (to directly use the Arduino LCD library)
- 1 x 100k variable resistor (to manually regulate the contrast)
- 1 x npn BC547, TO92 transistor (to switch power off)
- 1 x 10k resistor (to reduce the transistor base current)
I wanted the device to be both independent of an external power source (in case of outdoor use) but also able to be powered and reprogrammed through a USB cable. So I chose a standard 9V battery which has to be regulated to supply the 5V for the chip together with the very convenient USB FTDI cable. This cable already contains the circuitry to convert the USB signals to TTL serial UART interface as used to communicate with the ATmega328 chip (we have to keep in mind to reserve the RX/TX ATmega328 pins for that). Summing up, the components used for these tasks are:
- 1 x TO92 5V voltage regulator
- 2 x 10uF capacitors
- 2 x 100nF capacitors
- 1 x LED
- 1 x 220 resistor
- 1 x diode
- 1 x 9V snap connector
- 1 x commutator (to switch between power sources:battery or USB)
- 1 x USB to UART cable TTL-232R-5V (ends with 6 pins, spaced 0.1″, on a single line)
The functional parts
So here are the components that actually do the Intervallino work:
- 2 x npn BC547, TO92 transistors (used as switches)
- 4 x 2.2K resistors (to output the correct current)
- 1 x plug-jack cable (to plug into the remote)
- 1 x electronic buzzer (to make some beeps)
- 1 x 10K thermistor (to measure the temperature)
- 2 x 10k resistors (for the thermistor)
- 1 x photoresistor (to measure luminosity)
Finally, to connect the components, to interface the device with the USB connector and to interact with it:
- some single line male-male pins
- some wires and female-female connectors
- 4 x push-buttons
- 1 x nice containing box (I used a spare iPod transparent case)
I should also mention that I first used a bread-board to test the circuit. I highly recommend this step that ensures the circuit is properly designed and the various components are all working.
To make the project permanent I then used a stripboard together with a resin core solder and a 30W soldering iron.
To design the circuit, design the menu, write and transmit the code and make the project fit in the case I used in order the following tools:
- EAGLE trial software
- gVim and the Arduino IDE
- cutter/bisturi (if you have a drill, it would work much better than tediously bisturi-digging to make the button holes on the plastic case!)
Where to buy – costs
I bought the tools and the electronic components at different times and in different shops (both online and in retail stores) depending on the availability and cost of the single component. Overall, I spent for the project about 50 eur (65 $) distributed over these shops: Sparkfun, Cooking Hacks, Electan and RS. Half of the cost comes from one single component that is the USB-FTDI cable (24 eur). I counted it as part of the project even if it is not necessary, strictly speaking, and it is usable for any other project (you can use a battery for power and directly plug the microcontroller on the arduino board if you need to update the code without this convenient cable). The second most expensive component is the LCD (7 eur), all the remaining are well below.
Part 4: Designing the circuit
After trying different softwares (gEDA, Fritzing), I eventually found that the trial version of the EAGLE software is what I was looking for: easy to use, largely adopted, large component library, possibility to switch from circuit schematics to PCB layout with a simple click, easy and fun to route the connections in the PCB layout, and moreover it is free! The only limitation for the free version is in the size of the circuit one can design. But in this case, this was not a problem!
As you can see, I left all the I/O (buttons, LCD, thermistor, photoresistor..) as separate pluggable devices to have more freedom during assembly (since I still did not know what would have been the final case).
Part 5: Designing and writing the code
With the hardware features set, what remains is the second half of the project: the software that runs in the electronic veins :)
After some thinking, I convinced myself that I needed a navigating menu and at least these 4 different operating modes:
- input mode: set the various options
- confirmation mode: sum up the settings and wait confirmation
- running mode: change the output resistance according to the settings (to focus/shoot) and display the progression (number of pictures taken so far, time to next picture)
- end mode: inform it is finished, display the total number of picture taken
The input mode is by far the trickiest one and the one that requires most coding, the others are fairly trivial since they require small or none user interaction being mostly informative. In fact, during input mode, Intervallino has to display the correct information depending on where we are in the menu, wait for the button inputs and respond to them accordingly.
So first thing was to think and design the menu for input mode, I did it using the open source vector graphics editor inkscape:
To each menu window I associated an identifier (called G_menu_id in the code and showed on the top left corner of each window).
As an example if G_menu_id=1, the LCD should show the first and second line of the 01 menu (Home), if G_menu_id=2 the second and third line of the same menu. G_menu_id=142 should show the third and fourth line of the Backlight menu and so on.. To allow for future rearrangements I left some room between menu indexes.
Some options are shown but actually not implemented (shot on clap and battery stat..).
Once the menu is set, what remains to be done is to learn (through examples found on the arduino website) what are the basics of programming the ATmega328. I used the ATmega328 microcontroller with the Arduino bootloader already burned so that the Arduino IDE would smoothly take care of compiling and uploading the code to the chip.
The Arduino programming language is in fact C with some restraints and some special built-in functions to deal with the hardware. Fortunately I am already familiar with C so it wasn’t too difficult to understand the logic and program it: instead of a
main() function, a
setup() function is called at each power up and a
loop() function is then repeatedly called.
Cleared these points, it was finally time to dive into the code! Opened my favorite editor (gVIM), I began to code keeping in mind that I was limited to 32KB of total memory (bootloader+code+data for the ATmega328 microcontroller).
Here you can find the entire working code with some comments (1600 lines). It is not optimized and surely many things could have been done better.. but it works and for the time being I think it is fine!
Once uploaded it using the Arduino IDE to the microcontroller, I was ready to give it a try!
Part 5: The breadboard tests
I first made a breadboard circuit to test it thoroughly together with the software. Here are a few snapshots of the process.
All the components that I used:
What I call the keyboard is a small standalone soldered circuit that I made beforehand to practice with soldering (also because the buttons did not fit into the breadboard, so I had to have them somewhere else!). It contains 4 push-buttons and 4 resistors connected as shown in this circuit schematics:
In so doing, I only need 2 analog inputs (called A2 and A3) instead of one per button. One can do it better (just one analog input for all of them) but I could afford an extra analog input so I preferred to go the easy way!
Then I finally built the circuit:
and tested it in series with the remote and the actual camera:
so far, so good!
Part 6: Making it permanent
First of all, we have to transform our circuit schematics into an actual PCB layout. Of all the steps, probably this one is the one I mostly enjoyed. It is like playing a puzzle and it is almost fun! In essence one has to fit the components following these guidelines/constraints:
- use smallest room possible (to fit the case)
- position the connection pins for power cable, photoresistor and commutator near the edges for easy access
- exploit the stripboard nature at a maximum while minimizing ad-hoc wired connections (i.e. maximize horizontal connections over vertical ones)
- respect component sizes (no clashes!)
- respect circuit schematics (obviously..)
- make it esthetically pleasant (as a plus :) )
I have to say that the EAGLE software really helps you to accomplish all these positioning/routing tasks. After many versions, here is the resulting PCB layout:
The blue horizontal connections are taken care by the stripboard, the vertical ones are wires that have to be soldered. The green crosses are breaks along the stripboard connections (obtained manually enlarging the holes, see below).
Next step is to cut the necessary stripboard by overlaying the printed layout (in actual size) to the board. I did it using a bisturi and for sure it is not the best method as I pained doing it (but I had no other tools..).
Then I marked the holes that have to be enlarged to break the horizontal connections:
This is the result:
Then turned upside down the board and enlarged them. It is very important that you test each one with a tester to check if you correctly break the connection! Do it before soldering any components otherwise it becomes complicated..
In the next step, I created all the necessary connection wires that will be soldered as vertical connections.
and soldered them:
then I inserted the resistors and soldered them as well:
finally, I inserted all the remaining components:
and soldered them:
here is the final circuit:
now I have to make the appropriate holes through the case (for buttons, plugs..) :
This was the most painful step because I did not have the proper tool (a drill):
Finally, I could insert the plug cable and solder it to the PCB:
I forgot the photoresistor hole..:
And finally, after connecting the display and closing the case, here is the final Intervallino:
Part 7: A demo
A short video of the Intervallino at work:
Demo of the shoot on flash feature:
Realizing this project took me several months of fun, working on it an average of 3-4 hours per week. I learned a lot and I am sure many things could have been done better, but overall I am satisfied and I think the time was worth spent in designing, planning and testing it since afterward everything rolled out incredibly smoothly!
That’s all folks! I hope you enjoyed and found it useful! Any comment, suggestion, clarification etc.. is encouraged and welcome ;)
PS: Here is a short list of a few, great, online resources that helped me at different stages of the project and that I highly recommend!
(video, español) Tutorial Diseño PCB con Eagle Parte 3 : Layout
(video) Perfboard prototyping
(video) How and WHY to Solder Correctly