AS3935 Lightning Detector for Raspberry Pi Homemade Weather Station

Hi All,
I have recently purchased a AS3935 Lightning Detector, and like to be able to upload it data to WD. At pressent I used Stationless CSV file to update WD sadly that does not include the option for using a AS3935 Lightning Detector.

These can produce data for a single strike, that details its distance and Energy and Disturber.
Firstly is there a way this data could be added to the end of the stationless CSV import?
For example the extra four fields could be Strikes & Disturber per minute, averaged distastance and energy calculated over the minute. And this data plotted in the lightning data graphs.

I have tried to make my own version of a NOWCast.txt

Lightning/2000 v6.6.2 NOWcast (Friday, June, 12, 2020 at 13:08:58 )
Assessment: Some nearby thundershowers (some nearby flashes)
9 strokes per minute
60 noises per minute
Energy of 31 in the last minute

Unfortunatly I not sure what data WD needs from a NOWCast.txt file to make it work with WD, and what the nowcast file data shows, I have searched the internet without any luck. So I made my best guess.

Personally I think the CSV option would be the simplest

Can any one help?
Michael

its not very clear if you are meaning you are using consolewd or WD (windows)

It would be great if it could be added to weather display for windows.

Michael

I have a Davis station and a standalone AS3935 lightning sensor. I used a WD’s function to read the “nowcast.txt” file. The AS3935 is connected to a Raspberry Pi which logs the strikes. I store the data (timestamp, distance, energy) in csv files on the Raspberry Pi.
I had a script that produced a nowcast.txt file which contained only the first row (number of strokes in the last minute, I think). WD downloaded this file once per minute and logged the strikes. However, the number of strikes WD logged did not match with the real number of strikes detected by the Raspberry Pi. I assume there was an issue somewhere in the WD. I did not dig any further since I had my log files and produced just statistics out of it for my webpage.
If you want I can check if I can dig out the python script that produced the nowcast.txt.

ah is in the astrogenics nowcast file?

I don’t know, I asked here on the forum and got a direction to google existing nowcast.txt file. I found my script (here is an excerpt):


	with open(datafile, "r") as f:
		filer = csv.reader(f)
    		for i in filer:
        		if (int(now_seconds)-int(i[1])) < 10801:
      	        		last3hr=last3hr+1
        		if (int(now_seconds)-int(i[1])) < 3601:
      	        		lasthr=lasthr+1
        		if (int(now_seconds)-int(i[1])) < 1801:
      	        		last30min=last30min+1
        		if (int(now_seconds)-int(i[1])) < 1201:
      	        		last20min=last20min+1
		        if (int(now_seconds)-int(i[1])) < 601:
			        last10min=last10min+1
        		if (int(now_seconds)-int(i[1])) < 301:
      	        		last5min=last5min+1
	        	if (int(now_seconds)-int(i[1])) < 61:
        	        	last1min=last1min+1

		last_strikes.write("%s | %s | %s\n" % (last1min,last10min,lasthr))
		last_strikes.close()
else:
	filename1=open(dir + "/strikes2.txt","w")
	filename1.write("0")
	filename1.close()

# Lightning2000 file format for Weather Display
# Implemented: May 27, 2018

light2000=open(filename3,"w")
light2000.write("%s strokes per minute\n" % last1min)
light2000.write("  %s strokes in past 5 mins. (avg. %s/min.)\n" % (last5min,round(float(last5min)/5,1)) )
light2000.write("  %s strokes in past 10 mins. (avg. %s/min.)\n" % (last10min,round(float(last10min)/10,1)) )
light2000.write("  %s strokes in past 20 mins. (avg. %s/min.)\n" % (last20min,round(float(last20min)/20,1)) )
light2000.write("  %s strokes in past 30 mins. (avg. %s/min.)\n" % (last30min,round(float(last30min)/30,1)) )
light2000.write("  %s strokes in past 60 mins. (avg. %s/min.)\n" % (lasthr,round(float(lasthr)/60,1)) )
light2000.close()

Final file looks like:


pi@weather1:~/scripts $ cat ../data/nowcast.txt 
0 strokes per minute
  0 strokes in past 5 mins. (avg. 0.0/min.)
  0 strokes in past 10 mins. (avg. 0.0/min.)
  0 strokes in past 20 mins. (avg. 0.0/min.)
  0 strokes in past 30 mins. (avg. 0.0/min.)
  0 strokes in past 60 mins. (avg. 0.0/min.)

