The Problem
I am running an off-site weather station which is connected to meteohub. This enables me to create beautiful graphs and charts, but i wanted to display the the data on my arduino yun at home. So i had to find a way how to transmit this data via the Internet,
The Solution
Since it did not want to create a VPN tunnel I choose a solution where the weatherstation (to be more precise meteohub) is actively pushing the data to the Internet using MQTT. From there on everybody can fetch it and use it for his/her own purpose.
Step 1: Fetch the data
The setup is really simple. If you take a deep-dive into the documentation of meteohub, then you discover that it exposes all of its data (current weather data as well as aggegated data) via the network port 5558. So if you run netcat (the swiss army knife of TCP/IP) to read out this data the you will get a list of all the values.
Step 2: Filter the data
Since i am only interested in the most actual data (and not in the 100 other ones) i had to filter the data. This can be done via grep. Just have a look at the examples.
Step 3: Publish them via MQTT
The first step is to make sure that we can publis the data. For this purpose i am using mosquitto_pub which is a simple mqtt client that will publish a message on a single topic and exit.
So if we put it all together then we end up with a command like this:
Well - this one-liner does all that we want, by combining all the tools in the commandline.
- It fetches all available data from my meteohub station via netcat
- It filters out all messages but the ones which are containing the string actual
- it reassembles a command using awk
- it passes this command to the shell which executes it.