Industrial manufacturing
Industrial Internet of Things | Industrial materials | Equipment Maintenance and Repair | Industrial programming |
home  MfgRobots >> Industrial manufacturing >  >> Manufacturing Technology >> Manufacturing process

Lightning Detection with Raspberry Pi and AS3935: A Practical Guide

Lightning can be detected using the electromagnetic pulse generated by a strike. The AS3935 Franklin Lightning Sensor IC from ams (Austria Mikro Systeme) offers a reliable, low‑cost solution that can sense lightning up to 40 km away, filter out electrical noise, and differentiate between cloud‑to‑ground and intra‑cloud events. In this tutorial we’ll show you how to integrate the AS3935 with a Raspberry Pi using I2C, calibrate the antenna, and access the sensor’s data through a ready‑made Python library.

Why the AS3935? The chip contains a proprietary algorithm that eliminates man‑made interference and estimates storm distance. It supports programmable detection thresholds, antenna tuning, and can be interfaced via SPI or I2C. Its 4 × 4 mm MLPQ‑16 package is compact, and the MOD‑1016 breakout board from Embedded Adventures simplifies wiring by providing pull‑ups, level shifting, and a convenient I2C interface.

Hardware Overview

The AS3935 requires only a power line, ground, two I2C lines (SDA & SCL), and an interrupt pin (IRQ). Using a breadboard and a Raspberry Pi Cobbler from Adafruit, the wiring is straightforward:

MOD‑1016 PinPi Connection
GNDGround (any GND pin)
VCC3.3 V (Pin 1)
IRQGPIO 17 (Pin 11)
SCLSCL (Pin 5)
SDASDA (Pin 3)

When using I2C, remember that the bus is designed for short‑range communication; the specification limits bus capacitance to 400 pF, which usually confines effective wiring to a few meters. If longer runs are necessary, consider an I2C extender or reduce the clock speed. When running the I2C lines over twisted pair, use separate pairs for SDA and SCL and tie the unused wire of each pair to ground to reduce crosstalk.

Before connecting the hardware, enable I2C on your Pi:

sudo apt-get install python-smbus i2c-tools
sudo modprobe i2c-bcm2708
sudo modprobe i2c-dev
echo "i2c-bcm2708
i2c-dev" | sudo tee -a /etc/modules

With the circuit assembled, verify the bus using i2cdetect. On a Pi with a newer I2C bus (bus 1) you would run:

sudo i2cdetect -y 1

The output should show the AS3935 at address 0x03 and any other I2C devices, such as the MS5611 at 0x76:

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          03 -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- 76 --

To communicate with the sensor you need to read and write its internal registers. Registers act like digital DIP switches; setting specific bits configures the sensor or clears internal counters. The AS3935 datasheet lists all register addresses and bit functions. While low‑level register manipulation is possible with i2cget, i2cdump, and i2cset, a higher‑level Python library simplifies the process. The RaspberryPi-AS3935 library by Phil Fenstermacher provides convenient methods and a demo script to get you started. Install it via pip or from the GitHub repository, then explore RPi_AS3935.py for available commands.

Calibration is critical because the AS3935 uses a parallel RLC antenna tuned to 500 kHz ± 3.5 %. The chip includes an internal 120 pF tuning capacitor that can be activated in 8 pF steps. The MOD‑1016 breakout indicates the external tuning capacitor value on its anti‑static bag, so you can simply call the library’s calibrate() method with that value. For deeper antenna design details, refer to the AS3935 AMS Hardware Design Guide.

With the sensor calibrated, you can start collecting lightning data, logging storm distance, and even trigger alerts when a strike is detected within your defined radius. This project is an excellent introduction to I2C, sensor interfacing, and real‑world signal processing.

Manufacturing process

  1. Build a Raspberry Pi Temperature Logger with a $5 I2C Sensor
  2. How to Read Temperature with a DS18B20 on Raspberry Pi 2
  3. Measuring Temperature on Raspberry Pi with Maxim 1‑Wire Sensors and DS2482 I2C Bridge
  4. Accurate Temperature Monitoring in a Server Closet with Raspberry Pi
  5. Build a 433 MHz Smart Home Controller with Sensorflare and Raspberry Pi
  6. Build a Headless Raspberry Pi 2 Water Alarm with Adafruit T‑Cobbler Plus
  7. Capturing IR Remote Commands on Raspberry Pi without LIRC: A Python UART Approach
  8. Installing a Raspberry Pi Camera in a Birdhouse – Step‑by‑Step Guide
  9. Build a Robot with Raspberry Pi and Python: A Complete Guide
  10. Build a Self‑Balancing Segway with Raspberry Pi