Gravity: Lightning Sensor employs AMS innovative AS3935 Franklin lightning sensor IC and Coilcraft MA5532-AE dedicated antenna to detect lightning distance, intensity, and frequency within a radius of 40km both indoors or outdoors.

The embedded man-made disturber rejection algorithm can effectively avoid the electrical interference generated by various household appliances. In addition to allowing general weather enthusiasts to measure local thunderstorm data simply and efficiently, thanks to its compact size and wide detection range, it can also be embedded in various smart wearable devices for outdoor climber or people who work at heights. This provides early warning of thunderstorms that people can perceive, so that people can take precautions a step ahead. The sensor can also be embedded in the indoor protection device inside lightning-sensitive equipment, and automatically trigger these devices to switch to the backup power to isolate the power grid when lightning strikes. At the moment of lightning, the interrupt pin IRQ generates a pulse. This can be used to trigger the shutter to open, helping photographers to accurately capture the exciting moment of lightning.



Board Overview

No. Label Description
1 VCC Power VCC(3.3~5.5V)
2 GND Power GND
3 SCL I2C clock signal
4 SDA I2C data signal
5 ADDR I2C address DIP switch
6 IRQ Lightning alarm interrupt pin
7 PWR Power indicator (red)

About Lightning Distance and Intensity Estimation

No. Distance (km)
1 40
2 37
3 34
4 31
5 27
6 24
7 20
8 17
9 14
10 12
11 10
12 8
13 6
14 5
15 Storm is Overhead!

Arduino Tutorial

This tutorial presents a basic usage of the module with Arduino UNO.


Connection Diagram

Sample Code

   file DFRobot_AS3935_lightning_I2c.ino

   SEN0290 Lightning Sensor
   This sensor can detect lightning and display the distance and intensity of the lightning within 40 km
   It can be set as indoor or outdoor mode.
   The module has three I2C, these addresses are:
   AS3935_ADD1  0x01   A0 = High  A1 = Low
   AS3935_ADD2  0x02   A0 = Low   A1 = High
   AS3935_ADD3  0x03   A0 = High  A1 = High

   Copyright    [DFRobot](, 2018
   Copyright    GNU Lesser General Public License

   version  V0.2
   date  2018-10-08

#include "I2C.h"
#include "DFRobot_AS3935_I2C.h"

volatile int8_t AS3935_ISR_Trig = 0;

#define IRQ_PIN              2

// Antenna tuning capcitance (must be integer multiple of 8, 8 - 120 pf)
#define AS3935_CAPACITANCE   96

// Indoor/outdoor mode selection
#define AS3935_INDOORS       0
#define AS3935_OUTDOORS      1
#define AS3935_MODE          AS3935_INDOORS

// Enable/disable disturber detection
#define AS3935_DIST_DIS      0
#define AS3935_DIST_EN       1
#define AS3935_DIST          AS3935_DIST_EN

// I2C address
#define AS3935_I2C_ADDR       AS3935_ADD3

void AS3935_ISR();

DF_AS3935_I2C  lightning0((uint8_t)IRQ_PIN, (uint8_t)AS3935_I2C_ADDR);

void setup()

  Serial.println("DFRobot AS3935 lightning sensor begin!");

  // Setup for the the I2C library: (enable pullups, set speed to 400kHz)

  // Set registers to default
  // Configure sensor
  lightning0.AS3935_ManualCal(AS3935_CAPACITANCE, AS3935_MODE, AS3935_DIST);
  // Enable interrupt (connect IRQ pin IRQ_PIN: 2, default)

  //  Connect the IRQ and GND pin to the oscilloscope.
  //  uncomment the following sentences to fine tune the antenna for better performance.
  //  This will dispaly the antenna's resonance frequency/16 on IRQ pin (The resonance frequency will be divided by 16 on this pin)
  //  Tuning AS3935_CAPACITANCE to make the frequency within 500/16 kHz ± 3.5%
  //  lightning0.AS3935_SetLCO_FDIV(0);
  //  lightning0.AS3935_SetIRQ_Output_Source(3);

  attachInterrupt(0, AS3935_ISR, RISING);


void loop()
  // It does nothing until an interrupt is detected on the IRQ pin.
  while (AS3935_ISR_Trig == 0) {}

  // Reset interrupt flag
  AS3935_ISR_Trig = 0;

  // Get interrupt source
  uint8_t int_src = lightning0.AS3935_GetInterruptSrc();
  if (int_src == 1)
    // Get rid of non-distance data
    uint8_t lightning_dist_km = lightning0.AS3935_GetLightningDistKm();

    if (lightning_dist_km == 1) {
      Serial.println("Lightning overhead!");
    else if ((lightning_dist_km >= 5) && (lightning_dist_km <= 40)) {
      Serial.println("Lightning occurs!");
      Serial.print("Distance: ");
      Serial.println(" km");
    else if (lightning_dist_km == 0x3F){
      Serial.println("Out of range.");

    // Get lightning energy intensity
    uint32_t lightning_energy_val = lightning0.AS3935_GetStrikeEnergyRaw();
    Serial.print("Intensity: ");
  else if (int_src == 2)
    Serial.println("Disturber discovered!");
  else if (int_src == 3)
    Serial.println("Noise level too high!");


//IRQ handler for AS3935 interrupts
void AS3935_ISR()
  AS3935_ISR_Trig = 1;


Raspberry Pi Tutorial

This tutorial presents a basic usage of the module with Raspberry Pi.


Connection Diagram


pi@raspberrypi:~ $ sudo raspi-config
pi@raspberrypi:~ $ sudo apt-get update
pi@raspberrypi:~ $ sudo apt-get install build-essential python-dev python-smbus git
pi@raspberrypi:~ $ git clone
pi@raspberrypi:~ $ cd ~/DFRobot_AS3935/RaspberryPi/python
pi@raspberrypi:~/DFRobot_AS3935/RaspberryPi/python $ python

Run Sample Code

pi@raspberrypi:~/DFRobot_AS3935/RaspberryPi/python $ cd readAndInt
pi@raspberrypi:~/DFRobot_AS3935/RaspbeeryPi/python/readAndInt $ python



For any questions, advice or cool ideas to share, please visit the DFRobot Forum.

More Documents

DFshopping_car1.png Get SEN0290 Gravity: Lightning Sensor from DFRobot Store or DFRobot Distributor.

Turn to the Top