Thunderstorm Lightning Detector and Camera Trigger (or Droplet Detector)

3,872

53

16

Introduction: Thunderstorm Lightning Detector and Camera Trigger (or Droplet Detector)

Ever wanted to capture lightning on photo? Maybe this camera trigger will help you make incredible images. Sorry, it will not help you with the composition of your photo, the sensor sensitivity, shutter speed, aperture or whitebalance settings of your camera, but it will hit the shutterbutton as fast as possible when the lightning flash occurs.

This trigger is intended for cameras which can be controlled via a switch based remote control. I build it for my Canon EOS camera.

As a bonus it can be used as a droplet detector.

Step 1: Components

  • 1x Arduino ProMicro (or any other Arduino)
  • 2x optocoupler 4N25
  • 2x diode 1N4148 (or any other diode)
  • 2x resistor 470 ohm
  • 3x Led
  • 3x resistor 330 ohm
  • 1x opamp LM358
  • 4x photodiode (5mm IR Led Receiver 940 nm)
  • 3x dipswitches
  • 1x (trim)potmeter 10 kohm linear
  • 1x resistor 10 kohm
  • 2.5 mm jackplug (for connection to Canon EOS camera)

Step 2: Sensor Part

The sensor is build around an LM358 opamp and one or more reverse biased photodiodes in parallel. Adding photodiodes makes it more sensitive, especially during night conditions.

The output of the opamp is connected to a digital port of the Arduino. This MUST be an interrupt port in order to respond immediately to a lightning flash (interrupt the regular loop). The software must respond to a rising edge. Check the documentation of your Arduino for the correct port needed.

The opamp inputs are connected to analog inputs in order to read the threshold and the lightintensity.

Step 3: Camera Part

The camera is connected to the Arduino via optocouplers so it is electrically isolated. In my case the optocouplers are the “replacement” of the switches in my Canon RS60-E3 Remote Control and act as the shutter (-halfway) button.

Step 4: Arduino Software

Use the code shown below

/*
* Thunderstorm lightning detector and camera trigger.
*
* Pieter Horjus
* May 2020
*/

#include <Arduino.h>

int SHUTTERBUTTON_HALFWAY_PIN = 4;
int SHUTTERBUTTON_PIN = 5;
int PHOTOSEQUENCE_LED_PIN = 6;
int sensorPinThreshold = A8; // analog input pin for measuring the threshold
int sensorPinFlash = A9; // analog input pin for measuring the flashintensity

// Below specify the pin which is connected to the flashdetector.
// It MUST be a hardware-interrupt pin on your Arduino in order to respond immediately
// to the detected flash. Check the specification of the Arduino you are using.
int FLASH_DETECT_PIN = 7; // this pin is INT4 on an Arduino Leonardo
// (also Sparkfun Pro Micro)

volatile int maxValueMeasured = 0;
volatile long momentMaxValueIsMeasured = 0;
volatile boolean makingPhotoSequence = false;
volatile int flashcount = 0;
volatile long shutterbuttonPressedStartingmoment = 0;
volatile int sensorValueThreshold = 0;
volatile int sensorValueFlash = 0;

long shutterbuttonActiveTime = 300; // time (msec) the shutterbutton is pushed
// (increase in case you need continuous shooting)
long photosequencePeriod = 3000; // force an idle time (msec) between making two pictures
long currentTime;
long wakeupMoment = 0;

void setup(void)
{
Serial.begin(9600);

pinMode(SHUTTERBUTTON_HALFWAY_PIN, OUTPUT);
digitalWrite(SHUTTERBUTTON_HALFWAY_PIN, LOW);
pinMode(SHUTTERBUTTON_PIN, OUTPUT);
digitalWrite(SHUTTERBUTTON_PIN, LOW);
pinMode(PHOTOSEQUENCE_LED_PIN, OUTPUT);
digitalWrite(PHOTOSEQUENCE_LED_PIN, LOW);
pinMode(FLASH_DETECT_PIN, INPUT);

TXLED0; // deactivate TX led on Sparkfun
RXLED0; // deactivate RX led on Sparkfun

digitalWrite(SHUTTERBUTTON_HALFWAY_PIN, LOW);
attachInterrupt(digitalPinToInterrupt(FLASH_DETECT_PIN), detectedFlashInterruptRoutine, RISING);
}

