Raspberry Pi Lightning Detector - v1 and v2

Sorry, I forgot to add an image of the new current settings page. Please see attached.


Looking good!

I ordered one of those high cases. I’ll post on how it works out when it comes. The right angle connector looks promising. Nobody I could find carries them in the US. I contacted MikroElektronika support concerning the click shield and the need for +3.3V and +5V pin access for a fan. Their response was to return it for a refund. I believe it might be necessary to hook up a fan for the humidity, temp,etc. board.

pi3 click board and Thunder click are comming in 10 days from Mikroe US

maybe this can help to start things at boot

Thank you, that’s useful. I thought it would the the same or similar to the way I’d do it on Centos (the Linux OS I usually use) so it’s good to have an example to work from.

I need to implement proper logging in the web server so that we can see what’s going on when it runs as a service and also work out what to do with the pigpiod daemon. I don’t want to just start/restart it because it might be in use for other things, but I don’t know how to query it to see what else might be using it, or even if there’s a way to do that.

Another minor update to the web server (v1.2). This adds the CPU temperature onto the /current page to allow you to monitor your system to see if it needs a fan. This works on a Pi4 and I think it should work on a Pi3, but I’m not sure if it works on a Pi2. If there is hardware that it doesn’t work on I can add an config file option to disable it.

My current experience is that for a Pi running the AS3935 and Lightning Web Server then a fan probably isn’t needed. I don’t have a full case for my Pi yet but I covered it with a cardboard box about 15 hours ago which will trap the heat in probably much the same as a case would do. The box doesn’t have holes in it like a case though so it’s probably worse for retaining heat than a case. Ambient temp near the Pi is currently 21C and the Pi CPU is running at 54-57C. The Pi CPU is happy up to 82C where it starts to throttle before shutting down at 85C (at least that’s true for the Pi4…Pi2/3 owners would be advised to check the max CPU temperature for the board). So there’s a lot of headroom between the running temp and max temp. Even if the ambient temp was 20C higher it would still be running at below throttling temp. Of course a Pi mounted outside in full sun would be completely different, but I’m not sure if a fan would get the CPU temp low enough in those circumstances anyway!

To install the latest web server just upload the files to your Sensors directory and unzip (with the web server shut down first).


as3935_web_v1_2.zip (9.19 KB)

Chris, installed the temp upgrade to server, running around 51.5 to 52.5 C on the pi 3, no fan, lid off

I expect this to go up when the sun moves round this afternoon.

I received the Anidees Aluminum Extra High Pi case yesterday.

The Pi board installs in the bottom with 4 allen head screws (wrench included). The aluminum bottom cover has cooling slots. There’s ‘thermal’ tape for the 3 chips as the board rests against a cast aluminum plate above the board. The plate should be an excellent heat sink. There’s no room for finned heat sinks but they aren’t needed.

The click board is then installed in the top of the case. You can’t see the pins but you can see through the 2 unused mounting holes to the corresponding holes in the Pi board. The click board has 2 spacers meant to rest against the Pi board for stability. Since there’s now a cast aluminum plate between the click board and the Pi, the spacers are too long. I shortened the spacers with a Dremel tool to about 8mm and it’s now horizontal in the case.

Finally, the top smoke colored plexiglass cover fastens to the top with 4 allen head screws. As you can see in the pictures, they’ve provided 4 spacers for a air gap between the case an top cover.

There’s no provision for mounting a fan but ir shouldn’t be needed.

It was expensive but, to me, worth the cost.

Sorry about the quality of the pictures - kitchen lighting wasn’t great.

Hopefully I get it fired up this weekend.


More pictures…


That’s a nice looking case!

To administrator: thanks for your efforts for the python code and web server. I tried it with one of my detectors and confirm it is good. I also have an update for my allegedly failed AS3935. I have it connected to Arduino Nano (see attached photo). I used a procedure to find the most appropriate capacitor tune value and not use the one provided by the vendor. I found out the detector worked nicely in house (connected to my laptop) but didn’t detect any strike when placed outside to my RPi. When I enabled logging of all interrupts I found out it reads excessive noise. Obviously the installation spot is in the area with strong electromagnetic disturbances. Coming back to house, it’s working good again.
My next plan is to connect the Arduino to my laptop where WD runs. This way I’ll avoid copying the files and having an intermediate RPi. I’ll simply run a logging python script and generate nowcast.txt and my custom log files.

