Raspberry Pi Lightning Detector - Version 3.2

In http://discourse.weather-watch.com/p/542238 you said…

starting pigpiod fails with: Code: [Select] sudo pigpiod 2020-07-28 20:37:00 initInitialise: bind to port 8888 failed (Address already in use) pi@thunder:~ $ Can't initialise pigpio library

Are you still seeing this error?

Can you also run ‘sudo python3 as3935_pigpio_test_X.py’ from the Sensors directory with ‘X’ as the socket you have the Thunder Click board plugged into (1 or 2) and post the output in a message.

The empty nowcast.json file suggests that the monitor is/has been running but as it’s not getting any data from the sensor the file is empty.

ahh, sorry my bad…
Yes, still that error from pigiod

The output of test:

Test starting
Good version of pigpio found - Version 77
Register 0x00 is 0x24
Register 0x01 is 0x01
Register 0x02 is 0xC2
Register 0x03 is 0xC0
Register 0x04 is 0x00
Register 0x05 is 0x00
Register 0x06 is 0x00
Register 0x07 is 0x01
Register 0x08 is 0x0A
Test complete

This is all on a Pi3 with Buster lite installed
no full raspberry pi OS

no pigpiod.service no pigpiod service after manual install in "/run/pigpio_spi_handles" there was only a zero, so I did stop every service and deleted the file then started pigpiod and the monitor service the zero was back there in the zero was the number 2975

I spoke too soon.

I rebooted the Pi and now both services fail with an error.

Server Service

Jul 28 16:50:04 WeatherPi systemd[1]: Started AS3935 Monitor service.
Jul 28 16:50:06 WeatherPi python3[678]: Traceback (most recent call last):
Jul 28 16:50:06 WeatherPi python3[678]:   File "/home/pi/Sensors/as3935_monitor.py", line 53, in <module>
Jul 28 16:50:06 WeatherPi python3[678]:     as3935 = RPi_AS3935(address=int(config.get('as3935', 'address', fallback=1), 0), bus=config.getint('pi', 'bus', fallback=0), mode=0b10, speed=400000)
Jul 28 16:50:06 WeatherPi python3[678]: TypeError: int() can't convert non-string with explicit base
Jul 28 16:50:07 WeatherPi systemd[1]: as3935_monitor.service: Main process exited, code=exited, status=1/FAILURE
Jul 28 16:50:07 WeatherPi systemd[1]: as3935_monitor.service: Failed with result 'exit-code'.

Web Service

Jul 28 16:50:07 WeatherPi python3[679]: Traceback (most recent call last):
Jul 28 16:50:07 WeatherPi python3[679]:   File "/home/pi/Sensors/as3935_web.py", line 52, in <module>
Jul 28 16:50:07 WeatherPi python3[679]:     app.config['SECRET_KEY'] = config.get('interface','secret_key')
Jul 28 16:50:07 WeatherPi python3[679]:   File "/usr/lib/python3.7/configparser.py", line 780, in get
Jul 28 16:50:07 WeatherPi python3[679]:     d = self._unify_values(section, vars)
Jul 28 16:50:07 WeatherPi python3[679]:   File "/usr/lib/python3.7/configparser.py", line 1146, in _unify_values
Jul 28 16:50:07 WeatherPi python3[679]:     raise NoSectionError(section) from None
Jul 28 16:50:07 WeatherPi python3[679]: configparser.NoSectionError: No section: 'interface'
Jul 28 16:50:07 WeatherPi systemd[1]: as3935_web.service: Main process exited, code=exited, status=1/FAILURE
Jul 28 16:50:07 WeatherPi systemd[1]: as3935_web.service: Failed with result 'exit-code'.

sudo apt-get update
sudo apt-get install pigpio python-pigpio python3-pigpio
sudo systemctl enable pigpiod.service
pigpiod -v
sudo systemctl start pigpiod.service
sudo systemctl status pigpiod.service

Version is 77

It is late now, going to bed and try tomorrow with a fresh install
I will comment out the making of.
More tomorrow.

pinto and Asobig - can you please try the following…

  1. ‘sudo nano /lib/systemd/system/pigpiod.service’.

  2. Put this into the file and then save it…

[Unit]
Description=Daemon required to control GPIO pins via pigpio
[Service]
ExecStart=/usr/bin/pigpiod -l
ExecStop=/bin/systemctl kill pigpiod
Type=forking
[Install]
WantedBy=multi-user.target
  1. ‘sudo systemctl daemon-reload’
  2. ‘sudo systemctl enable pigpiod.service’
  3. ‘sudo systemctl start pigpiod.service’
  4. ‘sudo systemctl restart as3935_monitor.service’
  5. ‘sudo systemctl restart as3935_web.service’

I still don’t understand why the pigpiod service unit file isn’t being created but this should get you going whilst I investigate further. Worst case I’ll create the unit file in the installer but I don’t understand why installing pigpio doesn’t create the unit file for you but it does for me.

pinto - depending on the state of the various services it is correct that there can be number files in /run/pigpio_spi_handles where the file contains a process number. If you try ‘ps ax | grep ’ where <process_number> is the value from one of the number files you should see which process has which SPI handle open. I’ve had to build in some extra coding because SPI handles weren’t being tidied up cleanly when processes got killed/died unexpectedly and the number files are part of the cleanup process.