void loop(void)
{
currentTime = millis();
checkPhotoSequence();
measureValuesLightsensors();
determineMaxValueMeasured();
checkWakeup();
showThreshold();
}

void detectedFlashInterruptRoutine() {
if (makingPhotoSequence == false) {
// immediately hit the shutterbutton so the camera can do its thing
digitalWrite(SHUTTERBUTTON_PIN, HIGH);
// from now on nothing is time-critical
digitalWrite(PHOTOSEQUENCE_LED_PIN, HIGH);
makingPhotoSequence = true;
flashcount++;
shutterbuttonPressedStartingmoment = millis();
Serial.print("amount flashes detected: ");
Serial.println(flashcount);
}
measureValuesLightsensors();
determineMaxValueMeasured();
}

void checkPhotoSequence() {
// The detectedFlashInterruptRoutine might have detected a flash.
// If so, it activated a photosequence.

if (makingPhotoSequence == true) {
// busy making a photo
if (currentTime > (shutterbuttonPressedStartingmoment + photosequencePeriod)) {
// Waited enough time after making a picture
// (including idle time after releasing the shutterbutton)
digitalWrite(PHOTOSEQUENCE_LED_PIN, LOW);
makingPhotoSequence = false;
} else if (currentTime > (shutterbuttonPressedStartingmoment + shutterbuttonActiveTime)) {
// end of pushing the shutterbutton
digitalWrite(SHUTTERBUTTON_PIN, LOW);
// end of pushing the shutterbutton halfway (it might be pushed during a wakeup)
digitalWrite(SHUTTERBUTTON_HALFWAY_PIN, LOW);
wakeupMoment = currentTime;
}
}
}

void measureValuesLightsensors() {
sensorValueThreshold = analogRead(sensorPinThreshold);
sensorValueFlash = analogRead(sensorPinFlash);
}

void determineMaxValueMeasured() {
if (sensorValueFlash > maxValueMeasured) {
maxValueMeasured = sensorValueFlash;
momentMaxValueIsMeasured = currentTime;
}
if (currentTime > (momentMaxValueIsMeasured + 10000)) {
// report 10 seconds after detection the max value measured
Serial.print("max: ");
Serial.println(maxValueMeasured);
maxValueMeasured = sensorValueFlash;
momentMaxValueIsMeasured = currentTime;
}
}

void checkWakeup() {
// if your camera has a sleeping mode, it might be wise to keep it awake
// so it reacts as fast as possible on shutterbutton pressed

long keepAwakeTime = 60000; // 60 seconds
if (currentTime > (wakeupMoment + keepAwakeTime)) {
// end of wakeup-sequence
// on systemstartup this is also hit (so test the end first)
digitalWrite(SHUTTERBUTTON_HALFWAY_PIN, LOW);
wakeupMoment = currentTime;
} else if (currentTime > (wakeupMoment + keepAwakeTime - 500)) {
// start of wakeup-sequence
digitalWrite(SHUTTERBUTTON_HALFWAY_PIN, HIGH);
}
}

void showThreshold() {
static long count = 0;
if ((count % 2500 == 0)) {
Serial.print("threshold: ");
Serial.println(sensorValueThreshold);
}
count++;
}

Step 5: Mounting Plate

Use thick drawing paper (used for watercolor drawing). Glue multiple layers on top of each other and sculpt a shape which fits the hot shoe of your camera. Use indelible wood glue. It makes the layers very stiff and sturdy. Secure the circuitboard on the mounting plate. Slide the plate on the hot shoe.

Step 6: The Testing Process (1)

I started construction during Christmas holiday 2019. I gave myself a deadline. I wanted to test the device by photographing the New Year fireworks in my neighborhood.