Bonjour,
Je suis intéressé par ce détecteur. Povez6vous me donner un schéma de branchement avec le Raspberry et les modules.
Merci
Serge

THankyou every one for your help.

The extract of a python scipt looks help full, how ever I still unsure how to create the correct data that weather display can use.

I will contiue to search the internet for more info.
In the mean time , please continue to to post any useful help.

Note the sensor I’m using is made by DFRobot which costs a little over £23.00
The drivers are from https://github.com/DFRobot/DFRobot_AS3935 Which I am playing with.

Many thanks
Michael

Ok merci.

Bonjour Whimick,
Avez-vous un lien de référencement concernant ce détecteur contenant la visualisation de graphique des impacts de foudre ?
Merci
Serge

Hi All,

I have been playing with producing my own NOWCast.txt usig python3 and it looks like below, hoping that is the correct format for Weather Display to injest.
Sadley it does not work and no data is shown on the Lightning Counts Nextstorm Counts, but counts do show up on the 1wire graph. I do not use 1wire devices and so is not turned on.

What data format does Weather Display(Nextstorm) use, and does anyone have a working example if lighting date that works?
What exstra field are required?

Can any one offer me any more help?

NOWcast (Saturday, June, 20, 2020 at 14:18_54)

0 strokes per minute

0 Nearby flashes per minute

Energy of 0 in the last minute (ratio 0%, squelch = 0)

0 noises per minute (0.0%)

Thank you
Michael

Hi All,

I have reworked my Python3 script to produce NowCast.txt.

Sadlet Weather Display does not react it?

Could I be waisting my time?

Michael


NOWCast.zip (4.02 KB)

Merci.

I hope I can help, but please read through carefully.
My AS3935 is connected to a RPi at remote location but in same network as my laptop with WD. The lightning strikes are written into my logfiles in the following format: ,,
Every row represents one strike.

In my RPi I have a python script that runs every minute and analyzes the log file. It extracts the number of strikes in last minute, in the last 5, 10, 20, 30 and 60 minutes and generates a ‘nowcast.txt’ file. The file contains what I posted few posts above.

WD downloads the nowcast.txt file from my RPi to its c:\wdisplay\webfiles\ directory. In WD I enabled necessary option (Lightning2000) and pointed to the c:\wdisplay\webfiles\nowcast.txt file.

I attached fresh data from today. The storm is mild and just started hence just few strikes. But as the example shows, it works. You can see exact content of my nowcast.txt file and corresponding WD screen.
In the end, I don’t think WD ends up with same number of strikes as my logfiles but I didn’t investigate further.
I have a suggestion to Brian for much more simple logging but am not sure if this is of interest to larger public.


Hi mihec,

Thanks for your help, am I correct in thinking that your data only shows on the 1wire graph, which is what my version is/was also doing?
So guess nextstorm shows nothing.

Is there any chance of postong your python scripts?

Michael.

Here you go. The “20200625.log” is the source data logged by the detector. File format: ,,,
The “analyzeStrikes.py” script runs every minute and checks the daily log file (modify the path, etc.).

You can modify the “datafile=” line and simply enter the “20200625.log” file, then modify the path to “nowcast.txt” file.

Disclaimer: I’m not a software guy and the script could be written much better I guess. But for me it works fine.

Also, remove the “.txt” extensions from attached files.


20200625.log.txt (1.87 KB)

analyzeStrikes.py.txt (1.89 KB)

Thank you Mihec.

I will have a play and post my results in a few days

Hi all,

Thanks for help. I have been playing with making python3 scripts to monitor the AS3935 Lightning Detector.

To explain my setup at present I’m using two raspberry pi 3, both fitted with Grovepi boards. One Raspberry pi is the main weather station and feeds Weather Display.

The second has a the AS3935 Lightning Detector, and uses two python3 scripts.

DFRobot_AS3935_v06f_py.txt, monitors the Detector and generate 2 text files, NOWCast.txt:
NOWcast (Saturday, July, 04, 2020 at 14:46:33)

0 strokes per minute
0 noises per minute

Note that as far as I can see weatherdisplay only uses the first two lines, so I could not see the point af adding any extra lines.

The Lightning.txt just shows lightning strokes and noise, and used for reference only

The second script, lightning_transfer_py.txt, uses paramiko module to send the files to the first raspberry pi (Weather Station)

I hope these are useful.

Note I’m not a programmer so the scripts could be improved, please post any comments and examples.

Regards Michael


DFRobot_AS3935_v06f_py.txt (8.36 KB)

lightning_transfer_py.txt (1.73 KB)