{"id":2095,"date":"2022-01-20T20:20:40","date_gmt":"2022-01-20T19:20:40","guid":{"rendered":"https:\/\/www.pa3hcm.nl\/?p=2095"},"modified":"2022-01-20T20:25:14","modified_gmt":"2022-01-20T19:25:14","slug":"ecowither-logging-ecowitt-weather-data-to-influxdb","status":"publish","type":"post","link":"https:\/\/www.pa3hcm.nl\/?p=2095","title":{"rendered":"Ecowither: logging Ecowitt weather data to InfluxDB"},"content":{"rendered":"\n<div class=\"wp-block-image\"><figure class=\"alignright size-medium\"><a href=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2022\/01\/Screenshot-from-2022-01-20-19-57-41.png\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"132\" src=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2022\/01\/Screenshot-from-2022-01-20-19-57-41-300x132.png\" alt=\"\" class=\"wp-image-2098\" srcset=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2022\/01\/Screenshot-from-2022-01-20-19-57-41-300x132.png 300w, https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2022\/01\/Screenshot-from-2022-01-20-19-57-41-1024x449.png 1024w, https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2022\/01\/Screenshot-from-2022-01-20-19-57-41-768x337.png 768w, https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2022\/01\/Screenshot-from-2022-01-20-19-57-41.png 1199w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/figure><\/div>\n\n\n\n<p>Last summer my old WS2300 weather station finally gave up, after 15 years of service. So I bought a new one, the <em>Waldbeck Halley Professional Weather Station<\/em> (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.<\/p>\n\n\n\n<!--more-->\n\n\n\n<div class=\"wp-block-image\"><figure class=\"alignright size-large is-resized\"><a href=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2022\/01\/Screenshot_20220120-194635.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2022\/01\/Screenshot_20220120-194635-481x1024.png\" alt=\"\" class=\"wp-image-2097\" width=\"241\" height=\"512\" srcset=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2022\/01\/Screenshot_20220120-194635-481x1024.png 481w, https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2022\/01\/Screenshot_20220120-194635-141x300.png 141w, https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2022\/01\/Screenshot_20220120-194635-768x1636.png 768w, https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2022\/01\/Screenshot_20220120-194635-721x1536.png 721w, https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2022\/01\/Screenshot_20220120-194635-962x2048.png 962w, https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2022\/01\/Screenshot_20220120-194635.png 1080w\" sizes=\"auto, (max-width: 241px) 100vw, 241px\" \/><\/a><figcaption>WSview configuration screen to log to a custom weather service<\/figcaption><\/figure><\/div>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>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:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">POST \/ HTTP\/1.1\nHOST: localhost\nConnection: Close\nContent-Type: application\/x-www-form-urlencoded\nContent-Length:537 \nPASSKEY=307826236D0133E06009CE7FAFBBAFC4&amp;stationtype=WH2650A_V1.6.8&amp;dateutc=2021-12-24+11:31:57&amp;tempinf=66.0&amp;humidityin=51&amp;baromrelin=29.565&amp;baromabsin=29.565&amp;tempf=47.8&amp;humidity=91&amp;winddir=261&amp;windspeedmph=8.95&amp;windgustmph=14.76&amp;maxdailygust=21.70&amp;solarradiation=57.25&amp;uv=0&amp;rainratein=0.000&amp;eventrainin=0.071&amp;hourlyrainin=0.000&amp;dailyrainin=0.012&amp;weeklyrainin=0.110&amp;monthlyrainin=1.421&amp;yearlyrainin=24.256&amp;totalrainin=24.256&amp;temp1f=49.46&amp;humidity1=98&amp;temp2f=63.50&amp;humidity2=51&amp;wh65batt=0&amp;wh25batt=0&amp;batt1=0&amp;batt2=0&amp;freq=868M&amp;model=WH2650<\/pre>\n\n\n\n<p>Although I&#8217;m most familiar with MySQL\/MariaDB databases, I decided to use InfluxDB. This is a &#8220;time series database&#8221; 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!<\/p>\n\n\n\n<p>There was still one piece missing: the API\/webserver to catch the HTTP POST&#8217;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&#8217;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 &#8216;Ecowither&#8217;, which is a conjunction of &#8216;Ecowitt&#8217; and &#8216;Weather&#8217;.<\/p>\n\n\n\n<p><a href=\"https:\/\/github.com\/pa3hcm\/ecowither\" target=\"_blank\" rel=\"noreferrer noopener\">I published my code on Github<\/a>. The repository also includes a kubernetes deployment file, since I run both Ecowither and InfluxDB on my Kubernetes cluster.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2022\/01\/Screenshot-from-2022-01-20-20-17-08.png\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"709\" src=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2022\/01\/Screenshot-from-2022-01-20-20-17-08-1024x709.png\" alt=\"\" class=\"wp-image-2099\" srcset=\"https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2022\/01\/Screenshot-from-2022-01-20-20-17-08-1024x709.png 1024w, https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2022\/01\/Screenshot-from-2022-01-20-20-17-08-300x208.png 300w, https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2022\/01\/Screenshot-from-2022-01-20-20-17-08-768x531.png 768w, https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2022\/01\/Screenshot-from-2022-01-20-20-17-08-1536x1063.png 1536w, https:\/\/www.pa3hcm.nl\/wp-content\/uploads\/2022\/01\/Screenshot-from-2022-01-20-20-17-08.png 1734w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption>Example of my weather data in InfluxDB, showing the air shockwave caused by a vulcano erruption near Tonga, on January 15th 2022.<\/figcaption><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>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, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2098,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[71],"tags":[105,104,106],"class_list":["post-2095","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-software","tag-flask","tag-python","tag-weather"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":6}},"_links":{"self":[{"href":"https:\/\/www.pa3hcm.nl\/index.php?rest_route=\/wp\/v2\/posts\/2095","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pa3hcm.nl\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pa3hcm.nl\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pa3hcm.nl\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pa3hcm.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2095"}],"version-history":[{"count":3,"href":"https:\/\/www.pa3hcm.nl\/index.php?rest_route=\/wp\/v2\/posts\/2095\/revisions"}],"predecessor-version":[{"id":2103,"href":"https:\/\/www.pa3hcm.nl\/index.php?rest_route=\/wp\/v2\/posts\/2095\/revisions\/2103"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.pa3hcm.nl\/index.php?rest_route=\/wp\/v2\/media\/2098"}],"wp:attachment":[{"href":"https:\/\/www.pa3hcm.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2095"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pa3hcm.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2095"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pa3hcm.nl\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2095"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}