diff --git a/bbn_m5atomS3_lite_AS3935_lightning/bbn_m5atomS3_lite_AS3935_lightning.ino b/bbn_m5atomS3_lite_AS3935_lightning/bbn_m5atomS3_lite_AS3935_lightning.ino index 15c1845..a16c98a 100644 --- a/bbn_m5atomS3_lite_AS3935_lightning/bbn_m5atomS3_lite_AS3935_lightning.ino +++ b/bbn_m5atomS3_lite_AS3935_lightning/bbn_m5atomS3_lite_AS3935_lightning.ino @@ -4,6 +4,8 @@ // 0x03 is default i2c address, but the address can also be 0x02, 0x01. // Adjust the address jumpers on the underside of the product. +// C - SCL i2c clock +// D - SDL i2c data #define AS3935_ADDR 0x03 #define LIGHTNING_INT 0x08 #define DISTURBER_INT 0x04 @@ -12,21 +14,22 @@ SparkFun_AS3935 lightning(AS3935_ADDR); // Interrupt pin for lightning detection -const int lightningInt = G7; +const int lightningInt = G8; -byte noiseFloor = 2; -byte watchDogVal = 2; +byte noiseFloor = 4; +byte watchDogVal = 3; byte spike = 2; -byte lightningThresh = 1; +byte lightningThresh = 0; void setup() { auto cfg = M5.config(); AtomS3.begin(cfg); Serial.begin(4800); + Wire.begin(G2 /* SDL */, G1 /* SCL */, 100000UL); + pinMode(lightningInt, INPUT); // When lightning is detected the interrupt pin goes HIGH. - Wire.begin(); if (!lightning.begin(Wire)) { //Serial.println("Lightning Detector did not start!"); while (1); @@ -36,11 +39,11 @@ void setup() { lightning.setNoiseLevel(noiseFloor); lightning.watchdogThreshold(watchDogVal); lightning.spikeRejection(spike); - lightning.lightningThreshold(lightningThresh); + //lightning.lightningThreshold(lightningThresh); lightning.setIndoorOutdoor(INDOOR); //lightning.setIndoorOutdoor(OUTDOOR); - - //Serial.println("Lightning Detector did start!"); + + Serial.println("Lightning Detector did start!"); } void loop() { @@ -50,12 +53,14 @@ void loop() { uint8_t intVal = lightning.readInterruptReg(); if (intVal == NOISE_INT) { // Noise + //Serial.println("Noise Detected!"); } else if (intVal == DISTURBER_INT) { // Disturber + //Serial.println("Disturber Detected!"); } else if (intVal == LIGHTNING_INT) { - Serial.println("Lightning Strike Detected!"); + //Serial.println("Lightning Strike Detected!"); // Lightning! Now how far away is it? Distance estimation takes into // account any previously seen events in the last 15 seconds. gen_nmea0183_xdr("$BBXDR,D,%.0f,M,LIGHTNING_RANGE", (float)lightning.distanceToStorm() * 1000.0);