First tests were promising. The trigger responded to my tv remote control. At night it also detected a cameraflash at a distance of 30 feet. But was it enough?

Then the New Years fireworks came. It proved to be a success: 97 pictures shot in 30 minutes. I only needed to aim, the trigger operated the shutter.

Images: Canon EOS-300D, 18mm lens, manual focus, mode TV 2 sec, auto whitebalance.

Step 7: The Testing Process (2)

So I was ready to make pictures of the King's Day fireworks on April 27th and the 75-th End of WW-II Anniversary on May 5th here in the Netherlands.

Then came the coronavirus pandemic. No group gatherings allowed, no fireworks, no pictures.

Fortunately on April 30th, a small thunderstorm approached. First storm, four flashes, four detected, four pictures, two within view of the camera, two outside view. Not bad for a first attempt.

Images: Canon EOS-70D, 18 mm lens, manual focus, auto everything

Step 8: Ideas to Upgrade Your Triggerdevice

Add a display (OLED screen) which shows the threshold, measured intensity, flashcount, etc.

Step 9: Bonus 1: Droplet Detector

Look for the following line in the code

attachInterrupt(digitalPinToInterrupt(FLASH_DETECT_PIN), detectedFlashInterruptRoutine, RISING);

and change it to

attachInterrupt(digitalPinToInterrupt(FLASH_DETECT_PIN), detectedFlashInterruptRoutine, FALLING);

Power an infrared Led and position it opposite to your photodiode. This creates an infrared light barrier. Now you have a droplet detector. As soon as the droplet passes the barrier, the shutter is activated.

Start making amazing pictures.

Step 10: Droplet Detector, Capturing Technique

Capturing a repeating event (stream of droplets, left image) is pretty easy. You only need to manual focus the camera.

Capturing a single event (right image) is more challenging for your camera. I added a button and some extra software to the trigger device. When pushed the button activates the shutter-halfway circuit and keeps it activated. It is released when a droplet is detected. By manually activating it, the camera does the light measurement (aperture, sensor sensitivity, colorbalance, etc) in advance. So when the droplet is detected and the shutterbutton is activated, the camera immediately can open the shutter curtains.

Step 11: Bonus 2: Timelapse

Since all the electronics and drivers are present to activate/release the shutter button, it is very easy to build in timelapse functionality.

Create a loop:

  • activate shutterbutton
  • deactivate shutterbutton
  • wait a while

Step 12: Points for Improvement

I used a small trimpotmeter for adjusting the threshold. This forces me to use a screwdriver for adjustment. Better use a potentiometer with a long shaft. This is particulary handy when lightconditions changes often.

Step 13: Conclusion

The lightning camera trigger works as expected. It even helps with making pictures of fireworks and droplets.

As you saw my pictures look very amateuristic, even bad. I have to work on my technical and artistic skills to improve this. But thats a whole different ballgame.

I hope you enjoyed reading this article.

Good luck and happy shooting.

Step 14: Links

Step 15: One Year Later ...

Here are two pictures i shot last year. It gives an impression what is possible.

Both pictures have an exposure time of 2 seconds. The left one is of a lightning strike at a distance of 15 km. The second one was of a storm front at a distance of 40 km. Watch the lightning strike behind the tree at the left lower counter.

First Time Author Contest

Participated in the
First Time Author Contest

