Sunday, March 10, 2024

Staying out of the Ditch (Part I)

Staying Out of the Ditch

About four years ago, now, we had a helluva scare in Wyoming. A sudden gust of wind pushed us into the ditch. Emmy was driving; we had slowed down to about 45mph, thankfully.  

How she kept us upright is our best evidence of Divine Intervention to date.  Getting out and walking around our landing area, it was apparent that had we entered the ditch 20 feet sooner or later, the slope was much steeper, and we surely would have tipped over with a horrific outcome.

I'd like to try to avoid that again, if possible.

In the interim, I've kept two apps up and running on my phone: a NOAA weather radar and an app that displays Wind Speeds in the area.

But that meant I was glancing at the phone instead of the road.  I figured it was time to try to do one better.


Latitude and Longitude

There's already a GPS Receiver on top of the RV. I put it there. It's an inexpensive (<$10 USD) USB dongle with an older "ublox-7" GPS chip inside. While dated and likely not good enough for high precision needs, it consistently sends me my current location.

Like everything else in my RV, home and life, the data comes in as a MQTT message, JSON formatted. For example:

{"topic":"GPS","version":"2.0","dateTime":"2024-03-10T14:27:24-0600", "mode":"3D", "latitude":44.021032, "longitude":-125.088211, "altitude":5193.28, "speed":1.2, "track":-100.0, "climb":0.0, "GDOP":"GOOD", "HDOP":"MODERATE", "VDOP":"MODERATE", "distance":82.87}

[NB: the xDOP values are not great because the testing receiver I use is indoor. Outdoor, the xDOP values are typically 'EXCELLENT'. ]

So every minute, I know my location on the planet.

National Oceanic and Atmospheric Administration


Or NOAA, for short. NOAA has a weather department. That weather department has a public, free API that we can query for all sorts of fun weather data. In my case, I'm most interested in the Forecast and Alerts.

You can read more about the API; in my case I decided to ask the API for the hourly forecast data for my location. You pass in your lat/lon coordinates to the API and NOAA sends back a large JSON response with a ton of information.

I'll spare you the details here, I may go into them in a subsequent post. But I trim down the NOAA response to the data I'm interested in.

I'm only interested in the next four hours. The conditions, the forecasted temperature, wind speed and direction and the chance of precipitation.

If the wind speeds are forecasted to be above 10 MPH, then I'll color the data red:



My GPS receiver sends me my current location every minute. But I'm only calling the NOAA forecast API every 15 minutes.  (I doubt I could drive the RV fast enough to exit the current NOAA forecast bounding area to make more frequent updates worth the effort.)

A little implementation detail - every 'last' forecast data is cached. I'm using Node-Red to code a lot of the functionality here.  When this webpage is brought up, it asks for the last cached forecast.  That way there's relevant data to display immediately; the webpage does not have to wait 1..15 minutes for forecast data.


I'll end this post here. And cover the Weather Alerts section in the next post, Part II.


No comments :

Post a Comment