Welcome to bytebang » The blog about all and nothing » Streaming wireless weatherstationdata via MQTT

Streaming wireless weatherstationdata via MQTT

Dec 29 2020

The Problem

A lot of 433 MHz based weather stations are sending their data to their paired receiver. But how would you receive all the stations within your vincity and stream the data into the internet ?

The Solution

rtl_433 is a tool which takes samples from an attached RTL-SDR stick and decodes them. The name already suggests that it will operate in the 433 MHz frequency area where a lot of weatherstations are boradcasting their values.

So lets start by just calling the executable (which can e installed via your favourite pacakgemanager in linux within a few seconds):

rtl_433  
rtl_433 version 20.02-38-gf26830d branch master at 202004251247 inputs file rtl_tcp RTL-SDR
Use -h for usage help and see https://triq.org/ for documentation.
Trying conf file at "rtl_433.conf"...
Trying conf file at "/home/gue/.config/rtl_433/rtl_433.conf"...
Trying conf file at "/usr/local/etc/rtl_433/rtl_433.conf"...
Trying conf file at "/etc/rtl_433/rtl_433.conf"...
Registered 123 out of 151 device decoding protocols [ 1-4 8 11-12 15-17 19-21 23 25-26 29-36 38-60 63 67-71 73-100 102-105 108-116 119 121 124-128 130-149 151 ]
Detached kernel driver
Found Rafael Micro R820T tuner
Exact sample rate is: 250000.000414 Hz
[R82XX] PLL not locked!
Sample rate set to 250000 S/s.
Tuner gain set to Auto.
Tuned to 433.920MHz.
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
time      : 2020-12-22 09:50:03
model     : LaCrosse-TX  id        : 34
Temperature: 0.1 C       Integrity : PARITY
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
time      : 2020-12-22 09:50:03
model     : LaCrosse-TX  id        : 34
Temperature: 0.1 C       Integrity : PARITY
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
time      : 2020-12-22 09:50:03
model     : LaCrosse-TX  id        : 34
Temperature: 0.1 C       Integrity : PARITY

Well, you can see that a weatherstation transmits its temperature of 0.1 degrees celsius to its basestation - fine.

Now we want to send this information to a MQTT boker of your choice:

rtl_433  -F "mqtt://test.mosquitto.org,devices=hg/rtl_433/M[model]/I[id]/C[channel]"
rtl_433 version 20.02-38-gf26830d branch master at 202004251247 inputs file rtl_tcp RTL-SDR
Use -h for usage help and see https://triq.org/ for documentation.
Trying conf file at "rtl_433.conf"...
Trying conf file at "/home/gue/.config/rtl_433/rtl_433.conf"...
Trying conf file at "/usr/local/etc/rtl_433/rtl_433.conf"...
Trying conf file at "/etc/rtl_433/rtl_433.conf"...
Publishing MQTT data to itsp.htl-leoben.at port 1883
Publishing device info to MQTT topic "hg/rtl_433/M[model]/I[id]/C[channel]".
Registered 123 out of 151 device decoding protocols [ 1-4 8 11-12 15-17 19-21 23 25-26 29-36 38-60 63 67-71 73-100 102-105 108-116 119 121 124-128 130-149 151 ]
Detached kernel driver
Found Rafael Micro R820T tuner
Exact sample rate is: 250000.000414 Hz
[R82XX] PLL not locked!
Sample rate set to 250000 S/s.
Tuner gain set to Auto.
Tuned to 433.920MHz.
MQTT Connected...
MQTT Connection established.

This command tells rtl_433 to connect to the test.mosquitto.org broker and to send all received data in the /hg/rtl_433/# topic.

Theresult looks like this (viewed in the HiveMQ Websocket Client)

rtl433_mqtt_messages.png

If you want to dig deeper, then have a look at the documentation of rtl_433.

73 de OE6GUE

Get Social


(c) 2021, by bytebang e.U. - Impressum - Datenschutz / Nutzungsbedingungen
-