AS3935 Lightning sensor

I have adapted the Arduino library for the Spark core here on my github. I compiles on the web IDE. All that is needed is for someone to test it. :slight_smile:

1 Like

Hello peekay. I would love to try it. But I don’t know where to start. Where do I upload those files to?
can you provide me step by step on how to do it? (I’m OK about wiring the AS3935.)
Sorry for this stupid question?
Thank You

I think I got it. I’ll keep you posted.

1 Like

redland, assuming you are using the web IDE, create a new “app” and name it “LightningDetector.ino” which is the name of the example program provided (in the example folder). Then create a new file “pair” using the add file button on the RHS of the build window. Name the file AS3595 and the IDE will supply the .cpp and .h extensions automatically. On github, copy and paste the code from the AS3595 files to the corresponding AS3595 files in the IDE (each is a tab). Don’t forget to save.

Finally, delete all the stuff in the LightningDetector.ino file tab and copy and paste the content from the github file of the same name (the example). Again, hit the save button. If all goes well, you can hit the verify button and you should have no errors. You can now send the code over the air to the core of your choice.

I flashed the core and it took it fine. It seems to work. But now how can I see it?
Thank You,

redland, you need to open a terminal window with the correct serial port selected. I am on Win 8 so I use Putty for that. Does that help you?

peekay, It WORKS!! Yay… It needs to be fine-tuned. But it works… I had to disable the: AS3935.enableDisturbers(); to make the detector work.


redland, great news! It’s obvious that it does not like Disturbers() to be enabled (huh!). :open_mouth:

1 Like

To test it. I use the Lightning Emulator.


Thank goodness it was an emulated storm! I was worried for a minute there.

Some of the buyers comments on Tindie make me think it is a bit fiddly to get set up right.

Excellent news peekay123, I’ll also be giving it a try on my Sparkcore. Thanks for the porting! I got mine from tindie; just arrived yesterday.

1 Like

Redland. Do you have to disable the AS3935.enableDisturbers() in all three files or just the LightningDetector.ino?

I’ve got the following error when I tried to compile it (even though I’ve followed peekay123’s instructions step by step):

AS3595.cpp:22:20: fatal error: AS3935.h: No such file or directory
compilation terminated.
make: *** [AS3595.o] Error 1

Sorry, worked it out… I had mixed up the AS3935 and AS3595…!

neal_tommy. Only in the LightningDtector.ino . Also I had to add AS3935.reset(); under two if statements. because if you don’t have it lets say you got a lightning at 10 kilometer and you get another one at 12 kilometer it shows the closest one (10) . Also if you get a Storm overhead, watch out! and the next one is 6 kilometers away still get the Storm overhead, watch out!. So for me by adding that, it fixed. I don’t know if that would be the right way to fixed it, but it worked. (-:

Thank You peekay​123 for helping us out!!!


Has anyone gotten this to work with I2C?

I always seem to get 0xFF from it when I try to read the device.

I am using the Embedded Adventures board with the default I2C settings.

I’m trying to work my way through this but I’m really lost and I’ve had a hard time finding information on the wiring for this. I see the IRQ and CS pins defined in peekay’s library for the object constructor but is that it? I’m guessing not. What about SDA/SDL/MISO? Any help would be greatly appreciated!

Update: I realized that the board that I was using from Embedded Adventures (MOD-1016) was configured for I2C so I re-soldered for SPI to use peekay123’s library but I’m still not having any luck:

Tuning out of range, check your wiring, your sensor and make sure physics laws have not changed!
Noise floor is: 7
Spike rejection is: 15
Watchdog threshold is: 15

Update2: In case someone else runs into the same hobbyist problem(s) that I did, this is the wiring that I eventually used successfully:

VCC  - 3V3
CS   - A2 (spi 1 ss)
IRQ  - A1
SCL  - A3 (1 sck)
MISO - A4 (1 miso)
MOSI - A5 (1 mosi)
1 Like

Hello @peekay123. Can it be possible, If I want to change the ports to the following of my new Photon?
Thank You!
VDD - 3.3V
IRQ - D5 (or any other valid pin)
CS - A4

@redland, at this time the library only supports hardware SPI using A3(SLCK), A4(MISO), A5(MOSI) and optionally, A2(SS). However, the code could be adapted to use software SPI so any pins could be used (albeit slower of course). Can you tell me why you cannot use the hardware SPI pins?