How to send AS3935 Thunder Board (SwitchDocs) data to weewx.sdb

331 views
Skip to first unread message

bgra...@umw.edu

unread,
Aug 14, 2018, 3:54:18 PM8/14/18
to weewx-user
Hello,

I am using an Arduino with the SwitchDoc Labs Thunder Board - AS3935 for lightning detection and would like to incorporate the data in my weewx station (weewx.tgz, ubuntu 16.04, VP2+).
Not being much of a programmer, I wonder if anyone has tried this setup?
Since I'm running ubuntu on a linux machine (Intel NUC), I wonder if I need to setup a separate Rpi to send the data to the weewx machine (I have an extra if this is easier). The Thunder Board is presently configured to send data via MQTT to pubsub.com which I don't want to do but am not sure how to modify the Arduino code.
Any help on this would be greatly appreciated. Thanks.

Bob
http://grattans.org/wx

Steve2Q

unread,
Aug 15, 2018, 11:57:53 AM8/15/18
to weewx-user
Bob: I hope someone replies with the solution. I attempted to do this a while back on the same Rpi that runs Weewx, and although the AS3935 generated data, I could not figure out how to get it to show on Weeex.

Along those lines, my experiment with the AS3935 did get me interested in lightning (we have a lot in Florida), so I bit the bullet and purchased and assembled a System Blue lightning detector from Blitzortung.org

My station is at    http://photokinetics.org/Weather/    and at the bottom left is a clickable lightning map.

Steve (N2QLQ)

Thomas Keffer

unread,
Aug 15, 2018, 12:08:09 PM8/15/18
to weewx-user
Steve, how long did you have to wait before you got a System Blue? I put myself on the list ages ago, and am still a long way from the top.

-tk

--
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.
For more options, visit https://groups.google.com/d/optout.

bgra...@umw.edu

unread,
Aug 15, 2018, 7:38:04 PM8/15/18
to weewx-user
Thanks, Steve, very nice displays. I do hope someone can offer me some ideas. Bob

Steve2Q

unread,
Aug 15, 2018, 9:11:19 PM8/15/18
to weewx-user
Tom, I ordered mine in July 2017, and it took 3 weeks before I got mine. I am not sure what the criteria is for deciding who gets one. There are presently 12 registered stations in Florida of which 7 are currently running. In Oregon, there are 6 registered and all 6 are running. Maybe Florida is more to the top of the list as we have more lightning than Oregon??

Steve

Steve2Q

unread,
Aug 15, 2018, 9:13:03 PM8/15/18
to weewx-user
Thanks, Bob. I, too would like some advice. However, I can tell you that the Blitzortung receiver is magnitudes better at picking up lightning than the AS3935.

Steve

Pat

unread,
Aug 15, 2018, 9:14:38 PM8/15/18
to weewx-user
I have no experience with this hardware, but someone reading this might. It might help if you're able to share some code? What's the data? Time and distance to the lightning strike? You may have to extend the weewx schema to archive this data then modify a skin to show that data. 

But getting that data into weewx may be tricky since you can only run 1 driver at a time (your VP2). If you're using MQTT though, you may be able to find an extension that can connect to MQTT and bind to the loop to archive data that is published on your MQTT topic. 

bgra...@umw.edu

unread,
Aug 17, 2018, 5:33:25 PM8/17/18
to weewx-user
Thanks to everyone for the comments. With my limited experience I will probably not attemp to add this to weewx since it’s running so well at present.
I’ll probably try to setup my own web server to receive the AS3935 data using MQTT if I can figure out how not to send to pubnub.com whch seems to be programmed in the arduino sketch somewhere.

Pat

unread,
Aug 17, 2018, 8:23:11 PM8/17/18
to weewx-user
I'm curious about this project. Which Arduino sketch are you using?

bgra...@umw.edu

unread,
Aug 18, 2018, 11:06:10 AM8/18/18
to weewx-user
Pat,
I am attaching the software that comes with the SwitchDoc board. It seems to work fine except it tries to send data to pubnub.com which I don't want to do as I have my own web site. It logs into my local net with no problem but I haven't figured out how to change from pubnub to my local server.  If you have any suggestions then I would appreciate knowing what you think.  Thanks.
Bob
SDL_Arduino_ThunderBoard_IOT-master.zip

Pat

unread,
Aug 18, 2018, 3:21:17 PM8/18/18
to weewx-user
I read the code for the Arduino, as well as the Python code for the Raspberry Pi, and it looks like they're using pubnub.com as an MQTT-like service. Basically a middle man between your IoT device and your computer, so it makes sense that they're using it.

If you didn't want to use pubnub, you could potentially have the device send an update to your website using a format similar to how weather underground does it. For example, yoursite.com/lightningupdate.php?lightningcount=<lightning counter>&lightningtimestamp=<lightning timestamp>&more-variables-here. The PHP file could submit that data to your database so your website can pull it from the database when a visitor loads your site. Something along those lines. 

