Ecowither: logging Ecowitt weather data to InfluxDB

Last summer my old WS2300 weather station finally gave up, after 15 years of service. So I bought a new one, the Waldbeck Halley Professional Weather Station (also known as WH2650A-WIFI6C6F). This device can log some data (basic outdoor measurements) to online weather services (Wunderground, WeatherCloud, WOW, etc). However, I wanted my data stored locally, also to allow me to browse and publish the data my own way. The vendor does not publish software for this purpose, so I had to code it myself.

WSview configuration screen to log to a custom weather service

The new weather station has an option to post data to a webserver (API). It supports two formats: Wunderground and Ecowitt. I studied both formats and found out that the Wunderground format only reports basic weather data and does not include data of additional sensors. The Ecowitt protocol however reports really all measurements registered by the station, so Ecowitt is the way to go.

The Ecowitt protocol posts data to a weather service using a HTTP POST command. I built a very simple webserver to capture the POST statement, this is how it looks like:

HOST: localhost
Connection: Close
Content-Type: application/x-www-form-urlencoded

Although I’m most familiar with MySQL/MariaDB databases, I decided to use InfluxDB. This is a “time series database” and should easier handle the measurements than a SQL database. Also, InfluxDB v2 has some builtin reporting functions, including a nice dashboard. Also, it is very easy to link Grafana to InfluxDB and create even fancier dashboards!

There was still one piece missing: the API/webserver to catch the HTTP POST’s from the weather station and store the data into InfluxDB. This was the right moment to start experimenting with Flask. This is a web framework for Python and allows you to build an API in just a few lines of code. You basically define URL’s and attach code to each URL. In my case, some metrics had to be converted too: rain in mm instead of inches, temperatures in Celsius instead of Fahrenheit. I named my program ‘Ecowither’, which is a conjunction of ‘Ecowitt’ and ‘Weather’.

I published my code on Github. The repository also includes a kubernetes deployment file, since I run both Ecowither and InfluxDB on my Kubernetes cluster.

Example of my weather data in InfluxDB, showing the air shockwave caused by a vulcano erruption near Tonga, on January 15th 2022.

Leave a Reply