The SparkFun AS3935 Lightning Detector is a sophisticated integrated circuit (IC) designed to detect the presence of lightning activity within a specified range. This component is capable of distinguishing between distant and potential storm lightning strikes, providing an estimation of the distance to the head of the storm. It is commonly used in weather stations, golf carts, personal handheld devices, or any application where early detection of lightning strikes is beneficial.
Pin Number | Name | Description |
---|---|---|
1 | VDD | Power supply (2.4V to 5.5V) |
2 | GND | Ground connection |
3 | SI | SPI/I2C selection pin |
4 | IRQ | Interrupt request (active low) |
5 | SCL | SPI clock / I2C serial clock |
6 | SDA | SPI data / I2C data |
7 | CS | SPI chip select (active low) |
8 | A0 | I2C address selection pin |
Q: Can the AS3935 detect the direction of the storm? A: No, the AS3935 can only provide the estimated distance to the storm, not its direction.
Q: Is the AS3935 waterproof? A: The AS3935 IC itself is not waterproof. It requires proper casing or enclosure if used in outdoor applications.
Q: How can I adjust the sensitivity of the detector? A: Sensitivity settings can be adjusted through the registers of the AS3935. Refer to the datasheet for specific register settings.
Below is an example code snippet for initializing the AS3935 Lightning Detector with an Arduino UNO using the I2C communication protocol. Ensure you have the appropriate library installed for the AS3935.
#include <Wire.h>
#include <SparkFun_AS3935.h>
// Create an instance of the AS3935 library
SparkFun_AS3935 lightning;
void setup() {
Wire.begin(); // Initialize I2C
Serial.begin(9600); // Start serial communication at 9600 baud
// Initialize the lightning detector
if (lightning.begin(Wire, 0x03) == false) {
Serial.println("AS3935 not detected");
while (1);
}
// Set the indoor/outdoor mode
lightning.setIndoorOutdoor(INDOOR);
// Set the noise floor level
lightning.setNoiseFloor(2);
// Enable disturber detection
lightning.watchdogThreshold(2);
lightning.spikeRejection(2);
// Set the minimum number of lightning strikes before interrupt is triggered
lightning.lightningThreshold(5);
// Calibrate the internal oscillators
lightning.calibrateOsc();
}
void loop() {
// Check if the IRQ pin is low, indicating an event
if (digitalRead(IRQ_PIN) == LOW) {
// Read the interrupt register to determine the cause of the IRQ
int intVal = lightning.readInterruptReg();
if (intVal == NOISE_LEVEL_TOO_HIGH) {
Serial.println("Noise level too high");
} else if (intVal == DISTURBER_DETECTED) {
Serial.println("Disturber detected");
} else if (intVal == LIGHTNING_DETECTED) {
Serial.println("Lightning detected");
// Get the estimated distance to the head of the storm
int distance = lightning.distanceToStorm();
Serial.print("Distance to storm: ");
Serial.println(distance);
}
}
}
Remember to define IRQ_PIN
to the digital pin number connected to the IRQ pin of the AS3935. Adjust the settings such as indoor/outdoor mode, noise floor, and watchdog threshold according to your specific application needs.