I’m using an rlt_433 USB dongle for sniffing air things (mostly at this point a wireless bbq temperature monitor/transmitter) and it’s time to move it over to Docker so that I can include it in my compose stack. Getting rtl_433 running on Docker is already very well documented.
I then want to leverage mosquitto, influxdb, and Grafana to create a visualization of the data.
I already have mosquitto and influxdb containers in my compose stack, like this:
mosquitto:
image: "eclipse-mosquitto:1.6"
container_name: mosquitto
environment:
TZ: ${TZ}
restart: unless-stopped
volumes:
- "${DATADIR}/mosquitto/config:/mosquitto/config"
- "${DATADIR}/mosquitto/data:/mosquitto/data"
- "${DATADIR}/mosquitto/log:/mosquitto/log"
ports:
- 1883:1883
influxdb:
image: "influxdb:1.8"
container_name: influxdb
environment:
TZ: ${TZ}
restart: unless-stopped
volumes:
- "${DATADIR}/influxdb/data:/var/lib/influxdb"
healthcheck:
test: ["CMD", "curl", "-sI", "http://127.0.0.1:8086/ping"]
interval: 30s
timeout: 1s
retries: 24
ports:
- 127.0.0.1:8086:8086
Add grafana to the compose stack:
grafana:
image: "grafana/grafana:latest"
container_name: grafana
environment:
TZ: ${TZ}
restart: unless-stopped
user: "$PUID:$PGID"
depends_on:
- influxdb
volumes:
- "/data1/grafana/data:/var/lib/grafana"
ports:
- 3000:3000
Let’s create a database to write rtl data by connecting to the influxdb container:
# influx
Connected to http://localhost:8086 version 1.8.6
InfluxDB shell version: 1.8.6
> create database rtl433
> create user rtl433 with password 'muchsecret'
> grant all on rtl433 to rtl433
Now, figure out the device ID of the rtl_433 dongle (plugged in to my docker host):
slade@linux-home:~$ lsusb|grep RTL
Bus 005 Device 004: ID 0bda:2838 Realtek Semiconductor Corp. RTL2838 DVB-T
So, bus 005 device 004.
Add rtl_433 to the Docker compose stack. Note the device id matches what we found when running lsusb and we’re outputting to the influxdb database we previously created.
rtl433:
image: hertzg/rtl_433:latest
devices:
- '/dev/bus/usb/005/004'
command:
- '-Mtime:unix:usec:utc'
- '-Mbits'
- '-Mlevel'
- '-Mprotocol'
- '-Mstats:2:300'
- '-Fmqtt://mosquitto:1883, retain=1'
- '-Finflux://influxdb:8086/write?db=rtl433'
Start your containers:
slade@linux-home:~$ docker-compose up -d
Confirm that the containers are running.
Now find the data like this:
