A Lightning Detector for Arduino

You can download our e-book ‘Learn Arduino from Scratch’ from this link

In this tutorial, we will build a lightning detector using an Arduino Uno, a few resistors and some jumper wires. Most lightning detectors often cost too much for the normal hobbyist, however this does not mean one cannot enjoy lightning detection and the physics behind it. In this tutorial, using a surprisingly simple circuit we will be able to detect lightnings from around 10-20 km away, which is to say the least impressive.
The aim is to construct a simple circuit to detect lightnings with an Arduino and produce meaningful results.

Background

When a lightning strikes, a huge amount of energy is released in different forms. The most obvious are light and sound, the latter being a by-product of the rate of temperature increase of the immediate particles surrounding the lightning bolt, which then causes the sound. But, that is not all. Lightnings emit large amount of electromagnetic radiation in the VLF (Very Low Frequency) and LF (Low Frequency) range, typically ranging from 3kHz to 300kHz. VLF and LF are similar to light waves, your WiFi waves and also your microwave oven waves, but with the difference of operating at lower frequencies. eg. WiFi normally operates at around 2.4GHz, that’s 2.4 billion oscillations per second. VLF and LF operates at lower frequencies, and with an Arduino we can capture frequencies around 7kHz. The advantages in using this kind of radiation for lightning detection is that normally nothing gives out large bursts as seen in lightnings, around this frequency; and being an electromagnetic wave it travels at the speed of light, which means the sensor will detect lightnings as they happen (a few micro seconds after).
Our little Arduino will have an antenna (sort of), a piece of wire that will pick fluctuations in electromagnetic spectrum specifically around the 7-9kHz. These fluctuations will induce a small voltage +ve or -ve in the wire. We can pick these fluctuations using Arduino’s analog pins.

As you might already know, the pins on the Arduino board allow for voltages between 0v and 5v, anything below 0v and above 5v will not be read,hence data will be lost. More importantly, voltages below 0v will potentially damage the pin. This will create a little problem for us because the voltages produced in the wire fluctuate below and above 0v. To solve this problem we set the pin voltage in the middle of the 5v range, at 2.5v and this will be accomplished using a little trick, a voltage divider. In doing so, we will be setting the pin to a steady 2.5v and the voltage fluctuations will have an origin of 2.5v, hence no damage or loss of data.

Lightning Detector Circuit DiagramLightning Detector

The circuit is pretty straight forward, we have 2x 10k Ohm resistors in series from 5v (red wire) to GND (black wire), this is basically the voltage divider. Then a 3.3M Ohm (MegaOhm) resistor is connected between the 2x 10k Ohm resistor. In series with the 3.3M Ohm resistor attach a wire to pin A4 (blue wire), this will give us exactly 2.5v on pin A4. Then attach a wire which will act as an antenna (green wire) of around 6-8 inch in length. This should be connected from one end only as shown above.

Sketch

Here comes the hardest part to explain. As mentioned above, the frequency we need to pick up from the lightnings, is around 7kHz and to read a semi-decent wave the sample rate has to be 4x as much, giving us 4 readings per wavelength. That is, 28,000 samples per second.

The Arduino analog pins can only give us 9,600 samples per seconds. With that sample rate we will only be able to capture waves at 2kHz or a bit more, which is far from good. Thanks to the ATMEGA chip, it can be configured to speed up the ADC process by a certain factor, while retaining a good resolution. This is called the prescaler, and can be configured through code. There are a number of prescaler dividing factors but we will use factor 16 which in theory will give us a sampling rate of 77kHz. In practice any form of calculation will lower this sampling rate thus I was only able to get around 46kHz which is still very good for this project.

So moving forward, the sketch uses a 512 byte array to store voltage valves from pin A4. It constantly reads the pin value and writing it to the next location in the array. As soon as a lightning is detected the whole array is sent over the serial port. This can be plotted on the graph plotter in Arduino IDE or maybe sent over to another Arduino or ESP8266 to publish the data online. It’s probably best to monitor it via the Arduino IDE at first, so if there are some glitches, they can be tackled there and then.

Note that the device is very sensitive to EMF fluctuations. This includes AC power supplies. Place the device away from any AC supply and any socket outlets. We have also noticed that it behaves abnormal when connected to a laptop while charging. We recommend to use a laptop running on batteries only for optimum performance.

Hi Ultron,
I am sorry I couldn’t respond earlier, I was out of town with a very limited internet access.
You can view the results in the Serial Monitor provided in the IDE. You will see a bunch of numbers but if you plot them in a graph you’ll get something light the ones above.

Regarding the circuit, its pretty straight forward and a real life photo would probably be more complicated to trace. If you need I can give you a schematic drawing of the circuit.

Blinker, yes i am still having issues and am unable to get the circuit to work. It shows the graph and the first time a blue line came on the graph from then nothing comes on the graph instead of this error – ” Exception in thread “AWT-EventQueue-0″ java.util.NoSuchElementException” . Blinker can you please send me your code too, i have a school science fair to take care of. Thank you admin and blinker!!

Thanks for the cool project! I was just hoping you could clarify a couple of things for me. I know a voltage divider cuts your voltage in half as long as both of the resistors are the same. So why did you choose 10k resistors instead of some other? Also what does the 3.3M resistor do and what effect would it have if I was to replace it with a higher or lower resistance?

This is really fun. I’m looking at trying to expand it so that when it detects a lightning strike it switches over to listening for thunder with a sound detector. I can then use the old speed of sound trick to estimate the distance of the strike. I don’t know how it’ll work but it should be fun to try!

Hi Ultron,
The code compiles and works as expected. If you are trying to use the Arduino IDE serial plotter to display the graph you need to comment some lines.
Basically you need to replace the following function.

It would be difficult to load any libraries on the same Arduino since it uses almost all available RAM. How ever it would be interesting if we could add an ESP8266, receives data using serial.write, and stores them in an SD card to be served as a web page.