Personal Lightning Detector




Introduction: Personal Lightning Detector

About: I'm a maker and student at Harvard studying electrical engineering.

In this project we'll create a small device that alerts you to nearby lightning strikes. The total cost of all materials in this project will be cheaper than purchasing a commercial lightning detector, and you'll get to hone your circuit-making skills in the process!

The sensor used in this project can detect lightning strikes up to 40 km away, and is also capable of determining the distance of a strike to within a tolerance of 4 km. While this is a reliable sensor, you should never depend upon it to warn you of lightning strikes if you're outdoors. Your own circuit handiwork will not be as reliable as a commercial lightning detector.

This project is based upon the AS3935 lightning sensor IC, with a carrier circuit from DFRobot. It detects electromagnetic radiation that's characteristic of lightning and uses a special algorithm to convert this information to a distance measurement.


This project only requires a few parts. Information is outputted to the user via a piezo buzzer, and the circuit is powered through a lithium ion polymer battery. Below is a complete list of all the parts:

In addition to these items, you'll want the following tools/items:

  • Soldering iron
  • Solder
  • Hookup wire
  • Wire strippers
  • Hot glue gun

I also detail the process of creating a 3D-printed case for this project. If you don't have a 3D printer, operating the device without a case is still fine.

Step 1: The Circuit

As there's a relatively small number of parts in this build, the circuit is not particularly intricate. The only data lines are the SCL and SDA lines for the lightning sensor and one connection for the buzzer. The device is powered by a lithium ion polymer battery, so I decided to also integrate a lipoly charger into the circuit.

The above image depicts the entire circuit. Note that the connection between the lipoly battery and the lipoly battery charger is via the JST male/female connectors and does not require soldering. See the video at the beginning of this project for further details on the circuit.

Step 2: Circuit Assembly

This device is a great candidate for a circuit assembly technique known as free-forming. Rather than affix the parts in this project to a substrate such as a perf board, we will instead just connect everything with wires. This makes the project much smaller, and it is somewhat faster to assemble, but generally produces less aesthetically pleasing results. I like to cover my free-formed circuits with a 3D-printed case at the end. The video at the beginning of this project details the free-forming process, but I will go over all the steps I took textually as well.

First Steps

The first thing I did was unsolder the green terminal blocks from the lipoly charger. These aren't needed, and take up space. I then connected the "+" and "-" terminals of the lipoly charger to the "+" and "-" terminals at the front of the Beetle. This feeds the raw voltage of the lipoly battery straight into the microcontroller. The Beetle technically needs 5V, but it will still operate on the roughly 4V from the lipoly.

Wiring the Lightning Sensor

I then cut the included 4-pin cable such that roughly two inches of wire remained. I stripped the ends, plugged the cable into the lightning sensor, and made the following connections:

  • "+" on the lightning sensor to "+" on the Beetle
  • "-" on the lightning sensor to "-" on the Beetle
  • "C" on the lightning sensor to the "SCL" pad on the Beetle
  • "D" on the lightning sensor to the "SDA" pad on the Beetle

I also connected the IRQ pin on the lightning sensor to the RX pad on the Beetle. This connection needed to go to a hardware interrupt on the Beetle, and the RX pad (pin 0) was the only interrupt-capable pin remaining.

Wiring the Buzzer

I connected the short lead of the buzzer to the "-" terminal on the Beetle (ground), and the long lead to pin 11. The buzzer's signal pin should be connected to a PWM pin for maximum versatility, which pin 11 is.

Switching the Battery

The last thing necessary is to add a switch inline to the battery to turn the project on and off. To do this, I first soldered two wires to adjacent terminals on the switch. I fixed these in place with hot glue, as the switch's connections are fragile. I then cut the red wire on the battery about halfway down, and soldered the wires coming off the switch to each end. Make sure you cover the exposed sections of wire with heat shrink tubing or hot glue, as these could easily come in contact with one of the ground wires and make a short. After adding the switch, you can plug the battery into the battery charger.

Folding Everything In

The last step is to take the gangly mess of wires and components and make it look somewhat presentable. This is a delicate task, as you want to be sure that you don't break any wires. I first started by hot gluing the lipoly charger to the top of the lipoly battery. I then glued the Beetle on top of that, and finally glued the lightning sensor at the very top. I left the buzzer to sit off to the side, as shown in the above image. The final result is a stack of boards with wires running throughout. I also left the switch's leads to run freely, as I later wish to integrate those into a 3D-printed case.

