Have you ever wanted to take crisp photos of lightning during a storm without having to rely on chance or leaving the camera on a really long exposure. You have just under 200 milliseconds to see the lightning, push the camera’s shutter release and allow the camera time to take the photo which is next to impossible to get right once, never mind for a range of photos. You need an automatic camera trigger to get the shot.

The Arduino lightning trigger is the answer, it will detect the lightning strike and trigger your camera for your to ensure that you get the right timing and a clear photograph. All you need is an SLR camera which is able to be remotely triggered, an Arduino controller and a couple of cheap components.

You can also use this device to trigger your camera from far away using a laser pointer.

This project assumes you know the basics of Arduino programming, otherwise read our article on getting started with Arduino.

What You Will Need For An Arduino Lightning Camera Trigger

How To Build A Lightning Camera Trigger

The LDR is the sensor in this project, the light from the lightning changes the resistance of the LDR which the Arduino detects as a change in voltage and the Arduino then triggers the camera through the optocoupler. The optocoupler is not entirely necessary and you can get around using one by assigning the pins on the Arduino differently however, for the few cents it costs, it offers isolation and protection for the camera which can cost a few hundred or thousand to repair if the Arduino puts the wrong signal or voltage onto the cameras trigger terminals and damages the cameras circuitry.

Assemble The Components

First you need to assemble your components, if you are making a temporary trigger then a breadboard is perfect. Assemble the components as shown in the circuit diagram below.

Lightning Camera Trigger

Note that the LED and battery in the below breadboard model are merely used in this example to illustrate that the optocoupler has been triggered, in reality these shouldn’t be connected as you don’t want a voltage to be applied to the camera trigger.

Arduino lightning camera trigger

Connect your camera trigger cable’s ground to the purple wire going to the black header and the cable’s shutter release to the orange wire on the header.

Note that the optocoupler is only used to trigger the shutter release pin on your camera, your camera’s trigger cable may have three wires, the third is to remotely trigger the focus. Triggering the focus has been omitted in this project as it generally takes too long for the camera to focus and trigger in the time that the lightning is visible. The camera should therefore be used in manual focus mode. If your camera insists on the focus pin being used to release the shutter then connect it to the ground pin and this keeps the camera focus locked.

Some people have reported that the 4N35 is not able to trigger their SLR due to its high internal resistance. I have therefore added a lower resistance option to the parts list, the PC817. You can also use a EL 817-c.

Upload the Sketch

Now you can upload your sketch onto your Arduino, if you haven’t uploaded a sketch before then follow this guide on getting started.

Here is the link to download the Lightning code.

The code first assigns the shutter release to pin 2 and sets the output to Low or Off.

Next the Arduino takes constant readings from the LDR until the reading exceeds the set point in Row 18 (100 in this case). The controller then activates the optocoupler which triggers the camera.

Calibrate the Set Point & Timing

There are two settings which need to be adjusted to suit your light conditions and  your camera’s timing.

The first is the trigger sensitivity, the number in line 18 which is tested by the if statement. In this case, it is set to trigger on any value over 100 which is suitable for quite dark surroundings and will trigger with a small amount of light. If the sensitivity is too high, the camera will be set off all the time, adjust this parameter upwards with a higher number. If the sensitivity is too low and the camera is missing lightning strikes then adjust this parameter downwards with a lower number. This parameter will probably have to be changed every time you use the trigger as it is dependent on the current conditions.

The second parameter to adjust is the timing in line 20. This depends on two things, one is how bright and developed you want the lightning to appear in the photograph and the second is how fast your camera responds to the trigger command. More modern cameras react faster and therefore longer delays are needed to allow the lightning to fully develop before triggering the camera. Adjust the delay to be shorter if the camera is missing the lightning and longer if the camera is taking the photo before the lightning is fully developed.

Potentiometer Set-Point Modification

I’ve included this modification as an adaptation to the original circuit as a number of people have asked me how they can make the trigger set-point adjustable in the field instead of having to take their computer along with them.

This can easily be done by adding a 10K potentiometer circuit onto one of your Arduino’s analogue inputs and changing a few lines in the code.

Add a 10K potentiometer onto your Arduino analogue input A1 as shown in the diagram below:

Arduino Lightning Trigger Pot Adaptation

Now you’ll need to modify your Arduino code to accept the potentiometer input as your new trigger set-point.

To do this you’ll need to add two new variables, one for the triggerPointPin and one for the actual set-point measured from the pot – triggerPoint. Then you’ll need to read in the potentiometer value in the setup loop and save the value to the triggerPoint variable. Lastly you’ll change the set-point comparison line to be compared to the triggerPoint variable instead of the preset value.

Here is the link to download the Modified Lightning code.

