Trying to gee AS3935 to work with weewx 4.5.1

291 views
Skip to first unread message

philip....@gmail.com

unread,
Jul 26, 2021, 3:46:04 PM7/26/21
to weewx-user
Have a new install of weewx installed (4.5.1)  on a Raspberry Pi and using the Simulator driver loaded  the zip file from as3935 · weewx/weewx Wiki · GitHub with no problems

Stopped and Started weewx but will not start now.
Jul 26 20:27:08 raspberrypi weewx[1651]: Starting weewx weather system: weewx.
Jul 26 20:27:08 raspberrypi systemd[1]: Started LSB: weewx weather system.
Jul 26 20:27:08 raspberrypi weewx[1666] CRITICAL __main__: Caught unrecoverable exception:
Jul 26 20:27:08 raspberrypi weewx[1666] CRITICAL __main__:     ****  invalid syntax (as3935.py, line 233)
Jul 26 20:27:08 raspberrypi weewx[1666] CRITICAL __main__:     ****  Traceback (most recent call last):
Jul 26 20:27:08 raspberrypi weewx[1666] CRITICAL __main__:     ****    File "/home/weewx/bin/weewxd", line 151, in main
Jul 26 20:27:08 raspberrypi weewx[1666] CRITICAL __main__:     ****      engine = weewx.engine.StdEngine(config_dict)
Jul 26 20:27:08 raspberrypi weewx[1666] CRITICAL __main__:     ****    File "/home/weewx/bin/weewx/engine.py", line 93, in __init__
Jul 26 20:27:08 raspberrypi weewx[1666] CRITICAL __main__:     ****      self.loadServices(config_dict)
Jul 26 20:27:08 raspberrypi weewx[1666] CRITICAL __main__:     ****    File "/home/weewx/bin/weewx/engine.py", line 161, in loadServices
Jul 26 20:27:08 raspberrypi weewx[1666] CRITICAL __main__:     ****      obj = weeutil.weeutil.get_object(svc)(self, config_dict)
Jul 26 20:27:08 raspberrypi weewx[1666] CRITICAL __main__:     ****    File "/home/weewx/bin/weeutil/weeutil.py", line 1119, in get_object
Jul 26 20:27:08 raspberrypi weewx[1666] CRITICAL __main__:     ****      mod = __import__(module)
Jul 26 20:27:08 raspberrypi weewx[1666] CRITICAL __main__:     ****    File "/home/weewx/bin/user/as3935.py", line 233
Jul 26 20:27:08 raspberrypi weewx[1666] CRITICAL __main__:     ****      except Exception, e:
Jul 26 20:27:08 raspberrypi weewx[1666] CRITICAL __main__:     ****                      ^
Jul 26 20:27:08 raspberrypi weewx[1666] CRITICAL __main__:     ****  SyntaxError: invalid syntax
Jul 26 20:27:08 raspberrypi weewx[1666] CRITICAL __main__:     ****  Exiting.

In weewx.conf under
[Engine]
[[Services]]
process_services =  , user.as3935.AS3935  (This was added)

If I remove  user.as3935.AS3935 from process_services weewx will start OK but the AS3935 does not add anything to the database.

The AS3935.py is version 6
Just wondered what I have missed.
Thanks for any help
Phil

vince

unread,
Jul 26, 2021, 4:42:19 PM7/26/21
to weewx-user
See https://github.com/weewx/weewx/wiki/faq-python-error

You have a variety of options:
  • find a later version of the driver/extension that supports python3
  • patch your copy to be python3 compliant using 2to3
  • use python2 for your installation
In your particular case it looks like the second option is pretty trivial.

Change the offending line to be
     except Exception as e:

And see if that works ok...

philip....@gmail.com

unread,
Jul 27, 2021, 5:51:04 AM7/27/21
to weewx-user
Thanks Vince
Changed Line 233 to except Exception as e:
It then moved to Line 73 === no such module but sudo pip3 install RPi_AS3935 seems to have cured that (Installed ver 0.2.0 OK)
Now it stuck on Line 153 'object not callable. (address=addr, bus=bus)  
In weewx.conf I have
[AS3935]
address = 3
bus = 1
Pin 17
calibration = 6

Think I will try weewx 3.9.2, as I think that was the last python2 version , just to see if my lighnting sensor does work.
Phil

gjr80

unread,
Jul 27, 2021, 6:48:37 AM7/27/21
to weewx-user
> Think I will try weewx 3.9.2, as I think that was the last python2 version

All WeeWX releases to date have been python 2 compatible, including any 4.x releases. Python 4.0.0 and later are also python 3 compatible. It all comes down to what dependencies you have installed and what version of python WeeWX is run under.

Gary

Doug Jenkins

unread,
Jul 27, 2021, 8:50:36 AM7/27/21
to weewx-user
Phil:

In looking at your weewx.conf, you may want to switch the process service to be before the comma. I think the error is because you are passing [None] as the first object in the process_services dictionary.

[Engine]
[[Services]]
process_services =  user.as3935.AS3935, 

After that, it maybe prudent to go through and covert the AS3935 code to python3 syntax.

Doug

philip....@gmail.com

unread,
Jul 31, 2021, 5:45:17 AM7/31/21
to weewx-user
Thanks Doug but it didnt make any difference
As Im trying to use a DFRobot AS3935 I started again but this time on Python2
The i2cdetect -y 1 shows 03 show it appears the Raspberry Pi can see the AS3935
Using the simulator driver weewx now starts
Jul 31 10:17:47 raspberrypi weewx[2241]: engine: Initializing weewx version 3.9.2
Jul 31 10:17:47 raspberrypi weewx[2241]: engine: Using Python 2.7.16 (default, Oct 10 2019, 22:02:15) #012[GCC 8.3.0]
Jul 31 10:17:47 raspberrypi weewx[2241]: engine: Platform Linux-5.10.52-v7+-armv7l-with-debian-10.10
Jul 31 10:17:47 raspberrypi weewx[2241]: engine: Locale is 'en_GB.UTF-8'
Jul 31 10:17:47 raspberrypi weewx[2241]: engine: Using configuration file /home/weewx/weewx.conf
Jul 31 10:17:47 raspberrypi weewx[2241]: engine: Loading station type Simulator (weewx.drivers.simulator)
Jul 31 10:17:47 raspberrypi weewx[2241]: engine: StdConvert target unit is 0x1
Jul 31 10:17:47 raspberrypi weewx[2241]: wxcalculate: The following values will be calculated: barometer=prefer_hardware, windchill=prefer_hardware, dewpoint=prefer_hardware, appTemp=prefer_hardware, rainRate=prefer_hardware, windrun=prefer_hardware, heatindex=prefer_hardware, maxSolarRad=prefer_hardware, humidex=prefer_hardware, pressure=prefer_hardware, inDewpoint=prefer_hardware, ET=prefer_hardware, altimeter=prefer_hardware, cloudbase=prefer_hardware
Jul 31 10:17:47 raspberrypi weewx[2241]: wxcalculate: The following algorithms will be used for calculations: altimeter=aaNOAA, maxSolarRad=RS
Jul 31 10:17:47 raspberrypi weewx[2241]: as3935: service version is 0.6
Jul 31 10:17:47 raspberrypi weewx[2241]: as3935: address=0x03
Jul 31 10:17:47 raspberrypi weewx[2241]: as3935: bus=1
Jul 31 10:17:47 raspberrypi weewx[2241]: as3935: indoors=True
Jul 31 10:17:47 raspberrypi weewx[2241]: as3935: noise_floor=0
Jul 31 10:17:47 raspberrypi weewx[2241]: as3935: calibration=0x06
Jul 31 10:17:47 raspberrypi weewx[2241]: as3935: pin=17
Jul 31 10:17:47 raspberrypi weewx[2241]: as3935: data_binding=None
Jul 31 10:17:47 raspberrypi weewx[2241]: as3935: binding=archive
Jul 31 10:17:47 raspberrypi weewx[2241]: engine: Archive will use data binding wx_binding
Jul 31 10:17:47 raspberrypi weewx[2241]: engine: Record generation will be attempted in 'hardware'
Jul 31 10:17:47 raspberrypi weewx[2241]: engine: Using archive interval of 300 seconds (specified in weewx configuration)
Jul 31 10:17:47 raspberrypi weewx[2241]: engine: Using binding 'wx_binding' to database 'weewx.sdb'
Jul 31 10:17:47 raspberrypi weewx[2241]: manager: Starting backfill of daily summaries
Jul 31 10:17:47 raspberrypi weewx[2241]: restx: StationRegistry: Registration not requested.
Jul 31 10:17:47 raspberrypi weewx[2241]: restx: Wunderground: Posting not enabled.
Jul 31 10:17:47 raspberrypi weewx[2241]: restx: PWSweather: Posting not enabled.
Jul 31 10:17:47 raspberrypi weewx[2241]: restx: CWOP: Posting not enabled.
Jul 31 10:17:47 raspberrypi weewx[2241]: restx: WOW: Posting not enabled.
Jul 31 10:17:47 raspberrypi weewx[2241]: restx: AWEKAS: Posting not enabled.
Jul 31 10:17:47 raspberrypi weewx[2241]: engine: Starting up weewx version 3.9.2
Jul 31 10:17:47 raspberrypi weewx[2241]: engine: Clock error is -0.20 seconds (positive is fast)
Jul 31 10:17:47 raspberrypi weewx[2241]: engine: Starting main packet loop.
Jul 31 10:17:47 raspberrypi weewx[2241]: as3935: noise level too high - adjusting
Jul 31 10:20:14 raspberrypi weewx[2241]: manager: Added record 2021-07-31 10:20:00 BST (1627723200) to database 'weewx.sdb'
Jul 31 10:20:14 raspberrypi weewx[2241]: manager: Added record 2021-07-31 10:20:00 BST (1627723200) to daily summary in 'weewx.sdb'
Jul 31 10:20:20 raspberrypi weewx[2241]: cheetahgenerator: Generated 8 files for report SeasonsReport in 3.38 seconds
Jul 31 10:20:21 raspberrypi weewx[2241]: imagegenerator: Generated 14 images for SeasonsReport in 1.03 seconds
Jul 31 10:20:21 raspberrypi weewx[2241]: copygenerator: copied 5 files to /home/weewx/public_html
Im using the zip file from as3935 · weewx/weewx Wiki · GitHub
Have loaded sudo pip install RPi_AS3935 and sudo pip install GPIO
In each 300second cycle I just get the last 5 lines from above with nothing regarding the lightning detector

The database has the lightning fields in but always shows NULL
There isn't any lightning about at present but just wondered if thats correct 
Using weewxd the loop string I don't see anything to do with lightning .
Thanks for any help Phil


philip....@gmail.com

unread,
Jul 31, 2021, 7:59:38 AM7/31/21
to weewx-user
In the as3935.py

philip....@gmail.com

unread,
Jul 31, 2021, 8:06:06 AM7/31/21
to weewx-user
In the as3935.py I noticed for LOOP working I have to put that in the weewx.conf file which then showed lightning_strikes = 0
When checking the weewx.sdb it didnt have a lightning_strikes field its called lightning_strikes_count
When I added lighnting_strikes it now has a zero (0) in. 
So has the field names changed ??
The test will be when I get any lightning I shall keep you posted.

philip....@gmail.com

unread,
Aug 6, 2021, 10:06:07 AM8/6/21
to weewx-user
Lightning all round today but the only log entries were when the lightning was over head 7 in total
as3935: strike at 1.0 km
Calibration = 6 , changed to 2 didn't seem to make any difference
Storms now gone and still not sure if the dfrobot works that well

ian.r...@gmail.com

unread,
Aug 8, 2021, 3:08:59 AM8/8/21
to weewx-user
I think I have found the remaining Python 2 issue - 2to3 didnt find it when I tried

In as3935.py on line 73 change from:

from RPi_AS3935 import RPi_AS3935

to:

from RPi_AS3935.RPi_AS3935 import RPi_AS3935

Seems to be related to the situation discussed here

philip....@gmail.com

unread,
Aug 8, 2021, 11:32:05 AM8/8/21
to weewx-user
Im using python2 so as to get a lightning detector to work to that
Just had several lightning strikes overhead but it only recorded 1 strike 10km away and nothing else
Can anybody recommend a lightning detector that does work connected to a raspberry pi via weewx
The mod 1016 from EMBEDDED ADVENTURES has been mentioned but they dont seem to be in business anymore  
Thanks
Phil

philip....@gmail.com

unread,
Aug 8, 2021, 3:55:37 PM8/8/21
to weewx-user
Is the Calibration figure in weewx.conf the same as the tuning capacitance of the chip on the lightning detector
Why I ask is the dfrobot = 8 - 120 pf and has to be in multiple of 8's
They suggest 96 to start with but the Calibration figure in weewx.conf will only except 0-15
Or does that relate to some other figure
Thanks in anticipation
Phil

Reply all
Reply to author
Forward
0 new messages