Notes on the AS3935 Lightning Sensor

I finally got around to testing this sensor (two actually).  The AS3935 is IC sensor created by AustriaMicroSyetems.  There are a few breakout boards available out there with the chip installed.  The first one I got from Tautic on Tindie is no longer available.  The second breakout board I got was from PlayingWithFusion.  I never really got the Tautic board to work, hence my picking up the second.  I don’t know if it was a bad sample, or I cooked it when soldering on the pins.  All the sketches I ran on it, no matter what I did said the ‘noise floor was too high’.  I haven’t thrown it away, so I may have a go at resoldering the pins (in case one of the connections was wonky) and retrying sketches I know work on the Fusion board.  Ultimately, it would be cool to have two of them working and I could triangulate some kind of directional attribute.  Because they are using different capacitors and arrangement, it may not be a good idea.  If anything, two could eliminate false positives.

Now on to the Fusion board.  This board comes with a capacitor value in picoFarads, which you can apply to the sketch from the company’s website.  I tried the sketch that came from the company, and I got lots of local disturbers and no lightning indicators.  The terminology that is used with this board is ‘Disturber’ for a local man-made type of signal in 500kHz range.  The lightning algorithm also uses this frequency range, but filters and automatically identifies lightning over other signals.  It is not foolproof and there are many adjustments you can make through software registers.  If I were to rate this particular board version with AS3935 chip, I would say about 8 out of 10.  The reason I did not choose 9 or 10 is because I have gotten false positives.  Like I said, there are a bunch of adjustments one can make, and it may be that I need to step up a threshold (or two).  Thresholds for this chip are Watchdog, Spike Rejection, and Noise Floor values.

AS3935 with Olimexino

The connection for this particular board is SPI.  The difference between this board connections and the Tautic is for that one, you are supposed to connect SI to GND.  On the Fusion board it is connected to D9 on Arduino 328 type board.  The other connections are standard SPI.  IRQ is on pin D2 for the 328-based Arduino.

I have tried a number of sketches for this chip and the one that works (in my situation) is the one from ThunderAndLightning.  The automatic calibration may be the key.  It starts off the process with values zeroed out and finds the capacitor value closest to 500kHz.  I made a few modifications to work with my particular setup.  Since I had tried other libraries and sketches, I wanted this library to unique, so I changed header name and corresponding entries in the CPP file.

#include <SPI.h>
#include "TL_AS3935.h"
// #define A_MEGA_1280
#define A_PRO_MINI

Also, for the 328 Arduino, you want to insert interrupt as 1.  This line is an example:

AS3935IrqTriggered = 0;
attachInterrupt(1,AS3935Irq,RISING); // 1 for 328

I used the ‘Log’ sketch because I wanted to use Processing to access the chip and record the activity.  This sketch logs the activity as a CSV file.  I also hooked up a blue LED to indicate lightning.  The code for this is also in the script.  Change it to the pin you will use for your LED.

I must admit, I was surprised that about a half hour after I setup the board and ran the sketch, the blue LED flashed.  I looked at the CSV file and it actually recorded 2 strokes with a minutes time.  The interesting thing is, I am finding that it rarely signals a disturber, but is pretty good with indicating lightning.  I am in Florida and this summer there has been much rain and lightning – perfect testing ground for this.  As I mentioned before, I think I may have to tweak here and there – maybe the spike rejection or watchdog threshold.  I have had a few false positives.  Once I saw the blue LED flash and I went outside and there wasn’t a rain cloud in site.  Just small cumulus clouds scattered about.  the clue it was false was that it said 1Km away – so I couldn’t miss that if it was there.

All-in-all I am happy with this little sensor.

 

Posted under Sensors