WeeWX UDP driver for WeatherFlow station

Thanks for your quick response. These are helpful thoughts. I got 4.0.0b5 sorted with your help.

I did have an existing v3 installation. I wiped that out and started over with a weewx user and group and a home directory just as you said. It took a bit to get everything in the right place and working. Mostly permissions issues.

I installed on an existing Fedora 31 system that I use to serve several other httpd projects. It’s an 86_64 system. My several pi’s are already busy doing other IOT things. So getting it running on the Fedora system might reveal some other issues over time. It’s time to move to python3 in any case. It’s the only system I expose to the internet because it has robust security features. I used the tar.gz install method with setup.py. I think it probably errored on my earlier attempt and I didn’t notice. This time the egg file was installed OK and it’s working.

I manually installed your version of weatherflowudp for Python3 and it seems to be working on 3.7.5 even though I don’t have the WF hardware yet, It is monitoring the UDP broadcast and accepted all the settings from weewx.conf OK. It should work when I edit the settings with HW numbers. Nice work on keeping weewx moving forward.

Kevin

Morning - hope its ok to ask this in the thread - I am trying to get average wind speed out of weewx (via mqtt) - via my sensor map i am using:

[[sensor_map]]
outTemp = air_temperature.AR-00003549.obs_air
outHumidity = relative_humidity.AR-00003549.obs_air
pressure = station_pressure.AR-00003549.obs_air
lightning_strikes = lightning_strike_count.AR-00003549.obs_air
avg_distance = lightning_strike_avg_distance.AR-00003549.obs_air
outTempBatteryStatus = battery.AR-00003549.obs_air
windSpeed = wind_speed.SK-00009880.rapid_wind
windDir = wind_direction.SK-00009880.rapid_wind
lux = illuminance.SK-00009880.obs_sky
UV = uv.SK-00009880.obs_sky
rain = rain_accumulated.SK-00009880.obs_sky
windBatteryStatus = battery.SK-00009880.obs_sky
radiation = solar_radiation.SK-00009880.obs_sky
lightningYYY = distance.AR-00004444.evt_strike
lightningZZZ = energy.AR-00004444.evt_strike

So can i assume windSpeed is actually wind gust as its the latest every 3 seconds rapid wind - in which case anyone know where i can get the average wind speed and map it to an mqtt topic?

Andy

The WF docs for rapid_wind do not give any insight into exactly what value ‘wind_speed’ contains:

https://weatherflow.github.io/SmartWeather/api/udp/v114/

Given the 3 second (non-power-save mode) update frequency, I made the assumption that it was a close approximation of the instantaneous wind speed.

If you want to use the averages, they are in the per-minute obs_sky packets (documented in the link above) as ‘wind_lull’, ‘wind_avg’, ‘wind_gust’, and ‘wind_direction’.

The more difficult question is where you are going to stick these values in WeeWX (left side of equals sign):

http://weewx.com/docs/customizing.htm#archive_types

The default database schema only offers windSpeed and windGust, so you may need to extend the WeeWX database schema (directions at above link) unless you want to give up the 3-second rapid_wind data and stick the obs_sky ‘wind_avg’ into windSpeed. (The Belchertown skin would be quite boring without the 3-second mqtt wind updates, but that’s my use case for mqtt.)

Between the above two links, you should be able to compose a sensor_map for almost any scenario…

Oh, and in case it is confusing, rapid_wind was named by WF because the packets are sent rapidly (every 3 seconds). The name has no relation to what the data inside those packets reflects…

No, rapid_wind is just the current speed reported every 3 seconds rather than every 60 seconds.

Wind ‘gust’ has a very precise definition that typically includes some minimal duration and offset from previous measurements. There are many such definitions, but one is at Gust | Winds, Turbulence & Air Pressure | Britannica

I have rapid_wind enabled on my WF, so I just use that and weewx seems to do the right thing…

   windSpeed = wind_speed.SK-00013695.rapid_wind
   windDir   = wind_direction.SK-00013695.rapid_wind

There have been many discussions about whether station-XYZ can capture the windspeed in a microburst that’s even faster than the 3 second rapid_wind measurement, but my recollection is that it cannot. Rapid_wind just reports ‘wind’ more rapidly (often).

1 Like

Thanks for the replies - it makes sense now - i guess i am looking to get average wind speed - ie to get a graph similar to the WF app wind graph.

At the moment i have a test graph of live wind speed via mqtt (thought it might look nice in the belchertown template) but thought it also needed average speed as a second line.

