Lightning Shutter Trigger for a Camera

Update: Check out my latest Camera Axe project for a much more robust device that handles this.

From Public DomainI knew there were devices that could trigger a camera to fire during a lightning strike, but their circuits were more complicated than I wanted to make. I’m a software guy not a hardware guy so I decided to use an Arduino and that allowed me to write a little code that made the circuit much simpler.

Before I got started I looked at this wikipedia article about lightning so that I could verify this project would work. It has a lot of interesting information about lightning, but the most useful piece of data in the wikipedia article is the time lapse shot of a lightning strike. From the time lapse photo I was able to determine the duration of a lightning strike is about 100 ms. Then from this page I found my Canon 30d camera has a shutter lag of 65 ms. I know from a past project that if I use a reverse biased photo transistor to detect light it has a response time under 1 ms. The last piece of delay is the software running on the Arduino board and since it’s running at 16 MHz I am sure I can run a tight loop that takes under 1 ms. Adding up all the delays, I get 67 ms which is still much less than the 100 ms duration of a lightning strike so I was pretty confident this would work before I started work on the prototype.

The circuit I used to detect the light from the lightning was a very simple circuit that looked like the above circuit diagram. I used a cheap infrared photo transistor because that’s what Radio Shack had. I noticed that the sun, my house lights, and lightning all pump out plenty of infrared light for this circuit to detect. If this circuit is not sensitive enough try changing the value of the resistor. Larger resistance values should help sensitivity when there is only a little infrared light and smaller resistance values should help sensitivity when there is a lot of infrared light.

I also needed a circuit to trigger the camera. I already have written a short tutorial about how to do that here.

The last thing I needed to do was write some software. At first I thought I’d just have a threshold value that triggered the camera. That would work, but I’d need to calibrate the threshold value to different values depending on the environment. Instead I have the software look for a rapid change in the amount of infrared light detected. This works great because lightning causes a very rapid change.

Here is the code.

// Maurice Ribble
// 6-1-2008
// http://www.glacialwanderer.com/hobbyrobotics

// This code uses my camera trigger and lightning detector.
// It waits for a sudden change in the light intensity
// and then triggers the camera.

#define SHUTTER_PIN 7
#define LIGHTNING_TRIGGER_ANALOG_PIN 0
#define TRIGGER_THRESHHOLD 5

int lightningVal;

void setup()
{
  pinMode(SHUTTER_PIN, OUTPUT);
  digitalWrite(SHUTTER_PIN, LOW);
  Serial.begin(9600); // open serial

  lightningVal = analogRead(LIGHTNING_TRIGGER_ANALOG_PIN);
}

void loop()
{
  int cmd;
  int newLightningVal = analogRead(LIGHTNING_TRIGGER_ANALOG_PIN);
  Serial.println(lightningVal, DEC);

  if (abs(newLightningVal - lightningVal) > TRIGGER_THRESHHOLD)
  {
    digitalWrite(SHUTTER_PIN, HIGH);
    delay(1000); // May want to adjust this depending on shot type
    digitalWrite(SHUTTER_PIN, LOW);
    Serial.println("Shutter triggered");
  }

  lightningVal = newLightningVal;
}

Here are a few example pictures from Adam Bell. He used this blog to make a lightning shutter trigger. Traditionally lightning is captured at night. This lightning shutter trigger could do that (while you sleep), but where this device creates new opportunities is photographing lightning during the day. Peoples’ reflexes just are fast enough to get pictures like these. Thanks for the examples Adam!

Here’s a link to John’s Flicker page where he’s used this method to take some really nice lightning photos.