I think your device is using an ESP8266 for its WiFi connectivity, so you could replace the pubnub stuff with an HTTP GET method from the ESP library. In your code, the section publishPubNubMessage is where they are publishing it to pubnub. You could instead format the message variable and format it like mentioned above. Then you need to do the HTTP GET. Maybe something along the lines of this? The bits where you see http.begin(); and http.GET();

You could also keep the pubnub and add the HTTP GET portions to have it send the data in parallel. 

This does sound perfect for weewx though since it already uses a database and you can extend the the database for all these fields. The only challenge would be ingesting that data since you're already using a driver. I've never created a service, but I think a service can bind to the loop so it can input to the database much like a driver. 

So maybe a combination of many things could make this work for weewx?

1) Create a new service which runs an http server that can accept data from HTTP GET and submit to the loop. (Think a hybrid of the interceptor driver and the maxbotix service)
2) Re-program your arduino to use the http get as above and program it to submit to your weewx server instead of your web server
3) Figure out what variables you want to keep and how often you want to archive them and use those in the GET. Then update the service so it's aware of these variable names to submit.
4) Extend the weewx database schema for the variable data you want to save.
5) Update your weewx skin, or your website, to get this data from the database.

This is all speculation though since I don't own the hardware, but that's a couple potential workaround to get away from pubnub and still being able to get the data into a database.

Pat

unread,
Aug 18, 2018, 3:35:52 PM8/18/18
to weewx-user
I didn't see this until now, but there's a service for the AS3935 already, but looks like it's for one that's attached to the same Raspberry Pi system weewx is installed to. May not help much right now, but could offer insight on how to do the service part if you figure out how to get your data. 

bgra...@umw.edu

unread,
Aug 18, 2018, 5:45:43 PM8/18/18
to weewx-user
Thanks, Pat, there may be hope for me after all if you have the time to help.  I also have the SwitchDocs board for the RPI detector because I thought it might be easier to work with the Python than the Arduino IDE. I also have an extra RPI that could be used. Let me look at the software and get back to you. It would be nice to have  the AS3935 send data to weewx as that would simplify things. I think Matt wrote the extension for weewx but I haven't looked at it closely.
Again, much appreciated and I'll get back to you after I read some more.
Bob

bgra...@umw.edu

unread,
Aug 20, 2018, 11:22:36 AM8/20/18
to weewx-user
Pat,


It looks as if the weewx extension Matt suggests would be the best but I would prefer to run it in an RPI and not my main weewx server, if possible. The AS3935 board I have is not the one he references but it seems to have the same connections using Grove connectors.

I'm going to play around with the software from SwitchDocs Lab and see what I come up with. If I can eliminate the PubNub host and produce a web page on my own server then that might work. However, since weewx already has a data display and graph built-in then that looks promising also. Sort of mixed up as to what to do at this point... Thanks.
Bob

Eric K

unread,
Jun 16, 2021, 12:42:51 PM6/16/21
to weewx-user
I wonder if anyone knows if this AS9395 service 
can be configured to work with MQTT data, or if its hard-coded to only talk to ports on the Raspberry Pi?

vince

unread,
Jun 16, 2021, 12:46:02 PM6/16/21
to weewx-user
On Wednesday, June 16, 2021 at 9:42:51 AM UTC-7 Eric K wrote:
I wonder if anyone knows if this AS9395 service 
can be configured to work with MQTT data, or if its hard-coded to only talk to ports on the Raspberry Pi?


Did you download and look at the code ?

 

Eric K

unread,
Jun 16, 2021, 12:50:22 PM6/16/21
to weewx-user
Vince, if you don't know the answer to a question, why do you respond?

vince

unread,
Jun 16, 2021, 1:52:42 PM6/16/21
to weewx-user
On Wednesday, June 16, 2021 at 9:50:22 AM UTC-7 Eric K wrote:
Vince, if you don't know the answer to a question, why do you respond?


You asked a very open ended question.
I'm trying to understand what you have already looked into or tried.

I took the time to download and look at the code.
The answer to your question is very obvious if take just a little time and put just a little effort in.


Eric K

unread,
Jun 16, 2021, 2:30:44 PM6/16/21
to weewx-user
I was hoping Mathew Wall would see the question and respond.  It appears he wrote it.

I have not downloaded the code and looked.  
Based on the config sections shown on the wiki page, it looks like it's may be hard-coded to talk to a Raspberry Pi port.
If that's true, it might not work with the MQTT transport directly, and require more rewriting than I am able to do.

I'm primarily a hardware engineer.  I can read and write code, but its not my strong suit, or my passion.
I like to find out if something is difficult or impossible, before I spend a lot of time on it.

Getting answers from people who already know doesn't require much effort from anyone, so its a good plan, in my view.
Reply all
Reply to author
Forward
0 new messages