So it is an issue with the code, not my installation?
I seem to have the data being sent to MQTT, but nothing on the web page as per midenison.
Got it working by adding:
allow_anonymous true
to:
/etc/mosquitto/conf.d/websockets.conf
Thank you for finding that and giving us the answer. I didnāt know where the problem was but thatās mostly because I shelved the project during very quiet thunderstorm period. I have no way of testing without storms. Hopefully the increased solar activity might trigger some more lightning storms this year!
Just had the same issue, spent a week sorting this out to work and inject data into Weewx. A storm went past with very close strikes and nothing was detected. Really bummed here too. I wish there was a better way to test.
You sir are a genius
I had the same issue and this fixed it for me many thanks.
when i tried updating my Pi 4 a couple of months ago the lightning stopped working do not know why so currently powered off
I have a replacement Development Pi now and Iām currently rebuilding it so that I can put the Lightning software back on it. The Pi is on my network so now itās software load time.
EDIT:
I have the software installed and after making the following change (I assume a change to the MQTT server needs this) itās running as I remember it did.
So Iām back up and running, but also back to the point where was before the Pi hardware shortage hit, namely waiting for a thuderstorm. The nearest lightning seems to be about 400km away so well outside the sensor range. I wish I had a handheld unit that would be reliably detected as lightning! Properly testing the code is difficult without the ability to see lightning - real or fake.
Couple of months ago I updated my pi4 after that the lightning failed to work I suspect the update has upset thing and it probably need a fresh install but as it did not in my case pick up lightning on Christmas Eve that I got a picture of so decided to turn it off but may get back to it in the future when time and life allows
Iāve found a lightning simulator that can be used to test the AS3935 and other lightning detectors. Itās coming from halfway round the world (WA, USA) and itās not cheap but it will be good to be able to test the hardware and software. I suspect it might be a week or so before it arrives but Iāll let you know what I find when itās here.
One of our members had a Van de Graaff generator in his garage, but his website has been suspended. . .
I hope he wasnāt charged with electrocuting people!
It lives!
Weāve just had a thunderstorm but I missed the start of it. The power was off in the house yesterday and Iād not restarted the Pi thatās running the AS3935 software. I quickly got it up and running but there was only one strike that I know of after that. The AS3935 seems to have detected that one. All the false strikes Iāve ever seen have shown as 1km away. This strike was 5km away which was about the distance to the storm.
Lightning tester has arrived but I donāt think Iāll be able to properly test it for a few days because we have long-time friends in town to see us.
Chris,
Thank you for this fantastic walkthrough. Youāre the only SPI config of a lightning detector I can find, and itās awesome to have the apache and MQTT components as well. Iāve learned a lot in my failures to get this thing working!
Iām building the raspberry pi weather station project:
https://projects.raspberrypi.org/en/projects/build-your-own-weather-station
and adding a sparkfun lightning detector to it. I had to redo the wiring for the weather station to accommodate the SPI wiring of the lightning detector. For now, however, Iāve removed the lightning detector and put it on itās own breadboard with itās own raspberry pi (I bought them before covid, so they were cheaper then ). Everything seems to be working, exceptā¦ā¦ it doesnāt detect any lighting, disturbances, or noises!
Hereās the result of: sudo python3 as3935_pigpio_test.py 0:
And hereās the apache:
Iāve tried various permutations of bus and address in as3935_config.py, but I get a python error if I even try to change the bus to = 1, so I assume my bus needs to be 0. (Thatās how itās wired too!) Do you have any ideas of where I can go from here?
Thanks!
Chris
Hi Chris
Regarding bus - default is bus 0 and whilst the Pi can support two buses itās rare that youād need the second one so itās just there in case. You pigpio output looks reasonable. That means you probably have the correct address configured because the code seems to be able to access the AS3935 registers. You usually get all zeros if itās not able to see the sensor. Iām surprised that you get no detections thoughā¦whilst I donāt see strikes, I get loads of disturbers and quite a few noises.
Iām still looking into my own installation. The lightning simulator sometimes generates a strike, but not reliably, even when itās in the same place compared to the sensor. So Iām starting to go back to basics and trying to get some code working from another source to see if that more reliably recognises strikes. Despite the other code saying that it supports the SPI connection I get an error saying the sensor isnāt detected. So thatās slowed me down. I also need to find time to do a deeper dive and monitor the sensor pins whilst triggering a strike to see if I can see any difference in output. I want to check whether the sensor is sending an interrupt that isnāt being detected on the Pi for some reason.
I also want to modify the code to just continuously loop reading the registers in real time and looking for changed values. Thatās like doing the pin monitoringā¦seeing if the sensor is seeing strikes that arenāt being picked up for some reason.
So in summary, Iāve no ideas to help you right now but as soon as Iāve got something to go on Iāll let you know.
Hi Chris,
Appreciate the quick response, and thank you for continuing to look. If thereās anything I can do, especially code-wise, let me know. For your installation, is this faulty detection new? You wrote vās 1-3 as well, correct? Are you questioning the SPI setup? Were you I2C before?
As to my set up, I forgot to mention that I left my entire weather station setup on the old raspberry pi / breadboard with just the lightning detector header left, so I can easily move the lighting detector board back to the main set up easily when we solve this problem. The webpage readout is exactly as I published in my original question: meaning the headers are all there but so is the data as all zero strikes/noises. This implies that mosquitto is still running and reading nothing, just like in my new setup. So itās just not reading the board at all is my conclusion. That all said, if I switch in the configuration file to simulate strikes, I do get those:
Thanks again!
Chris
Good afternoon,
I tried v4 (and v3.2) on a RPi3 and both did not work.
I have:
From ChangeLog.txt:
4.1 - Released 10Sep2020
and the Thunderclip directly connected with wires 3.3V, GND, GPIO10, GPIO9, GPIO11, GPIO8 (see SPI at Raspberry Pi GPIO Pinout).
The test works:
pi@raspberrypi:~/Sensors $ sudo python3 as3935_pigpio_test.py
Test starting
Good version of pigpio found - Version 79
Register 0x00 is 0x24
Register 0x01 is 0x02
Register 0x02 is 0xC2
Register 0x03 is 0x04
Register 0x04 is 0xAA
Register 0x05 is 0xE0
Register 0x06 is 0x07
Register 0x07 is 0x3F
Register 0x08 is 0x0A
Test complete
But the calibration not!
pi@raspberrypi:~/Sensors $ sudo python3 calibrate_pig.py
Starting calibration run - Please wait approximately 16 seconds
calibration_run - At 0 pF 0.0 IRQs/sec with variance from ideal of -3906.2 ( -100.00 %)
calibration_run - At 8 pF 0.0 IRQs/sec with variance from ideal of -3906.2 ( -100.00 %)
calibration_run - At 16 pF 0.0 IRQs/sec with variance from ideal of -3906.2 ( -100.00 %)
calibration_run - At 24 pF 0.0 IRQs/sec with variance from ideal of -3906.2 ( -100.00 %)
calibration_run - At 32 pF 0.0 IRQs/sec with variance from ideal of -3906.2 ( -100.00 %)
calibration_run - At 40 pF 0.0 IRQs/sec with variance from ideal of -3906.2 ( -100.00 %)
calibration_run - At 48 pF 0.0 IRQs/sec with variance from ideal of -3906.2 ( -100.00 %)
calibration_run - At 56 pF 0.0 IRQs/sec with variance from ideal of -3906.2 ( -100.00 %)
calibration_run - At 64 pF 0.0 IRQs/sec with variance from ideal of -3906.2 ( -100.00 %)
calibration_run - At 72 pF 0.0 IRQs/sec with variance from ideal of -3906.2 ( -100.00 %)
calibration_run - At 80 pF 0.0 IRQs/sec with variance from ideal of -3906.2 ( -100.00 %)
calibration_run - At 88 pF 0.0 IRQs/sec with variance from ideal of -3906.2 ( -100.00 %)
calibration_run - At 96 pF 0.0 IRQs/sec with variance from ideal of -3906.2 ( -100.00 %)
calibration_run - At 104 pF 0.0 IRQs/sec with variance from ideal of -3906.2 ( -100.00 %)
calibration_run - At 112 pF 0.0 IRQs/sec with variance from ideal of -3906.2 ( -100.00 %)
calibration_run - At 120 pF 0.0 IRQs/sec with variance from ideal of -3906.2 ( -100.00 %)
Failure - minimum variance ( 100.00 %) > 3.5% of LCO frequency
Which brings me to the problem with āirq_cb.cancel()ā and āUnboundLocalError: cannot access local variable āirq_>āā. Do you think the device is working after even if the calibration does not work?
sudo systemctl status as3935_monitor.service
ā as3935_monitor.service - AS3935 Monitor service
Loaded: loaded (/lib/systemd/system/as3935_monitor.service; enabled; preset: enabled)
Active: active (running) since Sat 2024-08-17 19:16:41 CEST; 16min ago
Main PID: 2280 (python3)
Tasks: 3 (limit: 1557)
CPU: 19.656s
CGroup: /system.slice/as3935_monitor.service
āā2280 /usr/bin/python3 /home/pi/Sensors/as3935_monitor.py
āā2292 /usr/bin/python3 /home/pi/Sensors/as3935_monitor.py
Aug 17 19:16:59 raspberrypi python3[2281]: Process Process-1:
Aug 17 19:16:59 raspberrypi python3[2281]: Traceback (most recent call last):
Aug 17 19:16:59 raspberrypi python3[2281]: File "/usr/lib/python3.11/multiprocessing/process.p>
Aug 17 19:16:59 raspberrypi python3[2281]: self.run()
Aug 17 19:16:59 raspberrypi python3[2281]: File "/usr/lib/python3.11/multiprocessing/process.p>
Aug 17 19:16:59 raspberrypi python3[2281]: self._target(*self._args, **self._kwargs)
Aug 17 19:16:59 raspberrypi python3[2281]: File "/home/pi/Sensors/as3935_monitor.py", line 180>
Aug 17 19:16:59 raspberrypi python3[2281]: irq_cb.cancel()
Aug 17 19:16:59 raspberrypi python3[2281]: ^^^^^^
Aug 17 19:16:59 raspberrypi python3[2281]: UnboundLocalError: cannot access local variable 'irq_>
lines 1-20/20 (END)
I think nobody else is seeing this error as long as the calibration is working =).
Thank you in advance,
BR
HoWil
Itās a while since I looked at this so I suspect the code needs updating to reflect OS and other software changes.
Despite it being near the sunspot maximum weāve had very few thunderstorms here this year so I hadnāt been giving this project much thought. Iāll try to take another look at it soon, but Iāll need to āborrowā a Raspberry Pi from another project first!