Others detect DC to a high frequency.
I decided to have an amplifier from about l0 Hz to 100 kHz.
I added a monostable of 0.5 seconds to stop multiple detections
from one flash.
To interface to the arduino I use interrupts
Lightning can be detected at any time so this seemed the best option..
// simple program to show lightning sensor interface on arduino 2009
// int lightning will be updated on each lightning detection
//pin 3 causes an interupt and lightning_interupt runs
//at any time in the main program
volatile int lightning = 0;
const int interup_pin = 1; //this uses D3 as the interupt
void setup()
{
Serial.begin(9600); // initialize serial communication with computer
}
void loop()
{
delay(2000); //this is the main program working away
attachInterrupt(interup_pin, lightning_interupt, FALLING); //allow interupts
Serial.println(lightning); //main - here all we do is print the int
}
void lightning_interupt() //this program runs on interupt on pin D3
{
detachInterrupt(interup_pin); //disable interupts only need one(may bounce)
lightning +=1; //increment the int lightning
}
It's not really designed to prevent a full strike from reaching the house... but it does have a more direct path to earth ground than leaping through the opto. Most real world lightning protection for underground wiring is designed with sacrificial parts.
This is a nicely modified version of what Tim Bitson and others use to count strikes.
Mainly we are trying to keep large static voltages from our arduino.
This does not even need lightning. If you have wire antenna
you can get large static charges from clouds and even on
clear days a decent spark can be generated on ocassion.
pwillard - thanks
yes I do have Tim Bitson's book. It' been very usefull.
I tried his lightning circuit and it works fine.
Mine is more sensitive and stops multiple counts for single
strokes.
Just 2 days ago we had a massive ground strike not 200 m from
my house.
The strike was on a large 30 m high tree.
The explosion was spectular. Nothing was left of the tree except a stump.
We found parts of the tree some 100 m away.
It came out of the blue without any preceeding rumbles.
I lost my old desktop whick was connected at the time.
A good excuse to buy a new laptop.
Nextdoor lost a modem.
The arduino was connected at the time to the remote weather station but I was lucky there.
This is the first near miss after 15 years here so I hope it won't happen again for another 15 years.