Skip to content
Luca Weiss edited this page Aug 5, 2019 · 1 revision

MQTT

How to forward received sensors messages to MQTT on Linux?

rtl_433 -F "mqtt://mqtt.yourserver.com,events=/test/a,devices=/test/b"

Exemple

/test/a {"time":"2019-05-09 23:51:27","model":"HIDEKI TS04 sensor","rc":2,"channel":4,"battery":"OK","temperature_C":12.2,"humidity":57,"mic":"CRC"}
/test/b/HIDEKI_TS04_sensor/4/rc 2
/test/b/HIDEKI_TS04_sensor/4/channel 4
/test/b/HIDEKI_TS04_sensor/4/battery OK
/test/b/HIDEKI_TS04_sensor/4/temperature_C 12.200000
/test/b/HIDEKI_TS04_sensor/4/humidity 57
/test/b/HIDEKI_TS04_sensor/4/mic CRC

You can use mosquitto to see the received messages.

mosquitto_sub -v -h mqtt.yourserver.com -p 1883 -t '/test/a/#' -t '/test/b/#'

How to forward received sensors messages to MQTT on Linux (Old way)?

Install mosquitto-clients (apt-get install mosquitto-clients)

Edit a file called rtl2mqtt.sh ( gedit rtl2mqtt.sh )

Add the following content replacing mqtt.yourserver.com by your server, adding your password if necessary and adding the real path to your rtl_433 binary.

while true; do 
	echo "starting forwarding RTL to mosquitto" 
     	{PathToRTL433}/rtl_433 -Fjson | mosquitto_pub -h mqtt.yourserver.com -p 1883 -t 'your_topic/rtl433' -l
	sleep 5
done

Make this script runnable chmod 755 rtl2mqtt.sh and run it ./rtl2mqtt.sh

By running the following command, you'll be able to listen to messages coming from mqtt.

mosquitto_sub -v -h mqtt.yourserver.com -p 1883 -t 'your_topic/rtl433'

You will start to receive messages like

your_topic/rtl433 {"time" : "2019-02-26 19:43:32", "model" : "Nexus Temperature/Humidity", "id" : 193, "channel" : 1, "battery" : "OK", "temperature_C" : 19.200, "humidity" : 45}
your_topic/rtl433 {"time" : "2019-02-26 19:43:43", "model" : "HIDEKI TS04 sensor", "rc" : 13, "channel" : 5, "battery" : "OK", "temperature_C" : 7.300, "humidity" : 68, "mic" : "CRC"}`
your_topic/rtl433 {"time" : "2019-02-26 19:43:44", "model" : "HIDEKI TS04 sensor", "rc" : 13, "channel" : 5, "battery" : "OK", "temperature_C" : 7.300, "humidity" : 68, "mic" : "CRC"}`