What if I told you that you could have the power to detect a lightning strike from 40 kilometers away? We'll take a look at this with the DFRobot Lightning Sensor. This module will even tell you how far away that lightning struck. I'm going to set one up with a Raspberry Pi Single-Board Computer and capture some real data on real lightning.
Hey gang, Tim here at Core Electronics and it's go time. This is truly a superpower. This guy will demonstrate exactly how to use this DFRobot Lightning Sensor on a Raspberry Pi Single-Board Computer to create an early warning lightning detection system. It's going to run continuously and whenever lightning occurs within the 40 kilometer radius range, it's going to output that fact as well as how far away that lightning struck.
There are three types of lightning: cloud-to-cloud, cloud-to-cloud, and cloud-to-ground. This module can detect all three. The sensor on this board that really makes all of this possible is the AMS Lightning Sensor codenamed AS3935. This IC detects lightning distance, intensity, and frequency within a radius of 40 kilometers in 15 steps, both indoors or outdoors. The sensitive antenna picks up lightning events in the 500 kilohertz band of the electromagnetic spectrum with an accuracy of one kilometer to the storm front. Furthermore, it auto rejects disturbances in that band that do not match the characteristic profile of lightning. It has an indoor or outdoor toggle depending on the final setup and a number of methods to tune or filter out false positives.
If you want to know more about what's exactly going on inside this board, check the full written up article linked down below. Today, I'm using a Raspberry Pi 4 model B with this DFRobot Gravity Lightning Sensor and on screen now is everything that you need to get started.
You're going to need to follow along. I assume that you know how to run a Raspberry Pi as a desktop computer. Check the article for resources if you don't. Note also that the lightning module comes with all of these connected wires. We will need to solder on some connectors to the lightning sensor. Use blue Tack and flux to make your life easy. With that completed, connect the breakup cable to the lightning module like so.
You're going to find this next step much easier if you use a Raspberry Pi pin out like this one here. So, start by connecting the module's positive pin to the 3.3 pin on the Raspberry Pi. After that, connect the module's negative pin to any ground pin on the Raspberry Pi. Connect GPIO 4 pin of the Pi to the irq pin on the lightning module.
Now for the I²C connections, connect the SDA serial data pin of the Raspberry Pi to the D pin on the module. Finally, connect the SCL (that's serial clock pin) of the Pi to the C pin on the module. Double check all your connections and want sure that all is correct.
Set up your Raspberry Pi as you would a desktop computer and plug in that USBC power. But here we are in the Raspberry Pi desktop. This lightning sensor module requires I²C communication to work. Ensure I²C is enabled on your Raspberry Pi by clicking the top left menu button, going down to preferences and clicking on Raspberry Pi configuration. Underneath the interfaces tab, make sure that I²C is enabled and click apply.
We need to install some python packages to work with this module. In the article, find the software setup section and copy these commands one by one into a new terminal. Open a terminal by pressing the black button on the top left of the screen. Enter 'y' if prompted during installation. With that complete, all the software sides of the setup are done.
Things are sorted. The final step is to copy and paste this Python script from this directory into the same one as the Python script named DFRobot AS3935. Detailed, these two Python scripts rely on each other, so they just need to be in the same folder. With that, your Raspberry Pi system is ready to scan for lightning strikes anywhere within 40 kilometers.
Let's run our system. The easiest way to do that since we're in this folder is to right click it and open it with. With it open, here is our example script. It's all open source code and you can do whatever you would like to it, but I'm most interested in writing it. So press the Big Green Run button to start your script.
Nice! Now you're going to note watching this video that this disturber interrupt message pops up quite often and that's really because of all this technology I'm really lucky to have surrounding me. That I see on board knows what the characteristic shape of a lightning strike is in the electromagnetic spectrum and what is not. So when it sees something that isn't that shape, it spits out that disturber interrupt message. For instance, running a DC motor or activating a solenoid near it will make it pump out these Disturbed discovered messages. Those along with other sources of electromagnetic interference like activating the ignition system in a car, active CRT TV sets, lit fluorescent lights, powering high voltage wires, or turning on light switches, just to name a few sources, will cause this disturber discovered to trigger.
This is all good knowledge for testing and operating your lightning detection Hardware in the pursuit of authenticity. And because nobody can predict lightning, I have been sitting on this guide for a while now. That was until I got lucky one Monday morning and a huge storm plowed over us in Newcastle.
We caught the tail end of the storm and managed to get two Fair Dinkum detections. There's lightning right there, intensity 29, distance one kilometer. We just got another one, this time it's six kilometers away with an intensity of eight and just look how happy that man is with that demonstration complete.
Let's get back to the rest of the guide. Let's jump into the code for just a second. If we scroll down and comment this line out and uncomment this one, we've now set up our DF robot lightning detector to work outdoors. We scroll down a little bit further and do something very similar here. We've now disabled that disturbit interrupt detection, that means our system is going to run a lot faster and it's going to be better for lightning photography purposes.
There's a lot going on inside this script, but this should get you started. Now my system has been accurate and reliable from the get-go. Hopefully you're going to have the same experience as me. However, if you find the system keeps identifying false positives, they can be tuned out. Configuring this is more advanced, so check the full write-up if you need.
Now this is a proper electronic superpower and nobody can tell me otherwise. There are just heaps of potential applications with something like this. It is perfect for an Uber weather station which incorporates thunderstorm measurements. To be perfect as a wearable device for early thunderstorm detection, particularly useful for people who like to climb rocks really high or anyone who works at heights. You could even connect it up to a camera for some hands-free lightning photography. There's just so much going for it.
Lightning is incredibly dangerous, especially to both electronics and humans. This system provides an early warning of thunderstorms so that way people can always be a step ahead. So why not get amongst it?
We are full-time makers and we're always happy to help. Until next time, stay cozy!
Makers love reviews as much as you do, please follow this link to review the products you have purchased.