Behind the Weather Dashboard

The second COVID-19 vaccine knocked me out for a couple of days, so while I was recuperating from that, I created a Grafana dashboard with data from my weather station. The station is perched atop a building in midtown Phoenix. The dashboard is still quite a work in progress, but I’m pleased thus far with how it’s coming along.

For those who aren’t in the IT world, Grafana is a software platform that creates visual dashboards from various sources, including time series databases (TSDBs). TSDBs work by collating discrete metrics over time, and they’re usually found in the world of information technology. Instead of network I/O or CPU usage, the principle works for weather statistics: At this time, it was this temperature or the wind speed was that.

HOW IT WORKS

The weather station console (in my case, a Davis Vantage Vue) is connected to an Ambient Weather WeatherBridge device by serial-to-USB cable. In addition to uploading the data to Ambient Weather’s weather dashboard service and the Weather Underground page at MidtownWeather.com, it also spits out an XML feed of the current sensor data. This is what I get:

<logger>
  <TH date="20210425232741" id="th0" temp="34.3" hum="10" dew="-1.7" lowbat="0" />
  <WIND date="20210425232829" id="wind0" dir="276" gust="1.3" wind="2.2" chill="34.3" lowbat="0" />
  <RAIN date="20210425232753" id="rain0" rate="0.0" total="33.0" delta="0.0" lowbat="0" />
  <THB date="20210425232821" id="thb0" temp="30.5" hum="19" dew="4.3" press="963.6" seapress="1002.9" fc="3" lowbat="0" />
</logger>

That’s not particularly useful as it is, so I use the open source Telegraf software to translate the XML output into time-series data. In my case, I run the Telegraf agent in a container to poll the WeatherBridge every 15 seconds, and it reads the appropriate fields. It pushes the data into an InfluxDB server I have in my environment. Using a few queries and databases, I can put the data into the Grafana dashboard.

I don’t change the units when I’m ingesting the data, but I do some math in Grafana to convert as appropriate. Speaking of units, here they are:

  • Outdoor temperature (TH / temp) and outdoor dew point (TH / dew): ºC
  • Wind direction (WIND / dir): Degrees (0º is north, 90º is west, etc.)
  • Wind speed (WIND / gust): Meters per second (NB: WIND / wind is a calculated two-minute average of wind)
  • Barometric pressure (THB / seapress): Hectopascals

For obvious reasons (i.e., living in Phoenix), I’m a bit unsure of how rainfall is calculated. According to the WeatherBridge documentation, RAIN / total is supposedly the entire amount of rainfall recorded. The number in there now (33.0 mm) is how much rain we’ve had in Phoenix in 2021 as of the time of writing. I’ll figure out more when we have more rain!

I’m still learning a lot about Grafana’s capabilities, especially when it comes to minima and maxima by calendar day, month, or year. There’s also supposedly a function to toggle it so units are displayed in either all US units (inches, miles per hour, inches of mercury) or metric units (millimeters, meters per second, hectopascals). That’ll be version 2!

EDIT TO ADD: If you’re interested in deploying this in your own environment, I’ve thrown a sample configuration file on my GitHub page. This runs in a Docker container, and you’ll also need docker-compose installed.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.