AS3935 lightning detection using Arduino Uno


Some time ago I bought an AS3935 lightning sensor breakout board from Tindie. After some time I needed another sensor for a new project, only to find that it has been discontinued.

This article is more than two years old and might contain obsolete information; it is still kept here for informational purposes.

After some googling around I found the Thunder click board manufactured by the MikroElektronika. The Thunder Click is a breakout board in the mikroBUS form factor, a standardized interface from Mikroelektronika. For the Arduino fans, there is an adapter shield that can accommodate two microBUS devices. Both the Thunder Click and the Click shield are also available from the EU distributor TME.

In this example, the Thunder Click is installed on socket #1 of the adapter shield. The PWR_SEL bridge was set to 5V (originally all mikroBUS boards come set for 3.3V operation). The pin configuration is:

  • AS3935 CS — Arduino D10
  • AS3935 MOSI — Arduino D11
  • AS3935 MISO — Arduino D12
  • AS3935 SCK — Arduino D13
  • AS3935 INT — Arduino D2 (INT). Note this corresponds to Interrupt #0

If the Socket #2 is used, the CS line connects to Arduino Pin D9, and the INT pin connects to Arduino pin D3, corresponding to Interrupt #1 (see for reference). Don’t forget to change the code to reflect the new pin settings.

The code is based on the original library written by Raivis Rengelis available at with some modifications that are explained below:
 First, I added a line to display the value of the calibration register if the calibration is successful.
Second, I moved all the code to display the events inside the interrupt routine itself. The main loop code just displays “Waiting” so I know that the system is not stuck. Now all I have to do is wait for a thunderstorm 🙂

The output of this program looks like this:

Tuning cap register is 7
 Noise floor is: 5
 Spike rejection is: 2
 Watchdog threshold is: 2
 Noise level too high, try adjusting noise floor
 Disturber detected
 Disturber detected
 Lightning detected 27 kilometers away.
 Storm overhead, watch out!

From time to time the sensor reports “Noise level too high”. A possible workaround and future work is to count the number of noise warnings in a given amount of time, and dynamically adjust the noise level using AS3935.setNoiseFloor() function until a compromise between noise warnings and sensitivity is reached.

Update: Normally Arduino disables all interrupt sources during the ISR routine, this is why they recommend keeping the ISR routine short. Delay() also uses interrupts, and it seems that in very rare situations this causes Arduino to hang. For the moment I consider this as being a minor inconvenience, but I have to see what happens during a summer thunderstorm when tens of interrupts per second will occur.


Air quality,2,Arduino code library,2,Arduino projects,23,Buggy,1,Casual stuff,1,ESP8266,2,MikroElektronika,3,PIC projects,7,Review,26,Robots,1,Tutorial,20,
Electronza: AS3935 lightning detection using Arduino Uno
AS3935 lightning detection using Arduino Uno
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content