Weather Software > WeeWX Software

GW1000 + Lightning Sensor

(1/2) > >>

TinkerTown:
Does anyone know if there is a guide or extension to add lightning strikes to Weewx that is writing to MySQL? I am using Weewx and an Ambient Weather 2902C, but with the GW1000 and the WH51 Lightning Sensor reading off the GW1000. I thought I saw a guide or something that explained how to add tracking of lightning, but I can't seem to find it again (if I ever did see it). I also have Weewx writing to a MySQL database on a separate server from the PI that Weewx is running on.

Gyvate:
If you look at your DB schema, you can see all the fields weewx usually stores (or can store) in its database.
If you started with weewx 4.x.x that's most likely the wview_extended schema (what you have you can see in your weewx.conf
in [DataBindings]     [[wx_binding]]. It resides (under Debian/Raspbian) at /usr/share/weewx/schemas as wview_extended.py).

In principle it doesn't matter whether the schema was created in a sqlite or a mySQL database.
Weewx will write/archive to the database you define in [[wx_binding]].

But, if I read your question properly, you want to combine the WS2902C readings and the GW1000 readings - or did you only mean by that the outdoor sensor array of the WS2892C  plus the WH57 lightning sensor?
(It's WH57, not WH51. WH51 is the SoilMoisture sensor; see https://www.wxforum.net/index.php?topic=40730.0).
Because the GW1000 will be able to read all the data you need. I assume (and recommend if not) that you use the GW1000 API driver.
https://github.com/gjr80/weewx-gw1000

If you use the wview_extended schema together with the GW1000 API driver, weewx would automatically assign the WH57 readings to the respective database fields.

You can look up the field map of the GW1000 driver at
https://github.com/gjr80/weewx-gw1000/wiki/Field-map.
It shows all the data available to process by weewx from the GW1000 (depending on which sensors are connected) - not what is stored/archived. That is defined by the DB schema.
Only observations which have a corresponding field in the DB schema will be assigned and stored/archived automatically.

If you still have the minimalist wview schema, the automatic assignment will not happen (if the fields are not part of the schema). Then you should upgrade to the wview_extended schema.
That's described in the wiki and customization guide.
(see wiki [https://github.com/weewx/weewx/wiki] and customization guide [http://www.weewx.com/docs/customizing.htm]).

TinkerTown:

--- Quote from: Gyvate on April 14, 2021, 03:30:34 PM ---If you look at your DB schema, you can see all the fields weewx usually stores (or can store) in its database.
If you started with weewx 4.x.x that's most likely the wview_extended schema (what you have you can see in your weewx.conf
in [DataBindings]     [[wx_binding]]. It resides (under Debian/Raspbian) at /usr/share/weewx/schemas as wview_extended.py).

In principle it doesn't matter whether the schema was created in a sqlite or a mySQL database.
Weewx will write/archive to the database you define in [[wx_binding]].

But, if I read your question properly, you want to combine the WS2902C readings and the GW1000 readings - or did you only mean by that the outdoor sensor array of the WS2892C  plus the WH57 lightning sensor?
(It's WH57, not WH51. WH51 is the SoilMoisture sensor; see https://www.wxforum.net/index.php?topic=40730.0).
Because the GW1000 will be able to read all the data you need. I assume (and recommend if not) that you use the GW1000 API driver.
https://github.com/gjr80/weewx-gw1000

If you use the wview_extended schema together with the GW1000 API driver, weewx would automatically assign the WH57 readings to the respective database fields.

You can look up the field map of the GW1000 driver at
https://github.com/gjr80/weewx-gw1000/wiki/Field-map.
It shows all the data available to process by weewx from the GW1000 (depending on which sensors are connected) - not what is stored/archived. That is defined by the DB schema.
Only observations which have a corresponding field in the DB schema will be assigned and stored/archived automatically.

If you still have the minimalist wview schema, the automatic assignment will not happen (if the fields are not part of the schema). Then you should upgrade to the wview_extended schema.
That's described in the wiki and customization guide.
(see wiki [https://github.com/weewx/weewx/wiki] and customization guide [http://www.weewx.com/docs/customizing.htm]).

--- End quote ---

Ah, OK I will check that out. The weather station I have is the AW 2902C, but I use the GW1000 to read the sensors from the station, plus an additional Temperature sensor and the WH57 Lightning sensor. I just purchased a WH51, but haven't deployed it yet.

This installation is Weewx 4.5.1 and now that you mention it I do recall reading about the database extension script and that is what I think I was recalling, so thank you. I am not an expert on databases, but I should be able to follow the customization documentation once I read through it. I am running the gw1000 API driver.

Thanks!

[GW1000]
    # This section is for the GW1000 API driver.

    driver = user.gw1000
    ip_address = xxx.xxx.xxx.xxx
    port = 45000
    poll_interval = 20

Gyvate:
OK - if you use the wview_extended schema, which will be automatically the case when you made your initial (!) install with a weewx 4.x.x  version, all your sensors (= the ones you have right now) should be automatically stored/archived. Lightning strike number, last date and distance are fields in the wview_extendedschema, so are 1-4 SoilMoisture sensors. It will become trickier once you have more than 4 (as I do).

So, if you have the already the wview_extended schema, nothing you have to do. If only the wview schema, you need to upgrade to wview_extended.

If you want to display your data in (e.g.) the Seasons skin, you need to know the weewx DB field names which you will need to add to skin.conf and index.html.tmpl.
Those you find in the Python program which created the DB schema; it ran only once when the initial install of the DB happened.
It's located in /usr/share/weewx/schemas and is named wview_extended.py (or wview.py).

e.g.
in skin.conf (/etc/weewx/skins/Seasons/skin.conf) you can add to

[ImageGenerator]
#
# ....................
#
   [[day_images]]

# ..................
        [[[daylightning]]]
             [[[[lightning_strike_count]]]]
               

        [[[daylightning2]]]
            [[[[lightning_distance]]]]   


and in index.html.tmpl (/etc/weewx/skins/Seasons/index.html.tmpl) you can then add

note that in index.html.tmpl a "#" is a valid syntax tag, not a commentary sign - commentary would be "##"

##
## you can add to the below plot group

 <div id="plot_group">
        <div id="history_widget" class="widget">
          <div id="plot_title" class="widget_title">History:&nbsp;&nbsp;
            <a class="button_selected" id="button_history_day"
               onclick="choose_history('day')">Day</a>
            <a class="button" id="button_history_week"
               onclick="choose_history('week')">Week</a>
            <a class="button" id="button_history_month"
               onclick="choose_history('month')">Month</a>
            <a class="button" id="button_history_year"
               onclick="choose_history('year')">Year</a>
          </div>
          <div id="history_day" class="plot_container">
            <img src="daybarometer.png" alt="$obs.label.barometer"/>
            <img src="daytempdew.png"   alt="$obs.label.outTemp" />
            <img src="daytempfeel.png"  alt="$obs.label.feel" />
            <img src="dayhum.png"       alt="$obs.label.outHumidity" />
            <img src="daywind.png"      alt="$obs.label.windSpeed" />
            <img src="daywinddir.png"   alt="$obs.label.windDir" />
            <img src="daywindvec.png"   alt="$obs.label.windvec" />
            <img src="dayrain.png"      alt="$obs.label.rain" />
## ........................
## ........................
            #if $day.lightning_strike_count.has_data
            <img src="daylightning.png"      alt="$obs.label.lightning_strike_count" />
            #end if
            #if $day.lightning_distance.has_data
            <img src="daylightning2.png"      alt="$obs.label.lightning_distance" />
            #end if

the result should look like:
 [ You are not allowed to view attachments ]
here the last strike was a couple of days ago at 24 km distance

once it works, you will have to add entries for week, month and year to skin.conf and index.html.tmpl - otherwise the pictures will occur only in the day view!!

If you want to see not only the pictures but also the current and high/low values in the left hand side pane of the Seasons skin,
 you will have to add corresponding entries to current.inc and hilo.inc (which are loaded into index.html.tmpl).
That will also be current, week, month, year.

e.g. for current.inc (/etc/weewx/skins/Seasons/current.inc)
##.................
## WH57 lightning
#if $day.lightning_strike_count.has_data
      <tr>
        <td class="label">$obs.label.lightning_strike_count</td>
        <td class="data">$current.lightning_strike_count</td>
      </tr>
#end if
#if $day.lightning_distance.has_data
      <tr>
        <td class="label">$obs.label.lightning_distance</td>
        <td class="data">$current.lightning_distance</td>
      </tr>
#end if
## ................

result (without the WH45 observations  ;) 8-) )
 [ You are not allowed to view attachments ]

there is also statistics.inc to be edited if you want to see the lightnings in the history table (click on "high/low").

The same/similar approach will need to be used for your WH51 SoilMoisture sensor.

TinkerTown:
I am using the Belchertown skin, but I assume the shaping of the skin.conf is similar?

I looked in the database and these are the tables I have, so it looks like I have the extended schema already!

mysql> SHOW TABLES;
+---------------------------------------+
| Tables_in_weewx                       |
+---------------------------------------+
| archive                               |
| archive_day_ET                        |
| archive_day_UV                        |
| archive_day__metadata                 |
| archive_day_altimeter                 |
| archive_day_appTemp                   |
| archive_day_appTemp1                  |
| archive_day_barometer                 |
| archive_day_batteryStatus1            |
| archive_day_batteryStatus2            |
| archive_day_batteryStatus3            |
| archive_day_batteryStatus4            |
| archive_day_batteryStatus5            |
| archive_day_batteryStatus6            |
| archive_day_batteryStatus7            |
| archive_day_batteryStatus8            |
| archive_day_cloudbase                 |
| archive_day_co                        |
| archive_day_co2                       |
| archive_day_consBatteryVoltage        |
| archive_day_dewpoint                  |
| archive_day_dewpoint1                 |
| archive_day_extraHumid1               |
| archive_day_extraHumid2               |
| archive_day_extraHumid3               |
| archive_day_extraHumid4               |
| archive_day_extraHumid5               |
| archive_day_extraHumid6               |
| archive_day_extraHumid7               |
| archive_day_extraHumid8               |
| archive_day_extraTemp1                |
| archive_day_extraTemp2                |
| archive_day_extraTemp3                |
| archive_day_extraTemp4                |
| archive_day_extraTemp5                |
| archive_day_extraTemp6                |
| archive_day_extraTemp7                |
| archive_day_extraTemp8                |
| archive_day_forecast                  |
| archive_day_hail                      |
| archive_day_hailBatteryStatus         |
| archive_day_hailRate                  |
| archive_day_heatindex                 |
| archive_day_heatindex1                |
| archive_day_heatingTemp               |
| archive_day_heatingVoltage            |
| archive_day_humidex                   |
| archive_day_humidex1                  |
| archive_day_inDewpoint                |
| archive_day_inHumidity                |
| archive_day_inTemp                    |
| archive_day_inTempBatteryStatus       |
| archive_day_leafTemp1                 |
| archive_day_leafTemp2                 |
| archive_day_leafWet1                  |
| archive_day_leafWet2                  |
| archive_day_lightning_distance        |
| archive_day_lightning_disturber_count |
| archive_day_lightning_energy          |
| archive_day_lightning_noise_count     |
| archive_day_lightning_strike_count    |
| archive_day_luminosity                |
| archive_day_maxSolarRad               |
| archive_day_nh3                       |
| archive_day_no2                       |
| archive_day_noise                     |
| archive_day_o3                        |
| archive_day_outHumidity               |
| archive_day_outTemp                   |
| archive_day_outTempBatteryStatus      |
| archive_day_pb                        |
| archive_day_pm10_0                    |
| archive_day_pm1_0                     |
| archive_day_pm2_5                     |
| archive_day_pressure                  |
| archive_day_radiation                 |
| archive_day_rain                      |
| archive_day_rainBatteryStatus         |
| archive_day_rainRate                  |
| archive_day_referenceVoltage          |
| archive_day_rxCheckPercent            |
| archive_day_signal1                   |
| archive_day_signal2                   |
| archive_day_signal3                   |
| archive_day_signal4                   |
| archive_day_signal5                   |
| archive_day_signal6                   |
| archive_day_signal7                   |
| archive_day_signal8                   |
| archive_day_snow                      |
| archive_day_snowBatteryStatus         |
| archive_day_snowDepth                 |
| archive_day_snowMoisture              |
| archive_day_snowRate                  |
| archive_day_so2                       |
| archive_day_soilMoist1                |
| archive_day_soilMoist2                |
| archive_day_soilMoist3                |
| archive_day_soilMoist4                |
| archive_day_soilTemp1                 |
| archive_day_soilTemp2                 |
| archive_day_soilTemp3                 |
| archive_day_soilTemp4                 |
| archive_day_supplyVoltage             |
| archive_day_txBatteryStatus           |
| archive_day_uvBatteryStatus           |
| archive_day_wind                      |
| archive_day_windBatteryStatus         |
| archive_day_windDir                   |
| archive_day_windGust                  |
| archive_day_windGustDir               |
| archive_day_windSpeed                 |
| archive_day_windchill                 |
| archive_day_windrun                   |
+---------------------------------------+
114 rows in set (0.00 sec)

Navigation

[0] Message Index

[#] Next page

Go to full version