PlayingWithFusion.com Home


0 Items
View shopping cart itemsView Cart

Document: 1221
Posted: April 27, 2025
Modified: April 27, 2025

Home > Tech Article Categories > R3actor and Arduino > AS3935 Lightning Sensor Testing

AS3935 Lightning Sensor Testing

Test the response of the AS3935 digital lightning sensor with the digital lightning sensor tester.

Introduction

SEN-39003 is a breakout module for the AS3935 lightning detector, which estimates the distance to the head of an approaching storm based on lightning strike proximity. Each board is shipped fully calibrated with the values provided. Even still, it is advisable to test the module before implementing it. To facilitate this, we also offer a lightning sensor tester. This document will walk you through using the tester to validate your system.

SEN-39003 Qwiic Digital Lightning Sensor AS3935 SPI and I2C Breakout Kit
 Image

Hardware Setup

For this project, you will need:

  • (x1) SEN-39003 Qwiic Digital Lightning Sensor
  • (x1) SEN-39002 Digital Lightning Sensor Tester Arduino Shield
  • (x1) Arduino Uno
  • (x1) Additional Microcontroller (Arduino Uno, R3aktor, etc.)
  • (x2) USB cables
  • Breadboard Jumper Cables
  • (x1) Solderless Breadboard
  • (x1) Ruler

Arduino Uno Schematic

R3aktor Schematic

The diagrams above show how to connect the AS3935 lightning sensor to both a R3aktor and an Arduino Uno for I2C communication. For Serial communication, follow the same schematic, but connect the MOSI, MISO, and SCK pins to their respective labeled microcontroller pins instead of the SDA and SCL pins for I2C.

Connect the lightning emulator to the Arduino Uno.

Software Setup

Follow this link to the Playing with Fusion GitHub page for the lightning sensor tester. Download the zip file.

Unzip the folder and open the .ino file for the tester.

Follow this link to the Playing with Fusion GitHub page for the lightning sensor I2C. Download the zip file.

Extract the zip file to your Arduino IDE libraries folder. If you are not sure where this is, within the Arduino IDE, go to File -> Preferences. The sketchbook path location will be shown. This is the folder in which you can find the libraries folder.

Rename the root folder to PWFusion_AS3935_I2C (get rid of the -master at the end of the folder name).

Within this folder, open the .ino file in the examples folder.

Modify Software

Open the lightning sensor Arduino .ino file. The most critical modification is to add the correct sensor calibration value. We provide this value for every shipped lightning sensor. Set the AS3935_CAPACITANCE variable to the value provided. You can also modify the AS3935_LOCATION variable depending on where the sensor will be located (indoors or outdoors) during operation. A distance unit of miles or kilometers can also be selected by changing the AS3935_DIST_UNIT variable. After making these changes, upload the code to the microcontroller.

Open the lightning emulator .ino file. Before uploading, the only thing to modify here is to decide how you want to test. Set the MANUAL_TEST variable to 1 to trigger lightning strikes with a button press, or set AUTOMATIC_TEST to 1 and MANUAL_TEST to 0 to run an automated test. After making these changes, upload the code to the Arduino Uno.

Test

 

With the lightning sensor microcontroller connected to the Arduino IDE, open the serial monitor. Make sure to set it to 115200 baud.

Set up the lightning sensor and emulator to be about 15 cm apart. If using the manual testing method, press the buttons to trigger simulated strikes at a far, mid, or close distance. The serial monitor will display the estimated distance to the storm front. You may notice that the calculated distance remains the same when triggering a close strike and then a far strike. Don't panic, this is the intended response. Check out our YouTube channel for a video on why this happens.

Electronic devices such as smartphones or laptops can impact the lightning sensor's readings. Keep these devices about a foot from the testing area to avoid unwanted interference.

Related Products