Tutorial: Tuning the SkyWeather ThunderBoard Lightning Detector

Tutorial: Tuning the SkyWeather ThunderBoard Lightning Detector

This is a tutorial on lightning detector tuning for your SkyWeather weather station kit.  SkyWeather is a Raspberry Pi based Weather Station Kit for your hyper-local weather.

This kit is a perfect technology project to learn all about the weather and how to sense the environment around you.  Including Air Quality and Lightning.  Right here.  Right in your neighborhood.

This Raspberry Pi kit allows you to build your own weather station with a Sky Cam to take pictures of your Sky and display them the cloud on WeatherSTEM.

Lightning Detection and SkyWeather

How the heck do we detect lightning?  You would think it would be pretty easy, but it turns out it is not.   It’s not just like a giant spark.   Well, it is a giant spark, but there are lots of other things that make electrical noise that can be confused for lightning.  Your computer (even your Raspberry PI and Arduino!), your car, the motor in your refrigerator, your cell phone, your computer monitor, your AM/FM radio and even your TV.  They all make electrical noise that can be confused with Lightning.

The Thunder Board  is designed for use in Low Power applications such as battery and Solar Power applications.   It can detect lighting up to 40km away.

  • – I2C Interface – 0x02 Address
  • – Grove Connectors – No Soldering Required
  • – Lightning sensor warns of lightning storm activity within a radius of 40km
  • – Distance estimation to the head of the storm down to 1km in 14 steps
  • – Detects both cloud-to-ground and intra-cloud (cloud-to-cloud) flashes
  • – Embedded man-made disturber rejection algorithm
  • – Programmable detection levels enable threshold setting for optimal controls
  • – I2C interface is used for control and register reading
  • – Antenna Tuning to compensate variations of the external components
  • – Power-down, listening, and active mode


The Thunder Board is an I2C device and detects Lightning and provides a distance estimate to the “leading edge” of an incoming storm.

The Thunder Board Specification is Here.

How to Set the Tuning in SkyWeather

If you have a ThunderBoard AS3935 connected to your SkyWeather system, there are six different tuning parameters to set.

As of SkyWeather V042, look in the config.py (or confocal.py if you have set up that file) and look for the following code:

# AS3935 Lightning Configuration
# format: [NoiseFLoor, Indoor, TuneCap, DisturberDetection, WatchDogThreshold, SpikeDetection]
AS3935_Lightning_Config = [2,1,3,0,3,3]

To modify these parameters, edit your config file and then restart the SkyWeather Software.

Before you make modifications read about each parameter and then watch the video below.

How Do I Know if It Works?

You have changed the parameters.  How do I know if it works?    This is a problem with Lightning Detectors.  You need a lightning storm.  If you don’t want to wait for natural lightning, we have produced a Lightning Simulator to help out testing your parameters and the sensitivity.

You will get a pretty good idea about your noise sensitivity by moving cell phones or video monitors close to your ThunderBoard lightning detector.


Parameter Descriptions

The descriptions of each of these is below.   Please watch the video below on what these parameters do for more information and explanations.

Noise Floor

The output signal of the AFE is also used to generate the noise floor level. The noise floor is continuously compared to a reference voltage (noise threshold). Whenever the noise floor level crosses the noise threshold, the AS3935 issues an interrupt (INT_NH) to inform the external unit (e.g. MCU) that the AS3935 cannot operate properly due to the high input noise received by the antenna (e.g. blocker).  Low values of the Noise Floor makes the ThunderBoard more sensitive, but may pick up more noise.   Default of 2.  Range 0-7.

Indoor / Outdoor Selection

The AFE (Analog Front End) amplifies and demodulates the AC-signal picked up by the antenna. Since the AS3935 is a lightning sensor based on narrowband receiving technique (center frequency of 500kHz and a bandwidth of about 33kHz), the AFE bandwidth is meant to be greater than the antenna bandwidth. In this way, it is possible to consider that the gain within the antenna bandwidth as constant.

The gain of the AFE by default is optimized to operate indoor (e.g. inside a building). If the AS3935 operates outdoor, then the AFE gain setting has to be set to a lower value, as shown in the Table 15. Indoor and Outdoor setting must be selected according to according to the application.

Tuning Capacitor

Internal Tuning Capacitors (from 0 to 120pF in steps of 8pf).  This adjusts the receiving antenna to maximize lightning detection.    A value of 3 is default in SkyWeather.  Range of 0-15.

If you want to exactly tune your ThunderBoards, you can hook it up to an Arduino and then run the software provided in:


Report Disturbers / Do not Report Disturbers Selection

The lightning algorithm block, processing the demodulated signal, can distinguish between lightning signal and man-made disturbers. If the received signal is classified as a man-made disturber, then the event is rejected and the system automatically goes back into listening mode to minimize current consumption. If the incoming signal identifies a lightning event, then the statistical distance estimation block performs an estimation of the head of the storm.

Selection to Report Disturbers will enable reporting on disturber events.

Watchdog Threshold

The external antenna is directly connected to the Analog Front-end (AFE), which amplifies and demodulates the received signal. The watchdog continuously monitors the output of the AFE and alerts the integrated lightning algorithm block in the event of an incoming signal.

The output signal of the AFE is monitored by the watchdog, which enables the signal validation (in case the input signal crosses a certain threshold. The AS3935 is automatically set back to Listening Mode once the Signal Validation block has made an assessment on the nature of the received signal (lighting or disturber). it is possible to change the level of this watchdog (increase number) threshold to increase the robustness to disturbers.   

If higher thresholds are used, the AS3935 would loose sensitivity for very far lightning events, with an improvement of the man-made disturber rejection as benefit.  Default of 3, range of 0-15.

Spike Rejection / Detection

The signal validation in the ThunderBoard AS3935 checks the shape of the received signal. In particular, the AS3935 can reject the impulse signals, like spikes, picked up by the antenna. The AS3935 has the ability to improve the spike rejection by increasing the number of the Spike Rejection register.  Larger valuescorrespond to more robust disturber rejection, with a decrease of the detection efficiency.   Default of 3, range 0-15/


Tuning Your ThunderBoard – The Video



The Thunder Board Lightning Simulator

You can buy the Thunder Board Lightning Simulator here.

Debugging Lightning Detectors has always been a problem.  You have to wait for a lightning storm.   To fix this problem, we have now developed a Lighting Simulator product. This board is a companion to the SwitchDoc Labs Thunder Board Lighting Detector.   This fully assembled and programmed product will generate simulated lighting on cue to test your lightning detection setup.

We use it regularly in house and are pleased to release this as a product.

We have just posted the software for the Thunder Board Lightning Simulator.


It comes with a fully assembled and programmed shield plugged into an Arduino Uno R3. Works out of the box.  USB to USB – Type A Cable for programming and power.


Here is what it does:

  • Far Lightning Strike (push Far Stk Button)
  • Mid-range Lightning Strike (push Mid Stk Button)
  • Close Lightning Strike (push Close Stk Button)

and three other lightning test modes:

  • Slow Timed Lightning Strike Mode – Every 5 minutes (push Far Stk and Mid Stk buttons together)
  • Fast Timed Lightning Strike Mode – Every 15 seconds (push Mid Stk and Close Stk buttons together)
  • Random Timed Lightning Strike Mode – From 30 seconds to 30 minutes (push all three buttons together)

You terminate the Time Strike modes by pushing any single button or by performing a power off or reset.

Note:   This lighting simulator is not very strong and might have to be held close to the Thunder Board Lightning Detector especially in the presence of cell phones, computers and monitors.   If you look at the Thunder Board Lightning Detector, you can see when the Lightning board picks up lightning when the Interrupt White LED blinks or lights up.

If you are having detection problems, move your whole test setup away from RFI (Radio Frequency Interference) sources.


In general, it cannot be stressed enough that while the Thunder Board will certainly let you know about electromagnetic pulses and its best guess about lightning distance, in real life storms do not generally hang around all the time ready for testing this module.  Also, rain clouds don’t necessarily mean lightning!  Be patient, use your SkyWeather system to record what happens over time and enjoy learning more about storm patterns in your geographical location.

The easiest way to test your Thunder Board and project is to purchase the Thunder Board Lightning Simulator from SwitchDoc Labs.  You can simulate far, mid and close lightning strikes.