Sunday, March 10, 2024

Staying out of the Ditch (Part II)

 

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.  

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

See Part I of this post where I cover off how I get the forecasted weather conditions for my current location.

A quick recap:

  • there's a GPS receiver on top of the RV that tells me my current location, as a latitude/longitude pair every minute
  • I'm calling the NOAA's weather API to get the weather forecast for my current location
  • I'm also calling the NOAA's Alerts API to pull any severe weather conditions that are around me.


"The World Needs More Lerts."

Just like I take my current latitude and longitude and get the hourly weather forecast for "here", I pass those coordinates into the NOAA Alerts API. The NOAA call returns a JSON packet with no alerts, or the ones issued for my area.



NOAA returns a ton of information. And, as before in the forecast return data, I only clip out the information I think is necessary to display.  That's

  • The Event (eg. Wind, Snow, Rain, Flood...)
  • Urgency (Immediate, Expected, Future, Past)
  • Certainty (Observed, Likely, Possible, Unlikely)
  • Severity (Extreme, Severe, Moderate, Minor)
  • SAME Code
  • Details

You can read the NOAA documentation for more information about the return values.   The first four are self-explanatory. The SAME code is a number that you can enter into a Weather Radio that supports such codes. Punch the SAME code into the weather radio, and it will watch for alerts in this area. A SAME code designates a geographic area (more or less).

The last column, details, is simply a constructed hyperlink to the details on this alert. Click it and it will retrieve the full alert data.

Here's an example:



We'll "start to end" Part II here.

Part III, when I get around to it, will go into the implementation details.  But before I end Part II, some thoughts on the "Why?"

Why Bother?

Isn't this "re-inventing the wheel"? Isn't this information -- and more -- already available from a number of apps on any phone in 2024?

Sure.

So why?

A couple of reasons, some selfish, some pragmatic:

  • The apps on a phone are "pull" in nature. I have to take action to get the information. I have to stop watching the road, and press buttons on my phone to request the data.  Pulling data in 2024 is insanely stupid, IMO. The computer(s) have all of the capability to push data to me.
  • The apps on a phone have a user-experience that appeals to their developers. That may or may not be the way I want to consume the data.
  • The apps on the phone have a UI that changes whenever the developer feels like it. That sometimes aggravates me. I just get the muscle-memory set to use the app with minimal thought, and the developer decides to change things.

I can continue to refine the experience to tailor the output to my needs.  Some of the things I've thought about for V2 are:

  • tailor the wind warnings for heightened alert if the direction will be broadside
  • play the Star Trek Red Alert sound when some urgent alert comes in
  • pull up alerts and forecasts for where I'm heading, instead of just where I am
  • add a NOAA radar screen so I can see a current radar

And so on. I'm sure I'll come up with some new ideas for the next revision. Even more so after I use this one in the RV for a while.









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.