Lightning detector

sensor to detect electrical shock in the atmosphere capable of letting us know how near and how strong it is

Similar projects worth following
By using a sensible RF receiver and processing the signal received using a proprietary algorithm, the AS3935 integrated can determine if the electrical activity detected is caused by lightning, and it estimates the probable distance based on the signal’s intensity; with distance we mean distance from the start of the storm where lightning start to form and the chip can determine it with sufficient approximation between a maximum of 40 km and a minimum of 1 km. The algorithm is used to tell apart, with a certain approximation, lightnings (atmospheric discharges) and electrical discharges produced for instance by ignition coils and spark plugs, brush electric motors, and microwave ovens.

In order to make the atmospheric discharges sensor more easily usable, i have made a breakout board containing the AS3935 integrated supply. The heart is clearly the IC, and i bring its power, the communication bus with external microcontroller circuits and the major control signals, to the outside. All the lines to connect externally or to be handled externally are brought to a line of pads with 2.54 mm gap on one side, to which we can apply a pinstrip. Data connection with the external world is serial, using an I²C-Bus or SPI bus; in the last case we will make use of the lines:

  • MISO (Master Input Slave Output) which is to breakout boards output used to send data related to detected lightnings to Arduino;
  • MOSI (Master Output Slave Input) which is the data output of Arduino used to communicate setting message or confirmation message to the breakout board;
  • CS (Chip Select) which is the line of Arduino enabling the breakout board to interact on the SPI bus;  CS is useful because several devices can use the SPI and in order to avoid data collegians we need every communication session to enable just one device per time.
  • SCL (clock) corresponding to the signal synchronizing bus communication.

Note that pin 8 of the AS3935, i.e. the CS is kept at logic level high from its internal pull-up resistor if not specified otherwise, but it can be forced to logic zero by the JCS jumper where external management is not needed. For what concerns serial communication mode, this can be selected on the breakout board using the second jumper, labeled SI, intervening on pin 9 (Select Interface); the integrated AS3935 integrated works:

  • in SPI mode if being at 9 is at logic zero;
  • in I²C mode if Select Interface is at VDD.

In my application i chose the first option, so you can see the jumper has been closed. 

I have pin IRQ (10), brought to terminal 3 of the CN1 connector, which communicates the microcontroller when IRQ is an output that AS3935 Brinks logic level high when a lightning is detected and the corresponding value is written in one of the internal registers (REG0x03[3:0]).

The input stage, which is the stage that allows me to detect the radioelectric disturbance corresponding to the lightning; this is related to pins 2 and 3, which are the radio-receiver input of the integrated circuit, which requires an anti-resonant circuit to the input in order to tune a certain bandwidth and exclude low-frequency disturbances which are not relevant to the purpose.


The project i am proposing is essentially made of three elements: lightning detector, available on the breakup board, an Arduino Uno board, which duty is to analyze the signal provided by the sensor, process it and show on serial LCD display (which is the third element of the circuit) the information extracted, i.e. the number of electric discharges detected that can be considered “spawn” of lightning along with estimated distance.

Everything must be connected as we can see in the wiring diagram visible in these pages, where the sensor breakout board interfaces with Arduino through the ISCP connector, since the latter carries the complete, 4-line SPI bus.

In order to manage the serial display, we use a software serial, emulated thanks to the SoftwareSerial.h library, which allows you to free the hardware serial for possible applications that need it. The sensor breakout board is connected, as mentioned, through an SPI bus, from which it receives all the settings and communicates data regarding lightning detection; the onboard chip is enough on itself to measure intensity and detect the course of the electrical discharges detected by the coil mounted on the breakout board, therefore the data provided to not require any special processing by Arduino.

The connection with the breakout board takes advantage of the SPI bus lines reported on the ICSP connector; then we have GND (ground) and Vcc (connected to +5V) used by the board to take power from...

Read more »


Sketch for Arduino IDE

x-zip-compressed - 4.53 kB - 05/25/2019 at 14:56


Arduinio Library AS3935

x-zip-compressed - 11.94 kB - 05/25/2019 at 14:56


  • 1
    Connect the Hardware

    In the first step is necessary to link the sensor to Arduino using wires as schematic diagram, i suggest to use different colour, so it will be easy. 

    Now you can connect the display to Arduino. The display must be serial communication.
    Once all the connections have been made, you can go to the programming part.

  • 2
    Installing IDE Arduino

    The programming file has been published in these pages, as well as the library, so it will be easy to load the sketch on Arduino.

    Download the Arduino IDE on your computer. To use the published library, we recommend the 1.6.x version of the IDE (version that I used to create the sketch), but by updating the library, you can also use more recent versions.

    If you want to use the 1.6.7 version of the IDE, this can be downloaded from:

    On the page you will find both the version for Linux / Mac / Windows. All that remains is to choose the correct version and proceed with the installation in the operating system. I will not explain how to install the program, but in the next step I will explain how to load the library.

  • 3
    Installing AS3935 Library

    Now that the IDE is installed, it is important to install the sensor library in the IDE, otherwise error messages will be shown when compiling the sketch.

    There are two ways to install the library, that is to download from these pages (recommended choice because I guarantee the operation with the sketch), or install the library through the IDE library manager. In this last case, if the latest version is installed, I'm not sure it can be compatible with the sketch I created.

    I will explain how to use my library. Download the file from this site, so you will find a .ZIP file that you will have to decompress on the desktop for example. Now copy the AS3935 folder which has been decompressed, inside the directory where all the Arduino libraries are present, which is usually found among the documents on your computer, for example I use Windows and find it in this path "C: Users \ Alex \ Documents \ Arduino \ libraries ". When you copy the folder to the "libraries" directories, make sure that when you open the AS3935 directory you immediately find 4 files as below

    Now the library is ready to be used. If you want to verify that the IDE recognizes it, open the IDE, then opening "File> Examples" you will find the AS3935 folder

View all 5 instructions

Enjoy this project?



Tyler Gerritsen wrote 05/26/2019 at 13:54 point

I imagine it could be more sensitive than a light sensor, which is what some folks use to capture lightning.  I may be interested in assembling on in the future!  Thanks for the great write-up.

  Are you sure? yes | no

Tyler Gerritsen wrote 05/25/2019 at 19:48 point

Very cool!  Can this be used for triggering a camera?  If so then I would be interested in building one.

  Are you sure? yes | no

Alessandro Sottocornola wrote 05/26/2019 at 11:20 point

i never think to use this for triggering a camera but if there  is a lightning the device advise immediatly with detected signal message. It could be interested your idea,but will be to try

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates