Gravity AS3935 lightning detector

239 views
Skip to first unread message

Giuseppe Saia

unread,
Feb 2, 2020, 6:25:07 AM2/2/20
to weewx-user
Good morning and good Sunday to everyone
I recently purchased the DFrobot gravity detection sensor. after having connected it correctly to the raspberry pi 3b + and having verified the correct operation with the command sudo i2cdetect -y 1 I would like to implement on weewx the fields lightning_strikes and avg_distance to each archive record.
Message has been deleted

Giuseppe Saia

unread,
Feb 2, 2020, 6:32:16 AM2/2/20
to weewx-user


This project that explains in detail the inclusion in weewx as an extension has already been created in a splendid way by mwall for a lightning detection sensor called mod 1016 by filling in a file already available to everyone in github. This, logically, does not work for the gravity sensor as3935. Could anyone help me please?

Giuseppe Saia

unread,
Feb 3, 2020, 11:39:18 AM2/3/20
to weewx-user


I attach the compressed file valid for a generic and not working as3935 for my dfrobot sensor lightning detector
I'd like someone to help me edit the happy py file in this compressed file to make it work with the sensor in my possession
thanks to those who want to help me .......
weewx-as3935-0.6.tgz

Giuseppe Saia

unread,
Feb 3, 2020, 2:09:53 PM2/3/20
to weewx-user
scuse me for my bad english
I attach the compressed file valid for a generic as3935 but it does not work for my lightning detector with dfrobot sensor
I would like someone to help me edit the py file so that it works with the sensor in my possession
weewx-as3935-0.6.tgz

Giuseppe Saia

unread,
Feb 5, 2020, 11:35:38 AM2/5/20
to weewx-user
I also attach the error log file. I hope it will be useful to help me


Feb  5 17:26:19 raspberrypi weewx[10352]: engine: Loading service user.as3935.AS3935
Feb  5 17:26:19 raspberrypi weewx[10352]: sdr: MainThread: shutdown process rtl_433 -M utc -F json -R 42 -R 12
Feb  5 17:26:19 raspberrypi weewx[10352]: sdr: MainThread: waiting for stdout-thread
Feb  5 17:26:29 raspberrypi weewx[10352]: sdr: MainThread: timed out waiting for stdout-thread
Feb  5 17:26:29 raspberrypi weewx[10352]: sdr: MainThread: waiting for stderr-thread
Feb  5 17:26:39 raspberrypi weewx[10352]: sdr: MainThread: timed out waiting for stderr-thread
Feb  5 17:26:39 raspberrypi weewx[10352]: sdr: MainThread: close stdout
Feb  5 17:26:39 raspberrypi weewx[10352]: sdr: MainThread: close stderr
Feb  5 17:26:39 raspberrypi weewx[10352]: engine: Caught unrecoverable exception in engine:
Feb  5 17:26:39 raspberrypi weewx[10352]:     ****  No module named RPi_AS3935
Feb  5 17:26:39 raspberrypi weewx[10352]:     ****  Traceback (most recent call last):
Feb  5 17:26:39 raspberrypi weewx[10352]:     ****    File "/home/weewx/bin/weewx/engine.py", line 888, in main
Feb  5 17:26:39 raspberrypi weewx[10352]:     ****      engine = engine_class(config_dict)
Feb  5 17:26:39 raspberrypi weewx[10352]:     ****    File "/home/weewx/bin/weewx/engine.py", line 78, in __init__
Feb  5 17:26:39 raspberrypi weewx[10352]:     ****      self.loadServices(config_dict)
Feb  5 17:26:39 raspberrypi weewx[10352]:     ****    File "/home/weewx/bin/weewx/engine.py", line 142, in loadServices
Feb  5 17:26:39 raspberrypi weewx[10352]:     ****      self.service_obj.append(weeutil.weeutil._get_object(svc)(self, config_dict))
Feb  5 17:26:39 raspberrypi weewx[10352]:     ****    File "/home/weewx/bin/weeutil/weeutil.py", line 1107, in _get_object
Feb  5 17:26:39 raspberrypi weewx[10352]:     ****      mod = __import__(module)
Feb  5 17:26:39 raspberrypi weewx[10352]:     ****    File "/home/weewx/bin/user/as3935.py", line 73, in <module>
Feb  5 17:26:39 raspberrypi weewx[10352]:     ****      from RPi_AS3935 import RPi_AS3935
Feb  5 17:26:39 raspberrypi weewx[10352]:     ****  ImportError: No module named RPi_AS3935
Feb  5 17:26:39 raspberrypi weewx[10352]:     ****  Exiting.


Brice Ruth

unread,
Feb 5, 2020, 2:13:24 PM2/5/20
to weewx...@googlegroups.com
This doesn't seem to be documented, but based on your log output, I think you need to install a Python module =>

pip install RPi_AS3935


Brice Ruth, FCD
Software Engineer, Madison WI


--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-user/6899ccae-e507-47bd-a622-7127a57421e4%40googlegroups.com.

Brice Ruth

unread,
Feb 5, 2020, 2:14:36 PM2/5/20
to weewx...@googlegroups.com
Looking at the extension's source, you'll also need the GPIO module ... unless it's already installed as part of something else ...

pip install RPi.GPIO


Brice Ruth, FCD
Software Engineer, Madison WI

Message has been deleted

Giuseppe Saia

unread,
Feb 6, 2020, 12:31:57 PM2/6/20
to weewx-user


here is what I did thanks to your suggestions and your help
pi@raspberrypi:~ $ pip install RPi.GPIO
Requirement already satisfied: RPi.GPIO in /usr/lib/python2.7/dist-packages (0.7.0)
pi@raspberrypi:~ $ pip install RPi_as3935
Collecting RPi_as3935
Building wheels for collected packages: RPi-as3935
  Running setup.py bdist_wheel for RPi-as3935 ... done
  Stored in directory: /home/pi/.cache/pip/wheels/39/b9/8d/2b937250c4ef8377903f71a6d1125a6e92713e59bfb8a52a1a
Successfully built RPi-as3935
Installing collected packages: RPi-as3935
Successfully installed RPi-as3935-0.2.0
pi@raspberrypi:~ $ sudo /home/weewx/bin/wee_extension --install weewx-as3935-0.6.tgz
Request to install 'weewx-as3935-0.6.tgz'
Extracting from tar archive weewx-as3935-0.6.tgz
Saving installer file to /home/weewx/bin/user/installer/as3935
Saved configuration dictionary. Backup copy at /home/weewx/weewx.conf.20200206182609
Finished installing extension 'weewx-as3935-0.6.tgz'

Giuseppe Saia

unread,
Feb 6, 2020, 12:35:15 PM2/6/20
to weewx-user


here's what happened

Feb  6 18:32:38 raspberrypi weewx[15458]: sdr: MainThread: waiting for stdout-thread
Feb  6 18:32:42 raspberrypi weewx[15458]: sdr: MainThread: waiting for stderr-thread
Feb  6 18:32:52 raspberrypi weewx[15458]: sdr: MainThread: timed out waiting for stderr-thread
Feb  6 18:32:52 raspberrypi weewx[15458]: sdr: MainThread: close stdout
Feb  6 18:32:52 raspberrypi weewx[15458]: sdr: MainThread: close stderr
Feb  6 18:32:52 raspberrypi weewx[15458]: engine: Caught unrecoverable exception in engine:
Feb  6 18:32:52 raspberrypi weewx[15458]:     ****  No module named RPi_AS3935
Feb  6 18:32:52 raspberrypi weewx[15458]:     ****  Traceback (most recent call last):
Feb  6 18:32:52 raspberrypi weewx[15458]:     ****    File "/home/weewx/bin/weewx/engine.py", line 888, in main
Feb  6 18:32:52 raspberrypi weewx[15458]:     ****      engine = engine_class(config_dict)
Feb  6 18:32:52 raspberrypi weewx[15458]:     ****    File "/home/weewx/bin/weewx/engine.py", line 78, in __init__
Feb  6 18:32:52 raspberrypi weewx[15458]:     ****      self.loadServices(config_dict)
Feb  6 18:32:52 raspberrypi weewx[15458]:     ****    File "/home/weewx/bin/weewx/engine.py", line 142, in loadServices
Feb  6 18:32:52 raspberrypi weewx[15458]:     ****      self.service_obj.append(weeutil.weeutil._get_object(svc)(self, config_dict))
Feb  6 18:32:52 raspberrypi weewx[15458]:     ****    File "/home/weewx/bin/weeutil/weeutil.py", line 1107, in _get_object
Feb  6 18:32:52 raspberrypi weewx[15458]:     ****      mod = __import__(module)
Feb  6 18:32:52 raspberrypi weewx[15458]:     ****    File "/home/weewx/bin/user/as3935.py", line 73, in <module>
Feb  6 18:32:52 raspberrypi weewx[15458]:     ****      from RPi_AS3935 import RPi_AS3935
Feb  6 18:32:52 raspberrypi weewx[15458]:     ****  ImportError: No module named RPi_AS3935
Feb  6 18:32:52 raspberrypi weewx[15458]:     ****  Exiting.



rich T

unread,
Feb 6, 2020, 12:39:41 PM2/6/20
to weewx-user
Looks like you installed RPi-as3935 module, when it is looking for module named RPi_AS3935.  I believe this should solve the issue: https://pypi.org/project/RPi_AS3935/

Giuseppe Saia

unread,
Feb 6, 2020, 12:42:09 PM2/6/20
to weewx-user


I think that my DFrobot_as3935 module is not compatible with this driver and the subsequent integration with weeewx cannot be <..... what do you think?
is there a solution in your opinion?

rich T

unread,
Feb 6, 2020, 12:59:05 PM2/6/20
to weewx-user
Did you try install the RPi_AS3935 module (https://pypi.org/project/RPi_AS3935/)?  I have one still in the packaging, won't get around to setting it up until sometime this weekend.

Giuseppe Saia

unread,
Feb 6, 2020, 1:12:34 PM2/6/20
to weewx-user


same mistake
no integration with weewx

Brice Ruth

unread,
Feb 6, 2020, 1:32:55 PM2/6/20
to weewx...@googlegroups.com
I think there's a problem with your library paths ... because it's not even getting to where it can determine what hardware you have. It can't load the program because it can't find the missing module, period.

Brice Ruth, FCD
Software Engineer, Madison WI

On Thu, Feb 6, 2020 at 12:12 PM Giuseppe Saia <gian...@gmail.com> wrote:


same mistake
no integration with weewx

--
You received this message because you are subscribed to the Google Groups "weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-user+...@googlegroups.com.
Message has been deleted

Paul McGeorge

unread,
Feb 6, 2020, 10:00:36 PM2/6/20
to weewx-user
Try sudo pip install. I've seen the python modules need elevated privlages...

rich T

unread,
Feb 6, 2020, 11:23:23 PM2/6/20
to weewx-user
UPDATE

I believe there is an issue when using a DFRobot AS3935 with weewx. Here is what I did:

1.  Connect DFRobot AS3935 to RPI.

                       AS3935 >>>>  RPI
                          -------       -----
                         Red >>>>>> Pin 4
                         Black >>>> Pin 9
                         Blue >>>>> Pin 5
                         Green >>>> Pin 3
                         IRQ >>>>>  Pin 11
                         GND >>>>>  Pin 14

2. Apply power to  RPi and ensured I2C Interface is enabled on RPI.

3. Verified that you can detect the DFRobot AS3935.

          pi@raspberrypi:~ $ i2cdetect -y 1
               0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
           00:          03 -- -- -- -- -- -- -- -- -- -- -- --
           10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
           20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
           30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
           40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
           50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
           60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
           70: -- -- -- -- -- -- -- --

4. Install Required AS3935 Module (https://pypi.org/project/RPi_AS3935/)
4a. sudo pip install RPi_AS3935

5. Install Required AS3935 Service
5a. Download the file (http://lancet.mit.edu/mwall/projects/weather/releases/weewx-as3935-0.6.tgz)
5b. Install AS3935 Service --- pi@raspberrypi:/home/weewx/bin $ sudo ./wee_extension --install=/home/pi/Downloads/weewx-as3935-0.6.tgz (Paths may differ)

6. Followed the remaining instruction found at https://github.com/weewx/weewx/wiki/as3935

The error that I'm receiving when the DFRobot AS3935 is connected to the RPI is as follows:

Feb  6 22:36:54 raspberrypi weewx[1021]: engine: Loading service user.as3935.AS3935
Feb  6 22:36:54 raspberrypi weewx[1021]: as3935: service version is 0.6
Feb  6 22:36:54 raspberrypi weewx[1021]: as3935: address=0x03
Feb  6 22:36:54 raspberrypi weewx[1021]: as3935: bus=1
Feb  6 22:36:54 raspberrypi weewx[1021]: as3935: indoors=True
Feb  6 22:36:54 raspberrypi weewx[1021]: as3935: noise_floor=0
Feb  6 22:36:54 raspberrypi weewx[1021]: as3935: calibration=0x06
Feb  6 22:36:54 raspberrypi weewx[1021]: as3935: pin=17
Feb  6 22:36:54 raspberrypi weewx[1021]: as3935: data_binding=None
Feb  6 22:36:54 raspberrypi weewx[1021]: as3935: binding=archive
Feb  6 22:36:54 raspberrypi weewx[1021]: engine: Caught unrecoverable exception in engine:
Feb  6 22:36:54 raspberrypi weewx[1021]:     ****  [Errno 121] Remote I/O error
Feb  6 22:36:54 raspberrypi weewx[1021]:     ****  Traceback (most recent call last):
Feb  6 22:36:54 raspberrypi weewx[1021]:     ****    File "/home/weewx/bin/weewx/engine.py", line 884, in main
Feb  6 22:36:54 raspberrypi weewx[1021]:     ****      engine = engine_class(config_dict)
Feb  6 22:36:54 raspberrypi weewx[1021]:     ****    File "/home/weewx/bin/weewx/engine.py", line 78, in __init__
Feb  6 22:36:54 raspberrypi weewx[1021]:     ****      self.loadServices(config_dict)
Feb  6 22:36:54 raspberrypi weewx[1021]:     ****    File "/home/weewx/bin/weewx/engine.py", line 142, in loadServices
Feb  6 22:36:54 raspberrypi weewx[1021]:     ****      self.service_obj.append(weeutil.weeutil._get_object(svc)(self, config_dict))
Feb  6 22:36:54 raspberrypi weewx[1021]:     ****    File "/home/weewx/bin/user/as3935.py", line 154, in __init__
Feb  6 22:36:54 raspberrypi weewx[1021]:     ****      self.sensor.set_indoors(indoors)
Feb  6 22:36:54 raspberrypi weewx[1021]:     ****    File "/usr/local/lib/python2.7/dist-packages/RPi_AS3935/RPi_AS3935.py", line 167, in set_indoors
Feb  6 22:36:54 raspberrypi weewx[1021]:     ****      self.set_byte(0x00, write_value)
Feb  6 22:36:54 raspberrypi weewx[1021]:     ****    File "/usr/local/lib/python2.7/dist-packages/RPi_AS3935/RPi_AS3935.py", line 222, in set_byte
Feb  6 22:36:54 raspberrypi weewx[1021]:     ****      self.i2cbus.write_byte_data(self.address, register, value)
Feb  6 22:36:54 raspberrypi weewx[1021]:     ****  IOError: [Errno 121] Remote I/O error
Feb  6 22:36:54 raspberrypi weewx[1021]:     ****  Exiting.

When I connect a MOD-1016 AS3935 detector everything works as expected. 

rich T

unread,
Feb 6, 2020, 11:48:39 PM2/6/20
to weewx-user
EDIT

When I execute the Demo.py with the DFRobot installed I get the following error:

Traceback (most recent call last):
  File "Demo.py", line 15, in <module>
    sensor.set_indoors(False)

  File "/usr/local/lib/python2.7/dist-packages/RPi_AS3935/RPi_AS3935.py", line 167, in set_indoors
    self.set_byte(0x00, write_value)

  File "/usr/local/lib/python2.7/dist-packages/RPi_AS3935/RPi_AS3935.py", line 222, in set_byte
    self.i2cbus.write_byte_data(self.address, register, value)

IOError: [Errno 121] Remote I/O error

------------------
(program exited with code: 1)
Press return to continue

But if I REM out the following within Demo.py, it seems to be working:

#sensor.set_indoors(False)
#sensor.set_noise_floor(0)
#sensor.calibrate(tun_cap=0x0F)

I get "Waiting for lightning - or at least something that looks like it"

Again if connect the MOD-1016 AS3935 detector everything works as expected.
Message has been deleted

Giuseppe Saia

unread,
Feb 8, 2020, 1:51:57 PM2/8/20
to weewx-user
in my opinion, with my little experience as a beginner, a point to start from could be the specific library of DFrobot_as3935 together with the two py files that work only as a terminal with raspberry and adapt them to work with weewx

I attach the py files
DFRobot_AS3935_Lib.py
DFRobot_AS3935_detailed.py
Reply all
Reply to author
Forward
0 new messages