RTL SDR - JRInge/ha GitHub Wiki

Adding a system user for the radio:

sudo adduser rtlsdr --system --no-create-home --ingroup plugdev

/etc/rtl_433.conf:

frequency 433550000
protocol 36
output mqtt://localhost:1883,events

When is ACTION=="add" (un)necessary in a Udev rule?

I want to understand when you do and do not need to use terms like ACTION=="add" or ACTION=="remove" in a udev rule.

Scenario:

I want the rtl_433 monitoring programme to run continuously when my RTL-SDR dongle is plugged into my USB port. rtl_433 should start on system boot (but only if the dongle is present), or immediately the dongle is plugged in; restart if it crashes; and stop if the dongle is removed. I have achieved this using a udev rule with a systemd service unit:

When the rtl-sdr library is installed, it creates /etc/udev/rules.d/rtl-sdr.rules, which contains lots of rules like the following, to detect different types of RTL-SDR dongle:

# RTL2832U OEM vid/pid, e.g. ezcap EzTV668 (E4000), Newsky TV28T (E4000/R820T) etc.
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0bda", ATTRS{idProduct}=="2838", ENV{ID_SOFTWARE_RADIO}="1", MODE="0660", GROUP="plugdev"

When my dongle is plugged in, this creates the device /dev/bus/usb/001/003. The device disappears when the dongle is removed, and reappears when it is plugged in again, but with the 003 part incremented to the next number. I've added the following rule to the end of the rtl-sdr.rules file:

SUBSYSTEMS=="usb", ENV{ID_SOFTWARE_RADIO}=="1", SYMLINK+="rtlsdr%n", TAG+="systemd", ENV{SYSTEMD_WANTS}="rtl-sdr@%n.service"

Once I do udevadm control --reload, this causes a symlink /dev/rtlsdr3 to be created when the dongle is plugged in, pointing to the original device. In this case though, the 3 in the symlink doesn't seem to increment when the dongle is re-inserted.