94 Comments

  1. Travis said,

    January 7, 2009 @ 9:42 am

    So how did your arduino lightning detector work out? Do you have any examples?

    Thanks!

  2. Glacial Wanderer said,

    January 12, 2009 @ 10:57 am

    It’s worked well with all my test cases (used a camera flash to simulate lightning), unfortunately I don’t get much lightning so I don’t have an example yet. I do know of someone else who built the trigger and used it. I’ll check with him to see if he is willing to share a few pictures he took with this lightning shutter trigger.

  3. cheekygeek said,

    January 27, 2009 @ 12:41 pm

    Curious as to whether this will only work at night, or if it is sensitive enough to capture lightning in daylight?

  4. Glacial Wanderer said,

    January 28, 2009 @ 8:11 am

    I think so, but I have not tested it. You might want to add a pot to help adjust sensitivity. It is also helpful if you put the photo transistor on the viewfinder where your eye goes as that lets it focus on only the light the camera is seeing.

  5. Scott Rutledge said,

    February 25, 2009 @ 8:09 pm

    I used your code last fall and am happy to report it worked great. Now i am waiting on spring to find a good location to shoot from.

  6. Scott Rutledge said,

    February 25, 2009 @ 8:10 pm

    Yes it worked in daylight wonderfully.

  7. Marco said,

    April 3, 2009 @ 3:38 am

    Hello, I realized all the circuit, however i used Arduino 2009 instead of Arduino 10000, which is not availbale any more. Using the program listed, anyway, the circuit fires the camera continously, even if the ohoto transistor covered. What do you think about it? Thank you very much for help

  8. Maurice Ribble said,

    April 3, 2009 @ 5:12 am

    I don’t know what you mean by Adruino 2009 and Adruino 10000, but that probably does not matter. I don’t think Adruino version is the problem. Try using printf to display what is happening to newLightningVal. It might be that your circuit is working, but there is more noise with your phototransistor. If this is the case you can just increase the value of TRIGGER_THRESHHOLD. If the circuit isn’t working you’ll need to debug what is happening there.

  9. Roberto said,

    May 27, 2009 @ 5:30 am

    Very nice post. which is the exposure settings of your camera for these shots? (Lens, shutter, aperture)? Do you keep “pressed” the focus to get faster response? in this case, is it ok to keep the focus “pressed” for a very long time? isn’t there some risk of frying something? (playing this way with a 30D seems a bit frightening for me…)

  10. Maurice Ribble said,

    May 27, 2009 @ 5:41 am

    I didn’t take the picture above so I can’t give all the info you want, but I can help with your question. When you press the shutter half way down you are pre-focusing the camera. For these sorts of photos you want to manually set the focus and disable autofocus. Then the camera won’t spend any time focusing. This project also uses a trigger release which lets you bypass auto-focus even if it’s on, but you should still use the manual focus trick or your images might not be in focus.

  11. Orce Popovski said,

    July 2, 2009 @ 7:11 am

    Hello

    I create lighting trigger with your code and arduino, but from 20 to 25 lighting I manage to capture
    only one. Trigger reacts on light emitted by the lighting but it’s probably to slow to catch on the camera.
    I have canon eos 40d (Shutter Lag Prefocused 0.061 second) and 16-35 f2,8 lens on.
    I put light transistor on the top of the lens and pointed on the front of the camera
    Maybe it will work much better if there is faster microcontroller because you have optimized the code
    Today I will try to take pictures with mirror lockup and photo transistor on the viewfinder, I hope I will have more luck. If you wont I can send you my photo of lighting.
    Best regards
    Orce

  12. Maurice Ribble said,

    July 3, 2009 @ 4:50 am

    Dave found that his trigger is getting activated twice. By changing this line:

    if (abs(newLightningVal – lightningVal) > TRIGGER_THRESHHOLD)

    to this:

    if ((newLightningVal – lightningVal) > TRIGGER_THRESHHOLD)

    The trigger should only happen once (when it goes from dark to light). Thanks Dave!

  13. Maurice Ribble said,

    July 3, 2009 @ 5:00 am

    Orce, I think the trigger is actually fast enough since it is working for myself and others. I don’t know what you mean by faster microcontroller, but unless it’s really slow it should be fast enough. On the Arduino the slowest part of this code by far is the analog read and that only takes 0.1 ms which is 400 times less delay than my camera adds.

    Thanks you could try are:
    1) Making sure you have the lens set to manual focus
    2) Disable all power off features on your camera to see that it isn’t going to sleep
    3) Activate the focus pin on your camera trigger. This should be equivalent to #2 since it will prevent your camera from going to sleep, but if #2 didn’t work try this

  14. Kevin Fogarty said,

    July 15, 2009 @ 9:15 am

    Hi, I am 16 years old and part of the high school robotics team. Photography is one of my hobbies and I was wondering how hard it is to build this. If needed I think there are a couple of mentors on the team that could help me but I am really looking to do this myself as a project over the summer. I really don’t have any experience programming but I was hoping I could copy the code you wrote and use it for the arduino. I would also like to know where to get this stuff, I have a radioshack down the street so I think the photo transistor, arduino, and microcontroller could be purchased there along with a program to write the actual code.
    Any help is appreciated, I just figured give this a shot before spending $300+ on a store bought one.
    Thanks, Kevin

  15. John Groseclose said,

    July 21, 2009 @ 3:38 pm

    I bypassed the “activate the focus pin” by using a D80 pre-trigger cable from FlashZebra designed to work with a Pocket Wizard, and putting a female mini-jack (Radio Shack #274-0248) on the box containing my Arduino controller. The cable shorts the focus control pins on the D80, so there’s no need to mess about with the circuit.

    It is important, though, to make sure you get the tip/ring polarity correct, or it won’t work.

    I also mounted the IR phototransistor (Radio Shack #276-0142 – they were sold out of the individual phototransistors) in a panel-mount LED holder (Radio Shack #276-080) to help “snoot” the sensor a bit.)

  16. Lee said,

    July 30, 2009 @ 11:01 pm

    Kevin,

    I didn’t see anyone write you back…
    I put this together in an afternoon… I don’t know any programing languages, but have been tinkering with arduino for about 1 months.
    I had a spare photo resister (taken out of a night-light). A couple radioshack NPN transistors, a spare resistor (I have an electronics part box).
    I bought a RBBB (Really Bare Bones Board) a couple of weeks ago and have been experimenting with it.
    So what you need…
    1. Arduino Board (check out some of the Freeduino boards as they can be cheaper especially if you want to assemble them yourself)
    2. (2) NPN transistors see the above schematic for specifics although others will work as well. (radio shack)
    3. A resistor (100k ohm) is in the example; other values may work as well. (radio shack)
    4. A camera remote. I have an olympus E-3 so I used the optika remote for <$10 from amazon.
    (look up "opteka remote shutter release cord" most are less than $20, nikon and olympus for <$10)
    I recommend that you test your remote before wiring it. Mine had red-shutter, white-ground, and yellow-focus. I used a multimeter to test DC voltage between the leads, mili amps at trigger, and discovered that my camera needed both focus and shutter pins HIGH to take a picture.
    5. Some type of prototyping board (breadboard) $2-10.
    6. Wire.

    take a look at the photo and diagrams, it really is easy and arduino is a fun micro-controller.

  17. Pascal said,

    July 31, 2009 @ 1:03 pm

    I’m currently building this project and it’s just great ! A note for those of you building it. You might have to adjust the trigger threshold as i did. Because i found out that in my basement with all the normal light open the project was triggered almost always. Now i have to test it outside. Light must be more intense or the light in my basement are emitting more infra red than normal. ( fluocompact and fluorescent ). Note that i’m using a Arduino 2009. Everything seems to work great. A tip if you want to simulate a lighting strike you can use a camera flash. My SB-600 juste does the job great.

  18. cherokee said,

    August 10, 2009 @ 12:43 pm

    Do you know where I can buy the Ardino 2009 and other components necessary to make a lightning trigger?

  19. Pascal said,

    August 11, 2009 @ 6:21 am

    Arduino simple : http://arduino.cc/en/Main/Buy

    look at this link it will tell you where to buy it in your country. Otherwise for the parts… it depend where you live. If you live in the continental Canada / US you can buy the parts at The Source. There is also Active Component which sell them.

  20. helion said,

    August 17, 2009 @ 2:15 am

    This is just what I am looking for. How much do you charge for one of these gizmos?
    My photo equipment dealer charges over $300. I thing it’s a major ripoff.
    A photo sensitive switch can’t cost more then $30 to $50.
    I have seen a lot of cirquit diagrams for DIY, but I am no good at assembling tiny
    components and soldering them. Used to experiment when I was a teen, but kept
    burning up stuff or it simply did not work.
    I have a Canon Rebel XTi D-SLR.
    Thanks.

  21. John Groseclose said,

    August 22, 2009 @ 7:40 pm

    After last night’s fun, I’ve gone ahead and collated my best shots with the Arduino-based trigger here:

    http://www.flickr.com/photos/iaincaradoc/sets/72157621660951255/

  22. Eric said,

    August 26, 2009 @ 11:59 am

    I too am interested in this if you are selling a basic kit….soldering is not a talent of mine…

    thanks

  23. Photography - BANNED » Archive » Daylight Lightning Photography said,

    August 26, 2009 @ 5:05 pm

    […] the past month or so, I’ve been playing with a lightning trigger that I build based on this DIY page’s instructions, slightly modified to take into account the fact that I shoot with a Nikon D80 and the original […]

  24. Sam said,

    August 31, 2009 @ 9:41 am

    Hi,

    I’m building this circuit but am a little confused.

    Does this circuit run on battery power or does it use the camera’s power?

    Thanks!

  25. Maurice Ribble said,

    August 31, 2009 @ 10:13 am

    The circuit and arduino run off a battery.

  26. Sam said,

    August 31, 2009 @ 3:10 pm

    Ok so I can use a 9v battery to run the whole thing correct?

  27. Maurice Ribble said,

    August 31, 2009 @ 4:09 pm

    Correct.

  28. John Groseclose said,

    August 31, 2009 @ 8:53 pm

    I recommend keeping spare 9v batteries in the camera bag. Nothing sucks like finding a perfect spot with wonderful strikes going on, good foreground, and finding out that the battery in the trigger box is dead…

  29. Sam said,

    September 4, 2009 @ 9:06 am

    Hey guys..got my trigger build and it works but I’ve got a couple issues.

    With room lights on the camera is triggered constantly. If I shield the IR transistor with my hand it will stop however. If the lights are off in the room and I turn them on the unit triggers the camera but it will keep triggering if the lights are left on.

    With room lights off, my 580ex will trigger the camera however only if the flash is very close to the photo transistor. If I dial in 1/4 power on the flash and hold the flash 10ft from the IR transistor the unit doesn’t trigger.

    I’m not using the radio shack IR transistor so perhaps it’s the photo transistor. I’ve ordered a few different phototransistors and should have them next week to play around with. I’m also going to try the code mods that are mentioned above as well as adjusting the trigger threshold.

    Anyone have a similar problem with their build or have any suggestions?

  30. Maurice Ribble said,

    September 6, 2009 @ 9:33 pm

    Sam, I’m almost certain you have figured this out yourself. It sounds like you just have to go and adjust the threshold in the code (as you suggested).

  31. Sam said,

    September 8, 2009 @ 9:02 am

    Thanks Maurice!

    I did a little tinkering with it last night and found that a photo resister works much better than the phototransistor I was using…no false triggers and much more sensitive without any code modifications required.

    Hoping for some september T-storms!

  32. Thuy Nguyen said,

    December 10, 2009 @ 11:05 pm

    You got a good idea here, although your implementation is too complex. I found a much simpler way:

    http://thuytnguyen.spaces.live.com/blog/cns!DA7A6E9DDF81F274!274.entry

    and:

    http://thuytnguyen.spaces.live.com/blog/cns!DA7A6E9DDF81F274!279.entry

    I have to wait for a stormy day to try out my board, but I can use it for many other kind of pictures too.

  33. Thuy Nguyen said,

    December 13, 2009 @ 5:08 pm

    I posted a blog on another use of the shutter release board:

    http://thuytnguyen.spaces.live.com/blog/cns!DA7A6E9DDF81F274!288.entry

  34. Thuy Nguyen said,

    December 17, 2009 @ 3:54 pm

    For a complete implementation with application to other situations, see:

    http://thuytnguyen.spaces.live.com/blog/cns/fakehandlerpage.aspx?sa=692503166

  35. John Groseclose said,

    December 28, 2009 @ 9:57 pm

    I tried using a simple trigger like the one you describe, Thuy, but it wouldn’t do what I needed it to do.

    Many times, the initial strike would trigger it, but just one frame would fire. By having the Arduino controller hold that pin high for a longer period and trigger multiple frames, shots like this become possible:

    http://www.flickr.com/photos/iaincaradoc/3846107512/in/set-72157607043209736/

  36. Thuy Nguyen said,

    December 29, 2009 @ 1:07 am

    My apologies for those who are specifically interested in this topic: somehow my previous link leads to the wrong page. The correct one is:

    http://thuytnguyen.spaces.live.com/blog/cns!DA7A6E9DDF81F274!310.entry

  37. Thuy Nguyen said,

    December 29, 2009 @ 1:51 am

    Answer to:
    John Groseclose said,

    December 28, 2009 @ 9:57 pm

    Yes, the simple solution works as soon as enough light is detected. In my series of about 5 blogs, I describe the full implementation which involves also a microcontroller. There are 3 pieces:

    1/ The simple sensor that can be mounted directly on the camera. It triggers as soon as enough light is detected as taking pictures of lightning.

    2/ The microcontroller that you can program to do many things. I made pictures of drops of water. (see pictures on http://thuytnguyen.spaces.live.com/blog/cns!DA7A6E9DDF81F274!310.entry and http://thuytnguyen.spaces.live.com/blog/cns!DA7A6E9DDF81F274!321.entry : copy and paste the full link!)

    3/ The triggering circuit commanded by the microcontroller.

    Well the full implementation is more flexible, the light sensor can be replaced by other sensors such as a microphone, thermometer etc. Of course the microcontroller will have to be reprogrammed. There is no such thing as a free lunch, the full course requires more work!

  38. Thuy Nguyen said,

    December 29, 2009 @ 3:52 am

    Thanks to John Groseclose comment, I browsed through the store given by the link on the right hand side at the top. The store carries interesting items, a tad expensive, but if you don’t have an EE background, it is safer just to get your stuff from the store since you don’t have to figure out how and why things work.

    For my part, I have already a few components I bought a few years back for other purposes, I just use them. In fact I did not think of connecting a digital camera to the electronic until I noticed this site indicated on Flicker. After reading this blog, it dawned on me that it isn’t that difficult to connect my camera to the electronic! After a few days, I thought about the various other possibilities than taking pictures of lightning. I just found out by browsing through the store that some of the possibilities I thought about were already described in the pages linked to items carried by the store. I am glad that there is still a minority interested in doing things!

    Thanks also to Maurice Ribble who wrote this blog. It prompted me to find out how to connect the electronic to my camera.

  39. John Groseclose said,

    December 29, 2009 @ 8:46 am

    Thuy,

    Please show us a photograph of lightning that you’ve taken using your “simple circuit.”

    I don’t believe the timing will work quite the way you seem to think it will.

  40. Thuy Nguyen said,

    December 29, 2009 @ 11:39 am

    As I mentioned before, I have to wait for a stormy day to try it out. I did not say it explicitly but in one of the blogs I posted, I showed how I used a diffuser to cut down the amount of light i.e. if you want a picture of daylight lightning, you have to filter out some visible light by putting a piece of paper or some tinted piece of something.

    Now about your mention of timing, I did measurements with an oscilloscope which show that as long as the light level is above the firing threshold of the camera, the shutter is held open. This is quite suitable for taking pictures of lightning. In other kind of pictures, the simple circuit would not work correctly because when the shutter is held open for too long, the CCD of the camera saturates and the camera would lock-up. Tell me what kind of pictures you want to take so that I understand why you have problems and why you want to hold your shutter open for longer than the time the detector gets above the firing threshold.

    I posted on your other pages pictures of single drop of liquid I took with the circuits I built. In those situations, proper timing is necessary and in the blog for the full solution, I showed how to program the microcontroller for the task.

  41. Thuy Nguyen said,

    December 29, 2009 @ 11:46 am

    Answer to:
    John Groseclose.

    I forgot to put the link to your other page where I put two pictures:

    http://www.flickr.com/photos/iaincaradoc/3846107512/

    I took over a thousand of such pictures to make sure of the consistency of the results.

  42. Thuy Nguyen said,

    December 29, 2009 @ 12:17 pm

    I should repeat that I use a PENTAX camera (not a CANON as you all seem to have) and in the circuit, I chose a high resistor value to limit the current and avoiding messing up the camera in case of accident.

    In the full solution for general pictures taking, I took a further precaution by electrically isolating the control from the camera through the use of optical coupling the controller to the camera.

    In the blog http://thuytnguyen.spaces.live.com/blog/cns!DA7A6E9DDF81F274!339.entry I described another use of camera in a non-imaging case.

    I though that this is about robotics and photography so I posted my comments. I do not sell anything. I even advise people to buy stuff from you guys if they don’t have the appropriate engineering background to venture on their own!

  43. Thuy Nguyen said,

    December 29, 2009 @ 1:36 pm

    Now a big idea: there are a whole bunch of signals processors in cameras, it should not be too hard for manufacturers to add some software to read files from SD cards, this way you can load your code onto the camera and make it do what you want. All you need is to connect to the camera a sensor and bypass all the external processors.

    The challenge would be to hack such a piece of code!

  44. Maurice Ribble said,

    December 29, 2009 @ 2:05 pm

    Take a look at CHDK. It allows people to load custom software onto many canon point and shoot cameras. http://chdk.wikia.com/wiki/CHDK_in_Brief

    The point about plugging in sensors is a bit tricky and it would be best if camera makers would support both custom software and sensor ports, but I don’t really think that will happen since the market isn’t large enough to interest big companies like Canon. Hope I’m wrong 🙂

  45. Thuy Nguyen said,

    December 29, 2009 @ 2:14 pm

    Thanks Maurice for the link. I have to confess that in my function as baby sitter, I don’t go out much in the wide world so I just dream of stuff when babies let me some free time for it!

  46. Thuy Nguyen said,

    December 29, 2009 @ 2:37 pm

    Oh, I just skimmed through the link. Actually there is usually a USB port. I don’t use it since the kids always play with my stuff and I can’t never find the cord. That USB port may be used to plug in sensors. The remaining is a problem of knowing how to squeeze in the custom software!

    In the pre-micro era, we used to joke about software and said that the day will come when you buy a piece of code and get the hardware as bonus. It seems to be the case today. Maybe that manufacturers do not care about letting people fooling around with their products or even worse, they did not think of the possibility!

  47. John said,

    December 30, 2009 @ 3:42 pm

    Where can I get a Lightning trigger for my Canon Rebel XTi 40d 10.1 mega pixil? How much do they cost.

  48. Anonymous said,

    February 23, 2010 @ 5:00 am

    Take a look at this:

    http://shop.ebay.com/patch_master/m.html?_nkw=&_armrs=1&_from=&_ipg=&_trksid=p3686

  49. ThierryD said,

    June 17, 2010 @ 3:42 pm

    Hello
    I can speak on this post because I made a lightning detector for SLR photography.
    This small electronic assembly costs less than 10 dollars and is very easy to achieve.
    All details of installation, drawing, explanations and examples of photos are available on my website:
    rienquepourlesyeux.free.fr

  50. Dan said,

    July 8, 2010 @ 9:41 am

    Try the following for a less expensive commercial trigger:

    http://www.pmgadgets.com

RSS feed for comments on this post