Be the First to Share

    Recommendations

    • Big and Small Contest

      Big and Small Contest
    • For the Home Contest

      For the Home Contest
    • Game Design: Student Design Challenge

      Game Design: Student Design Challenge

    16 Comments

    0
    SBINS
    SBINS

    10 months ago

    Hi,

    I am trying to build this but had a small question regarding the schematics. I am also an amateur/beginner and hence wanted to clarify before placing the components together.

    1. In the images I see 4 push buttons which are not in the schematics. Can you please tell me why they are needed?

    2. In the schematics (sensor part) , I see you have U2, U3 AND U4. It looks like switches but again can you please explain why they are needed or what are they if I read it wrong (what is u2,u3,u4).

    3. In the image, there is a red thing beside the photo diodes which I cannot see in the schematics. Can you kindly confirm what is that and its use.

    Thanks a lot in advance and fantastic project. I would love to build and see what it can do. :)

    Best Regards,
    s

    0
    PieterHorjus
    PieterHorjus

    Reply 9 months ago

    Hello,

    Thanks for being interested in my project. Here is some extra explanation.

    In left upper part of the first picture you see two buttons. I connected them directly to the output wires to the camera. They are used as a direct focusbutton and shutterbutton. With them I can test the wiring/connection to the camera and make pictures even without powering up the detector.
    The third (and not visible) forth and fifth button I use for stepping through the menus of the display. They are not needed for the basic version.

    The red thing besides the photodiodes is a four-pin dip switch. It contains the switches U2, U3 and U4. With them you can switch extra photodiodes in parallel. More photodiodes in parallel makes the sensor more sensitive. When I have all four in parallel I am able to detect lightning at 40 km easily when it is dark.

    I hope this explanation will help.

    Also read the other comments for extra information. The diodes in the schema are obsolete also. I made a second detector without the diodes and it is still working.

    Regards,
    Pieter

    0
    SBINS
    SBINS

    Reply 9 months ago

    Dear Pieter,

    Thank you very much for the detailed reply. It helped a lot to understand everything :)

    I just finished building a prototype. I will need to test it in a real thunderstorm /Fireworks. Initial tests showed response. In day time , the op-amp output is always high (even with the POT turned to max) since daylight has IR. I will do a few test and post a feed back here to help everyone.

    Many thanks for your explanation which helped me finish this and next storm I cannot wait to enjoy "looking" than fiddling with my cam which all photographers do mostly :)

    Best Regards,
    S

    0
    PieterHorjus
    PieterHorjus

    Reply 9 months ago

    Hello S,

    A good test is to check if it responds to an (external) camera flash in a dark environment. You won’t be able to capture the flash because such a flash is too fast (milliseconds), but at least a picture should be made.

    Do not use a LED flash, there is no infrared light in it.

    Greetings,
    Pieter

    0
    SBINS
    SBINS

    Reply 9 months ago

    Hi Pieter,

    Quick update.

    1. A zippo lighter spark can be used to test and it works nice to calibrate.



    2. If the POT reads zero, it actually does not work. A threshold value of 11-12 seems to trigger best at night and 620 is the value for day with clouds. Is this the same for you and zero does not work? Also, can you please tell me your minimum/average threshold value you use for reference?

    3. For mild lightening, the trigger is being triggered perfectly but the camera is missing the bolt. For a strong bolt in the day, it is missing the bolt (strong at night is yet to be tested). Any tips to make it faster?



    So, I confirm that trigger works 100%. Strong lightening produces many bolts and as soon as the trigger is triggered it should captures the rest. (night test left).

    In case of mild and weak lightening only, with behind the cloud bursts or 1 weak bolt with no others, the trigger can miss but works if the burst is strong enough (more test needed). It uses initial bolt to trigger and if nothing follows it, the pic won't show bolts.

    Thanks a lot for sharing your views :)



    Best Regards,
    s

    0
    PieterHorjus
    PieterHorjus

    Reply 4 months ago

    Hello SBINS,
    Sorry for this late response. Somehow i must have missed the notification of your request.

    About the level, the trigger only works if the level rises from below the threshold to above the threshold. If it is not returning to below, it will not ‘fire’ again. So a threshold of 0 will not work. My experience is that below 10 you can run into instability due to noise.

    About the response, you cannot improve the response of the trigger. It works at almost ‘lightning speed’. The problem here is how fast your camera is responding to the trigger. When i put my camera on automatic, it respond after half a second. And that is most of the time too slow. I have all my camerasettings on manual, mirror in up position, and the focus halfway already activated so the lightmeasurement is also done. With that i could speed up the response to 100 msec. And even then i sometimes miss the lightningbolt. Check the documentation of your camera to find out what to do to improve the response.

    It is in fact a similar problem as i described in the section about capturing a single droplet.

    I hope this will help.

    Greetings

    0
    Ptronx
    Ptronx

    Question 2 years ago

    This looks a cool project that I'd like to try!

    What would need changing If I were to use the 3.3V Arduino? Maybe some resistor values? I'm thinking of running it from rechargeable batteries (3 x 1.2V)...

    Any advice would be welcome.

    0
    PieterHorjus
    PieterHorjus

    Answer 2 years ago

    Hello Ptronx,
    If you use a 3.3V Arduino, the resistors to the 4N25 can be a littlebit lower (330 ohm). Just give it a try and check if your camera is responding.

    Use an Arduino with a free interrupt pin available.

    If powering the circuit is an issue, think about using a 5 volt usb powerbank. But beware to add extra load (several 330 ohm resistors in parallel) because a powerbank often shutdown after a while if the current drawn from it is too low.

    0
    Ptronx
    Ptronx

    Reply 2 years ago

    Many thanks for your advice, Pieter, and for the powerbank tip!

    I'll give it a try and report back, though it may be a few weeks until i get the spare time...

    0
    Ptronx
    Ptronx

    Reply 6 months ago

    It's been much longer than a few weeks, but I've just built the detector and it's ready for testing! I may need to wait for thunder or fireworks for that - striking a match doesn't trigger it and I don't have a TV remote control, non-LED flash or lighter.

    A few observations so far:
    1. There's an error on the 'camera part' diagram - the 'to camera' connection to the shutter-halfway optocoupler should be made on pin 5, not pin 6 (as is correctly shown for the 'shutterbutton' optocoupler)
    2. If using a non-regulated power supply (I am) it's necessary to connect the power to the Arduino's RAW pin, rather than to VCC shown in the 'sensor part' diagram
    3. I tried using 5 x 330 Ohm resistors to keep a 5V powerbank alive, but it's not enough. @ajoyraman has a pulsing keep-live circuit that looks like an alternative here
    4. If using the a 3.3V Arduino, swapping out the 470 Ohm resistors for 330 Ohm versions works OK. That is, the 60 second 'keep live' pulse triggers the camera focus & the associated LED, so it should work for the shutter button too
    5. I had to drop the TXLED0 and RXLED0 lines from the code as they were causing compile errors - it seems that the Arduino Pro Mini that I'm using doesn't support this (?)
    6. It seems that 'threshold' in the code corresponds to pin A0, and 'intensity' to pin A1; hopefully the need for 'intensity' will become clear during testing.

    0
    DiederikvD
    DiederikvD

    Question 2 years ago

    Thanks for sharing this project! Would it be possible to leave the Arduino out and just use the photo diodes, the LM358, R2 and R4 and a 4N25 just for lightning triggering?

    0
    PieterHorjus
    PieterHorjus

    Answer 2 years ago

    Hello Diederik
    It might be possible. Just give it a try.

    0
    ValentinJ2
    ValentinJ2

    2 years ago

    I love this project, thanks for sharing! Can you tell me what is the use of diodes D1 and D2? And is 940 nm a good wavelength to detect lightnings?

    0
    PieterHorjus
    PieterHorjus

    Reply 2 years ago

    Hi ValentinJ2.

    I found the diodes in the schematic of jim-easterbrook (first link). Maybe that schematics is derived from one to control a relais. In that case a flyback diode is required to prevent electrical noise. Good change the diodes are not required.

    About the 940 nm: that was for me also the big question. I did some research on the internet and thought lets give it a try. Heat radiates in infrared and lightning is very hot.
    So it was very exciting to me that all the four lightning strikes on the very first thunderstorm were detected.

    0
    Jim_Easterbrook
    Jim_Easterbrook

    Reply 2 years ago

    The diode in my circuit (adapted from elsewhere) is to protect the 4N25 photo diode from reverse voltage if someone wrongly connects the input pins. In this case there there are no external connections they're almost certainly not needed.