[http://www.finchamweather.co.uk/mqtthighcharts_windgust.html]

Andy

Here’s my weewx Season’s skin version from mine…

Screen Shot 2020-01-04 at 11.53.23 AM

Similar graph from my VP2 which is mounted 7’ higher and has a little better clean path from the prevailing SSW winds.

Screen Shot 2020-01-04 at 11.56.07 AM

1 Like

Nice graph - so in weewx do you know which reading the bottom line is - is there a windAvg reading? Just trying to see which one to output to Mqtt as it does not seem part of the general mqtt list this may now be off topic for this tread though and I can probably get it from the database instead I guess…

Andy

Depends on what you have configured ‘to’ graph. If you look at skin.conf you will see the aggregate_type can be min/max/avg. One example is the yearly high/low temperature graph that the Standard skin puts out - example at https://www.skahan.net/weewx/Standard/yearhilow.png

I think we’re way off anything WF related at this point. You should ask any followups in the weewx-users group in Google Groups.

1 Like

I just got a WeatherFlow to replace my old Acurite earlier this week. I’m really enjoying exploring all of these new integrations I’m discovering every day.

I got Weewx set up with the WF UDP driver, and I’m sure I’ve got a lot more to learn about customizing. But in the meantime, I would like to set up a new database for various other reasons.

I have a growing DB of personal sensor data. I have all of my 5 minute archives from WeatherUnderground going back over 2 years. I want to now add this PWS as a new table. I also use the same node.js process running on my raspberry pi to send the data from all the sensors to Graphite.

But I can’t seem to get both weewx and my test node app (simply create a dgram socket, bind, and log to console) to run at the same time. Even if I set the “share_port” setting to true, it still throws the “address in use” error.

Any ideas? I’m really interested in the UDP dgrams. When I first saw the amount of raw data that thing spits out (and I don’t have to poll a remote server!) I was definitely data geeking.

Thanks!

1 Like

your node app also needs to share the port…

If you’re running weewx, you should ideally use a secondary db for your other sensors if you want to keep everything as simple as possible. There are lots of howtos in the weewx google group.

I have an example at https://github.com/vinceskahan/weewx-minimal-secondary-db if you want a trivial example that cooks up a db and stores the seconds since epoch in a new field. You could use that as a starting point for rolling your own extension and custom db to do whatever you want.

1 Like

Ok great, thanks!
For as many times I’ve told my kids how sharing is important and goes both ways…

Edit:
So now I get to move past step 1 because that was absolutely the issue! In case anyone else is new to UDP, here was the money shot that did the trick:

const server = dgram.createSocket({ type: 'udp4', reuseAddr: true });

2 Likes

Hi there! So I’ve walked through the process of installing WeeWx on Ubuntu and I believe I have the UDP driver for WeatherFlow setup correctly.

I’ve enabled verbose logging but I never see any of my sensors come through. All I see is “weatherflowudp: MainThread: Listening for UDP broadcasts to IP address on port 50222, with timeout 90 and share_socket False…”

After that nothing gets logged. No timeout errors or anything like that. What am I missing?

The first troubleshooting step is to confirm that your WF Hub and WeeWX server are on the same IP subnet or VLAN, since UDP broadcasts cannot cross routers between subnets.

Ubuntu’s included Python is a stable/sane version, and you should be able to enable share_socket in case you also want to run one of the other third-party WF apps side-by-side on the same system.

Out of curiosity, is your Hub uploading to the WF servers and visible on the SmartWeather web site? You would be surprised at how many owners have stopped their WF install early, never setting up the Hub’s wifi and leaving themselves with only Bluetooth access to the Hub from the smartphone app…

another thing to verify is that you actually have a sensor map in weewx.conf - some people skip/miss that part…

Mine looks like the following - substitute in your sensor IDs of course…

[WeatherFlowUDP]
    driver = user.weatherflowudp
    log_raw_packets = False
    udp_address = <broadcast>
    # udp_address = 0.0.0.0
    # udp_address = 255.255.255.255
    udp_port = 50222
    udp_timeout = 90
    share_socket = True

    [[sensor_map]]
        outTemp = air_temperature.AR-00013349.obs_air
        outHumidity = relative_humidity.AR-00013349.obs_air
        pressure = station_pressure.AR-00013349.obs_air
        outTempBatteryStatus = battery.AR-00013349.obs_air
        windSpeed = wind_speed.SK-00013695.rapid_wind
        windDir = wind_direction.SK-00013695.rapid_wind
        UV = uv.SK-00013695.obs_sky
        rain = rain_accumulated.SK-00013695.obs_sky
        windBatteryStatus = battery.SK-00013695.obs_sky
        radiation = solar_radiation.SK-00013695.obs_sky

Thanks for the response!

Yes my WF Hub is on the same subnet as WeeWx. I can ping the WF Hub from my WeeWx Ubuntu server.

Also my the WiFi on the bridge is setup correctly. You can review my station data here: https://smartweather.weatherflow.com/station/7271/grid

Is the Ubuntu firewall on? Is there an exception for 50222/UDP (and not TCP) in the firewall config???

Try to listen for udp/50222 from the command line

  • sudo netcat -ul 50222
  • sudo tcpdump -n udp port 50222

netcat will return the first one it hears and you’ll be able to see the content since it’s pretty obvious JSON. tcpdump will just show you that it’s receiving stuff.

root@pi3jr-wifi:/var/www/html# netcat -ul 50222
{"serial_number":"SK-00015850","type":"rapid_wind","hub_sn":"HB-00010412","ob":[1586624164,0.89,230]}


root@pi3jr-wifi:/var/www/html# tcpdump -n udp port 50222
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on wlan0, link-type EN10MB (Ethernet), capture size 262144 bytes
08:56:09.119651 IP 192.168.1.189.50222 > 255.255.255.255.50222: UDP, length 106
08:56:09.121018 IP 192.168.1.189.50222 > 255.255.255.255.50222: UDP, length 99
08:56:10.147552 IP 192.168.1.151.50222 > 255.255.255.255.50222: UDP, length 99
08:56:11.476180 IP 192.168.1.151.50222 > 255.255.255.255.50222: UDP, length 101
^C

I’m at about 8 months on this driver, working great - Thanks!

I’m considering updating to WeeWX 4.0 soon, are there any known issues with the driver that will need to be adjusted to be compatible?

1 Like

Yes, there are Python 3.x issues. Please send me an email at the address in the readme file, and I’ll send you the pre-release version with WeeWX 4.x and Python 3.x support…