Can you please PM me the contents of your as3935_monitor.config and as3935_web.config files.

Bedtime for me now, but I’ll check on things in the morning and try to get problems resolved ASAP.

Hey Chris,

Never mind.

The editor I used stuck a .xml on the end of both files. It works perfectly when that’s deleted :oops:

No problem. I had a suspicion that there was something wrong with the file format and I’m glad that my hunch was correct.

I’m part way there to fixing the problem with the pigpiod.service file being missing. I now know why but still need to figure out how to make it available for everyone.

The first part of the puzzle was caused by a combination of a misunderstanding and a difference. I discovered pigpio whilst trying to work out how to program the AS3935 sensor. It seemed to do what I wanted so I installed the version compatible with my Pi4B. What I’d misunderstood was that pigpio is already included in some Raspberry Pi OS (and Raspbian OS) builds. I now know that it is included in the ‘Desktop plus recommended software’ build that I use and that it isn’t included in the Lite build. I’m not sure if it’s in the ‘Desktop (without recommended software)’ build. So in reality I had installed pigpio on top of an existing version. That’s where the difference came in. The pre-installed version includes the pigpiod.service file but when you build the software to install for yourself the file isn’t included. So my Pi had the pigpiod.service file from the build and the updated software from my own installation. The AS3935 installers only do the second part of this, i.e. build pigpiod, and when run on a Pi OS build that doesn’t include pigpiod it doesn’t have the service file.

I don’t know why the pre-installed and self-built versions differ, but my next job is to figure out how to fix the problem. I initially thought that would be simple, but this morning I’ve discovered that the pre-installed and built versions of pigpiod end up in different directories so there isn’t a ‘one size fits all’ service file that I can include in the installer. I’ll figure it out but I need some breakfast and a good old mug of British tea inside me first!

Good morning, new day.

I tried the above steps and got no errors, but no data on the website.

Last entries monitor log:

2020-07-29,07:09:03.660 : as3935_monitor - as3935_processing - INFO: Starting as3935_monitor
2020-07-29,07:09:03.660 : as3935_monitor - as3935_processing - INFO: Tuning capacitor set to 24pF
2020-07-29,07:09:03.660 : as3935_monitor - as3935_processing - INFO: Initial noise floor is set to 0
2020-07-29,07:09:03.661 : as3935_monitor - as3935_processing - INFO: Location is set to indoors
2020-07-29,07:09:03.661 : as3935_monitor - as3935_processing - INFO: Mask disturbers is False
2020-07-29,07:09:03.661 : as3935_monitor - as3935_processing - INFO: Miniumum strikes for detection is 1
2020-07-29,07:09:10.089 : as3935_monitor - register_event - ERROR: Unknown reason in register_event() - 0
2020-07-29,07:09:29.330 : as3935_monitor - register_event - ERROR: Unknown reason in register_event() - 0
2020-07-29,07:09:45.093 : as3935_monitor - register_event - ERROR: Unknown reason in register_event() - 0
2020-07-29,07:09:50.539 : as3935_monitor - register_event - ERROR: Unknown reason in register_event() - 0
2020-07-29,07:09:56.838 : as3935_monitor - register_event - ERROR: Unknown reason in register_event() - 0

Last entries web log:

2020-07-29,07:09:00.760 : as3935_web - <module> - DEBUG: Web server setup complete
2020-07-29,07:09:00.768 : as3935_web - <module> - INFO: Starting web server
2020-07-29,07:09:01.871 : as3935_web - connected - DEBUG: Socketio connection created
2020-07-29,07:09:08.675 : as3935_web - connected - DEBUG: Socketio connection created
2020-07-29,07:09:13.058 : as3935_web - connected - DEBUG: Socketio connection created

Just did a new install as discripted on page one, and got a working website with data showing!
No errors or warnings.

But i don’t dare to restart :oops:


I think you should be OK with a restart. The fix you applied before the re-install is still there and that’s what’s allowing it to work.

I’m just about to do an install of v3.1 onto a fresh OS build to test it before releasing. It should solve the pigpiod.service problems you and others have seen and I’ve also modified the installer and other scripts to use a command line parameter for the Thunder Click socket number to reduce the number of files needed by 3. Once I’ve tested the new version I’ll upload and modify the installation instructions.

Nope, it is gone again…
After the reboot of the PI i only got a website with connected.


Forget my post.

The site is still working!!! :lol: :smiley:

That’s good to hear!

My Pi is still upgrading (56% now) so I’ll be able to test v3.1 soon and hopefully that will fix the problem at source rather than trying to put sticking plasters onto it.

I’ve installed v3.1 and it worked on first install and after a reboot. I have to go out to an appointment now but I’ll upload the new version and update the docs when I return.

I’ve updated the top message in this thread to remove the v3.0 files and add the v3.1 files.

I’ve also changed the instructions. They are subtly different so please read them carefully and don’t repeat the previous installation process because it may not work properly, especially if your Thunder Click board is plugged into socket 2!

on Raspberry Pi OS lite new installation
install python3-pip
:smiley:

So it looks like everyone so far is up and running with either v3.0, tweaked v3.0 or v3.1?

Now we just need some lightning!