weewx-sdr howto document available on git hub

294 views
Skip to first unread message

vince

unread,
Mar 6, 2024, 4:14:25 PMMar 6
to weewx-user
In working with another weewx user to help him gets his SDR station online, it was clear that lots of people (like me) have some problems really understanding some of the rtl-433 and sdr documentation that is out there.

After working through it end-to-end a few times on both ubuntu and on a raspberry pi, I wrote up the whole setup as a howto with examples mainly for future-me but I thought it might be of general interest.  At worst a google search should find it for future folks trying to battle SDR into submission :-)

The howto and a small github repo with a patched/enhanced fork of the SDR driver is at https://github.com/vinceskahan/sdr-howto if you have interest.  Start with the toplevel readme file then read the howto.txt file for how I got it working here.

bell...@gmail.com

unread,
Mar 6, 2024, 5:06:27 PMMar 6
to weewx-user

Vince,
Nice write up.
Begin shameless plug…
Since I am heavily invested in reading things from MQTT, I just run rtl_433 as a separate service and subscribe to the topic. I did this primarily to get the data in a service and secondarily to get sensors that were not ’mapped’.
The service invocation, ‘ExecStart=/usr/local/bin/rtl_433 -M utc -F mqtt://localhost:1883,retain=0,devices=rtl_433[/host]/devices[/type][/model][/subtype][/channel][/id]’
And one topic config looks like this
[[topics]]
ignore = True

[[[message]]] type = individual # Upright freezer (basement) [[[rtl_433/weather-data/devices/Acurite-606TX/77/temperature_C]]] ignore = False unit_system = METRIC name = extraTemp8

It may seem more complicated, but since I was invested in MQTT, it actually simplified it. This was primarily because I could treat rtl_433 as a separate service

End plug

vince

unread,
Mar 6, 2024, 5:20:42 PMMar 6
to weewx-user
Nice.  Lets see your system service file(s) to match !

How would you use that way as a driver and not even need to user weewx-sdr ?  Not remembering if MQTT subscribe can run as a driver.  I just run it as an extension.

bell...@gmail.com

unread,
Mar 6, 2024, 8:13:19 PMMar 6
to weewx-user
I only hesitate to share because I know just enough about systemd to be dangerous. One should NOT use these as a template but as additional information to learn from.
The rtl_433 file. There is additional lines because  I use https://pushover.net to monitor things related to WeeWX
# systemd unit configuration file for rtl_433
#

[Unit]
Description=rtl_433 service
Documentation=https://github.com/merbanan/rtl_433/README.md
# StartLimitIntervalSec=5
After=syslog.target network.target

StartLimitIntervalSec=500
StartLimitBurst=5

[Service]
Environment=UUID=replace_me
Restart=on-failure
RestartSec=5s

# Type=exec
#ExecStart=/usr/local/bin/rtl_433 -M utc -F json -F mqtt://localhost:1883,retain=0,devices=rtl_433[/host]/devices[/type][/model][/subtype][/channel][/id]

ExecStart=/usr/local/bin/rtl_433 -M utc -F mqtt://localhost:1883,retain=0,devices=rtl_433[/host]/devices[/type][/model][/subtype][/channel][/id]

## ExecStartPre runs before, the "-" in the beginning is to let systemd continue even on non-zero exit
ExecStartPre=-/bin/bash -c "curl -fsS -m 10 --retry 5 -o /dev/null https://hc-ping.com/$UUID"

## ExecStopPost runs after, no matter if ExecStart was success or not. The "-" in the beginning is like ExecStartPre
ExecStopPost=-/bin/bash -c "curl -fsS -m 10 --retry 5 -o /dev/null https://hc-ping.com/$UUID/fail"


# Restart script if stopped
#Restart=always
# Wait 30s before restart
#RestartSec=30s

# Tag things in the log
# View with: sudo journalctl -f -u rtl_433 -o cat
#SyslogIdentifier=rtl_433


# NOTE: only works in systemd v236+
#       Debain "stretch" includes v232, "buster" includes v239
# Note also the user must be able to create the file and logrotate must be amended to rote the log.
StandardOutput=file:/var/log/rtl_433.log
StandardError=file:/var/log/rtl_433.log

#StandardOutput=syslog
#StandardOutput=null
#StandardError=syslog

# To run as a non-root user, uncomment and set username and group here:
#User=pi
#Group=pi

[Install]
WantedBy=multi-user.target  


My WeeWX file. I hacked this up in 4.x. I would think 5.x would work just fine.

# source bellrichm-configs weewx/multi/systemd
[Unit]
Description=WeeWX gather %i data
Documentation=https://weewx.com/docs

Requires=time-sync.target
After=time-sync.target
RequiresMountsFor=/home

[Service]
ExecStart=/home/weewx/bin/weewxd --log-label=weewx-%i  /home/weewx/%i.conf
StandardOutput=null
# To run as a non-root user, uncomment and set username and group here:
User=pi
Group=pi

[Install]
WantedBy=multi-user.target

Yup MQTTSubscribe runs as either driver or service. Nothing special to running as a driver.
rich

tarob...@gmail.com

unread,
Mar 7, 2024, 5:01:28 PMMar 7
to weewx-user
Thank you Vince! So when I've setup SDR driver previously, the rtl_sdr package was required but looking at your how-to, only the rtl_433 is needed. I will say getting rtl_sdr on debian bookworm was a challenge as it had to be built from source.
Reply all
Reply to author
Forward
0 new messages