This personal Lightning Detector is exactly what it sounds like: a small device that alerts you to nearby lightning strikes. It even tells you how far away they are. The materials for building it cost less than a commercial lightning detector, and you’ll get to hone your circuit-making skills in the process.

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.

The sensor can detect lightning strikes up to 40km (25 miles) away and is capable of determining the distance of a strike to within a tolerance of 4km (2.5 miles). While this is a reliable sensor, you should not depend upon it to warn you of lightning strikes if you’re outdoors. Your own circuit handiwork may not be as reliable as a commercial lightning detector.

YouTube player

Project Steps

Plan out 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. A lithium ion polymer battery powers the device, so I also decided to integrate a LiPo charger into the circuit.

Figure A

Figure A depicts the entire circuit. Note that the connection between the LiPo battery and the LiPo battery charger is via the JST male/female connectors and does not require soldering.

Assemble the circuit

This device is a great candidate for the circuit assembly technique known as free-forming. Rather than affix the parts to a substrate such as a perf board, you can just connect everything with wires instead (Figure B). This makes the project much smaller and faster to assemble, but can produce less aesthetically pleasing results. I like to cover my freeform circuits with a 3D-printed case at the end. You can see how I assembled my freeform circuit for this project in the video above.

Connect Beetle to Charger

Unsolder the green terminal blocks from the LiPo charger. You don’t need them, and they take up space. Then connect the positive (+) and negative (–) terminals of the LiPo charger to the positive (+) and negative (–) terminals at the front of the Beetle. This feeds the raw voltage of the LiPo battery straight into the microcontroller. The Beetle technically needs 5V, but it will still operate on the roughly 4V from the LiPo.

Wire the Lightning Sensor

Cut the included 4-pin cable so that roughly 2″ of wire remains. Strip the ends and plug the cable into the lightning sensor, making the following connections:

  • Positive (+) on the lightning sensor to positive (+) on the Beetle 
  • Negative (–) on the lightning sensor to negative (–) on the Beetle 
  • Clock pin (C) on the lightning sensor to the SCL pad on the Beetle 
  • Data pin (D) on the lightning sensor to the SDA pad on the Beetle.

Also connect the IRQ pin on the lightning sensor to the RX pad on the Beetle. The connection needs to go to a hardware interrupt on the Beetle, and the RX pad (pin 0) is the only interrupt-capable pin remaining.

Wire the Buzzer

Connect the buzzer’s short lead to the negative (–) terminal on the Beetle (ground), and its long lead to pin 11. Since the buzzer’s signal pin should be connected to a PWM pin for maximum versatility, pin 11 is perfect.

Add the Switch

Add a switch inline to the battery to turn the project on and off. First, solder two wires to adjacent terminals on the switch. After soldering, I fixed these in place with hot glue, as the switch’s connections are fragile.

Figure B

Cut the red wire on the battery about halfway down and solder the wires from the switch to each end. You can see these connections on the righthand side in Figure B. 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.

Fold Everything In

Figure C

The last step is to take the gangly mess of wires and components and make it look somewhat presentable (Figure C). This is a delicate task, as you want to be sure you don’t break any wires. Start by hot-gluing the LiPo charger to the top of the LiPo battery, then glue the Beetle on top of that. Finally, glue the lightning sensor at the very top. I left the buzzer to sit off to the side, as shown Figure C. The final result is a stack of boards with wires running throughout. I also left the switch’s leads free to integrate into a 3D-printed case later.

Program the microcontroller

Open the Arduino IDE on your computer and make sure the Tools→Board selection is set to “Leonardo.” Download and install the library for the lightning sensor at Then download the project code from and upload it to the Beetle. The software is simple but it’s very 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 in kilometers. If lightning is less than 10km (6.2 miles) away, the device will emit one long beep. If it’s more than 10km (6.2 miles), the device will divide the distance by 10, round it, and beep that many times. For example, if lightning strikes 26km (16 miles) away, the device will beep three times.

The software revolves around interrupts from the lightning sensor. When the lightning sensor detects the electromagnetic radiation from a lightning strike, it sends 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 interference/noise level is too high. If so, you’ll need to move your detector away from any electronic devices. Radiation coming from these devices can easily dwarf the comparatively weak radiation from a distant lightning strike.

3D print a case (optional)

I modeled a case for my device. You can download the files for 3D printing from (Figures D and E). The top of the case snaps onto the bottom, so no special hardware is required. I made it big enough that it will probably fit your device (Figure F), but you can also try creating your own case:

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

Detecting Lightning Strikes

Congratulations, you now have a fully functioning lightning detector! I recommend waiting until there’s a thunderstorm around you to make sure the device actually is capable of detecting lightning. I don’t know the reliability of this sensor, but mine worked on the first try.

Charging the device is simple — you can just plug a micro-USB cable into the LiPo charger until the charging light turns green. Make sure the device is switched on while you charge it, or no power will go to the battery!

Making Modifications

There are many modifications you can make to the software to make your lightning detector more useful and user-friendly.

  • Change the beeps: You can use the Tone.h library to generate more pleasant-sounding notes.
  • Implement sleep mode: The ATmega32u4 microcontroller (the chip powering the Beetle) supports hardware interrupts in sleep mode. You can place the device into sleep mode, then have it wake up when it receives an event from the lightning sensor. This should greatly extend the battery life of the system.