Step 3: Programming

The software for this circuit is simple at the moment but is heavily customizable to suit your needs. When the device detects lightning, it will first beep many times to alert you that lightning is nearby, then beep a certain number of times corresponding to the lightning's distance. If the lightning is less than 10 kilometers away, the device will emit one long beep. If it is more than 10 km from you, the device will divide the distance by ten, round it, and beep that many times. For example, if lightning strikes 26 km away, the device will beep three times.

The entire software revolves around interrupts from the lightning sensor. When an event is detected the lightning sensor will send the IRQ pin high, which triggers an interrupt in the microcontroller. The sensor can also send interrupts for non-lightning events, such as if the noise level is too high. If the interference/noise is too high, you'll need to move the device away from any electronics. The electromagnetic radiation coming from these devices can easily dwarf the comparatively weak electromagnetic radiation from a distant lightning strike.

To program the microcontroller you can utilize the Arduino IDE - make sure the board selection is set to "Leonardo." You will also need to download and install the library for the lightning sensor. You can find this here.

Step 4: 3D-Printed Case

I modeled a case for my device. Your free-form circuit will likely have different dimensions, but I tried to make my case big enough such that many different designs can still fit in it. You can download the files here, and then print them out. The top of the case snaps on to the bottom, so no special parts are required for the case.

You can also try making a model of your own device and creating a case for it. I detail this process in the video at the beginning of this project, but the basic steps to follow are as such:

  1. Capture the dimensions of your device
  2. Model your device in a CAD program (I like Fusion 360 - students can get it for free)
  3. Create a case by offsetting a profile from the device model. A tolerance of 2 mm generally works well.

Step 5: Using Your Device and More

Congratulations, you should now have a fully-functioning lightning detector! Before using the device for real, I recommend waiting until there's a thunderstorm around you to make sure that the device actually is capable of detecting lightning. Mine worked the first try, but I do not know the reliability of this sensor.

Charging the device is simple - you can just plug a micro-USB cable into the lipoly charger until the charging light turns green. Make sure that the device is on while you charge it, or no power will go to the battery! I also recommend changing the beeps to something that you like more; you can use the Tone.h library to generate more pleasant-sounding notes.

Let me know in the comments if you have any problems or questions. To see more of my projects, check out my website

Sensors Contest

Participated in the
Sensors Contest

Be the First to Share


    • Make It Bridge

      Make It Bridge
    • Game Design: Student Design Challenge

      Game Design: Student Design Challenge
    • For the Home Contest

      For the Home Contest



    3 years ago

    Great write-up but I went looking for parts and found a ready made device on eBay that is cheaper than the sensor you are using. Thanks for posting tho!


    Reply 3 years ago

    Would you mind sharing the link or product description?


    3 years ago

    Cool device, if you build 3 of them and network them together somehow you might be able to get an approximate GPS location of the strike. Quite useful for a farm to tell if any of their assets might have had lightning damage.


    3 years ago

    Very timely as several people were killed by lightning in Poland a few days ago. On the summit of a mountain, metal cross on top, metal handrails.
    A medium wave radio tuned to nothing also gives good indication. I have a healthy respect for lightning. At about 10,000 volts per cm air gap, you do not want to be the ground terminal.


    3 years ago

    Very good write up. What is the purpose, since it's petty easy to tell how far lightning is, just by noting the time between the lightning and the thunderclap?


    Reply 3 years ago

    This device is far more accurate and can detect and report lightning from a much further distance. Timing distance based on thunder is very inaccurate because sound traveling through the air is affected by the density of the air. Also, the thunder can easily be lost in the background clutter of a storm. The electromagnetic radiation signature of lightning can travel miles and is virtually unaffected by those mentioned atmospheric changing conditions. Great project, I'm getting ready to build one.


    3 years ago

    I wonder if an esp8266 couldn't be utilized here somehow. It would be pretty awesome to have this in home assistant and the event this is triggered it would run line commands to close the garage door and sends a message to the hub and all mobile devices to alert of the incoming weather event.