I’ve added the potentiometer reading to occur in the setup loop of the code so that you’re not wasting processing time in the main section of the code to keep your Arduino’s reaction time as fast as possible. This does have one disadvantage in that you’ll need to reset your Arduino each time you make adjustments to the pot in order to “take” the new setting. This will take a second or so, so it shouldn’t be much of an issue. If you have a fast camera then you may be able to include it in the main section of the code as well without compromising the performance of the circuit.

Would you like to learn more about this project? Are you interested in projects similar to this one? Then Practical Arduino Projects is the book for you, available now on Amazon as an eBook or in Print form.

Practical Arduino Projects

Have you tried any other methods for taking photos of lightning? Let us know in the comments section below.

lightning in clouds, arduino lightning trigger

Lightning by One Day Closer
Cover Image: Lightning by Ricardo Faria. All images in this post are used under CC BY 2.0.

27 Replies to “Arduino Lightning Camera Trigger”

  1. Can you setup a POT to replace the sensitivity value? So there is no need to edit the code while out taking pictures (i.e. leaving the laptop at home)…

    1. Hi David,

      Yes you can do that, I would suggest that you put the pot into the setup function of the code though so that you don’t slow down the trigger response time. This would then require you to reset the Arduino each time you make a change to the pot but this takes less than a second with this amount of code.

  2. Why are you using an optocoupler as opposed to a transistor? I’m not saying that you SHOULD use a transistor, I’m just wondering why you chose that. I’m self-taught with electronics and things like this interest me. Thanks!

    1. Hi Mark,

      An optocoupler provides galvanic isolation from the Arduino circuit. It’s just another layer of protection for your camera. If anything goes wrong on the Arduino or with your IO you still won’t put a voltage onto your cameras trigger which may permanently damage it. You could use a transistor and you could just drive it directly from the Arduino’s IO.

  3. Can you please show us a layout of when a pot is used in the circutry and the codes associated with it? Thanks a lot.

    1. Hi Farzad,
      I have added in a section at the end which explains how to add the potentiometer and associated code for an adjustable set-point.

  4. It will not work with a Cannon camera the optocoulpler has too much resistance. It is still an open circuit as far as the camera is concerned.

    1. Hi Jim,
      I first built this circuit for a motorised dolly time-lapse rig which I used with a Cannon 77D, Cannon 80D and a Cannon 5D and it worked perfectly with all of them. I have also used this lightning trigger with the Sony Alpha A100. I haven’t tested it on a Nikon but since the triggers are generally compatible (with adapters), I can’t see it being a problem.

  5. I have tested it with a led and ohm meter it works but due to the resistance of the Optocoupler the shutter will not trip . I am going to try a different optocoupler I have found one that has less resistance. It does not matter how the light is set it will not work with my camera. The camera shutter will trip if I short the legs on the optocoupler, like I have said it is a resistance problem with that part number optocoupler there are others that have less resistance.

  6. I finally have the trigger working. The 4N35 just had too much resistance to trigger my camera so I swapped it for a EL 817-c and it works great.

    1. Great to hear you’ve got yours working. I have added a note to the end of the hardware section and another option to the parts list for lower internal resistance optocouplers. Thanks for your contribution.

    1. Hi Tom,
      Yes you could set it up to send an IR trigger however this is typically much slower on the Arduino and camera and a lot of the newer SLRs do not have IR anymore. With an optocoupler there really isn’t any risk to your camera.

      1. Thanks, I just got all the parts, will build it since it’s Monsoon Season in Arizona now and lightning will be all around for a while.

  7. This works great as long as I use the arduino but would like to
    move it to a standalone with atmega328p on Bread Board.
    I cant get it to work for some reason. would you please help with pinout
    on atmega. Thanks for a great project.
    Bobby Lawrence

    1. Hi Vasilis,
      A PIR sensor is not really the right type of sensor for this application. They generally have a short sensing distance as they’re designed to detect humans or animals a short way away from the sensor, in a room or in the bounds of a property. They’re intentionally designed to not pick up things far away as this would cause false triggering of lights and alarms.
      I’m also not sure why you’d want to use a PIR sensor? LDRs are really cheap and work reliably for this type of application.

      1. Hi again.
        Ask for a RIP sensor for a new projector. No the same.
        A system how can detect animals.
        Wildlife systems not for lighting.

    1. The code shouldn’t require it to be continuously connected to a computer. You can disconnect it and provide a power supply and it will work as a standalone system.

    2. I made a suitable code. It is not perfect.
      But it supports the change of the sensitivity and also of the delay. And it displays everything on an oled screen. I have developed PCB boards and I can give you the plans and code (free) if you want. It’s not professional. This is my first card but it works. I can put a zip archive on OneDrive and you can adapt it after

      1. Hi Michaël,
        That sounds awesome! Yes, if you’re happy to share the plans and code, please send the link to OneDrive through to admin(at)the-diy-life(dot)com and I’ll get them uploaded.

Leave a Reply

Your email address will not be published.