Re: few posts back - I log all the strikes to my daily log file (timestamp, distance, energy). Then I run a separate script that counts the number of strikes in a selected time frame (e.g. every 10 minutes or 1 hour) and generates a simple 2-column text file. I upload this file to web and use ‘plotly’ to generate a plot. Easy and lightweight.
I have a couple of weather stations and am using also other software to log the data. I attached an example of a lightning plot generated by another software. I find it useful since it nicely shows then the storm started and when it reached its maximum.
WD should be able to log the number of strikes in the last 1 minute (it already does it through nowcast.txt). From this value, we could reduce the time scale from 1 minute to something longer. I think majority is already available. But I like to manage these things myself.

On the fan topic: if a RPi is used only to log the data from AS3935, I don’t think one needs a RPi 4 but also a second hand RPi 2 is OK. I’m using it (2B) 24/7, taking one 5M photo every minute, collect pictures from 2 more RPi cameras over http, log air quality data and run several scripts (warning scripts; USB 4G dongle to send alerts via SMS, etc.) Sometimes the load average goes to ~1 but it never complains. It’s placed outside in a dry place, closed in a big plastic box.


hi Chris
i am getting this

^Cpi@raspberrypi:~/Sensors $ python3 as3935_web.py
Exception in thread Thread-2:
Traceback (most recent call last):
File “/usr/lib/python3.5/threading.py”, line 914, in _bootstrap_inner
self.run()
File “/usr/local/lib/python3.5/dist-packages/pigpio.py”, line 1213, in run
cb.func(cb.gpio, newLevel, tick)
File “as3935_web.py”, line 115, in register_strike
with open(strike_log_filename, ‘a’, newline=‘/n’) as logfile:
ValueError: illegal newline value: /n

not sure what this means

it set as debug false so not sure if i did something, last night i changed the power supply as i was getting flashing red led so was off a couple of times it had been ok upto that point, have attached the setting

Harold


Hi Harold

That’s a typo that’s crept in. In the line (115)…

…change the ‘/n’ to ‘\n’. The slash direction makes all the difference. It’s in code that I’ve not been able to test because I’ve not seen any real lightning yet.

Just to keep everyone up to speed…

I’m starting writing version2. I know version 1 hasn’t existed for long, but having reviewed what it’s become I’ve realised I took a wrong turning. The new plan is to split the lightning detection from the web server. There will be a service (background process) that simply handles the detection process and outputs the data into a file (or probably multiple files). There will then be a Pi web server that simply deals with displaying info rather that detecting lightning and displaying data. The file(s) created by the service process can then be used in a number of different ways, e.g. let WD grab nowcast.txt, or let the Pi web server display the data for ‘home’ use, or to upload to an ‘Internet web server’ to be displayed by a page/pages on that server.

Version 2 will also include the relevant scripts to start/auto-start/re-start the service processes and include a number of additional changes to make the whole thing more robust.

I don’t know how long v2 will take to complete, but v1_2 is still usable until it’s ready. I’ll upload v1_3 soon to fix the typo that Harold has found.

Hi Chris
Ah so it was not me then glad you found it and i await 1_3
not had any lightning here so i wonder what triggered the error

i just been converting a copy of the strike history log in excel to get the time and dates plus distances is there a reason why the date is a 10 digit number (which is seconds since 1/1/1970) rather than dd/mm/yyyy hh:mm:ss format

Harold

The time is a Unix epoch time - number of seconds since Jan 1st 1970. It’s easier and quicker to use than having to convert to/from dd/mm/yyyy hh:mm:ss when you want to do time calculations. I guess I could add both values to the file.

I also note those values are in GMT/UTC time

Unix epoch time is more or less UTC (see Unix time - Wikipedia) so it wouldn’t normally be translated into local time.

For the purposes of the software as it currently stands epoch time is all I needed to store. The stroke time is only used to calculate the number of seconds since ‘now’ to decide which bucket (1/5/10/20/30/60 minutes) the stroke should go into for nowcast.txt purposes and ‘now’ (actually time.now()) is epoch time.

If time zones and daylight savings time need to be included that would need to be something for version 2. They can be non-trivial to work with though!

My current thoughts are that the strike log file format will have to change in version 2 so be aware of that.

v1.3 is attached with the typo fixed that Harold found. There are no other changes so if you’re happy to make the change yourself in the file then you don’t need to download/upload/unzip this version.


as3935_web_v1_3.zip (9.19 KB)

can someone tell me where I setup WD to import NOWCAST?

Thanks

Setup->Advanced Settings->Rain/Wind/Barometer/Lightning (Nexstorm/Lightning2000)/Distrometer - Second box in the right hand column