Run RTL_433 in the background on Raspberry Pi

1,046 views
Skip to first unread message

ohhforfucksake

unread,
Oct 31, 2019, 11:32:56 PM10/31/19
to rtl_433
 Hi all,

I'd like to run rtl_433 on a raspberry pi. I can get it working fine when the terminal is open, but it wont let me do anything else with that terminal,and if i close it that ends rtl_433.

I have a simple script that I can run inside Raspbian GUI but I cannot get it to run at start-up/boot (when its scrolling down the screen showing what's starting), as a system service.( I'm not sure if that's what its called)


#!/bin/bash

echo "RTL_433 Startup script"

echo "rtl_433 -C si -M notime -M newmodel -F json | mosquitto_pub -t home/acurite -l"

rtl_433 -C si -M notime -M newmodel -F json | mosquitto_pub -t home/acurite -l



I don't wish for this device to boot to a gui. Just sit there and do nothing at a logon prompt.

Am I missing something that makes it extremely simple, or it it just as complicated as it's always been?

I'm and old hand at computers but Linux has always confused me with its 47 ways of doing the same thing and none of them really explained without two weeks of other reading. (I'm old and slow)


Thanks in advance.

Christian Zuckschwerdt

unread,
Nov 1, 2019, 4:08:00 AM11/1/19
to rtl_433
The easiest and most robust way is to use a supervisor that starts as a system service and runs (and restarts) rtl_433. E.g. Supervisord, with something like this in the config file:

[program:rtl_433]
command=/PATH-TO-RTL_433/rtl_433 -C si -M notime -M newmodel -F "mqtt,devices=home/acurite"
user=YOUR-USER

Gabriel Klein

unread,
Nov 1, 2019, 4:48:10 AM11/1/19
to rtl_433
My tips on raspberry (it works great for me!).
I have no particular problems with this environment... rtl_433 works just great!

Do a
> apt-get update; apt-get upgrade; apt-get dist-upgrade;
> rpi-upgrade

Add a user to dialout (I like to run rtl_433 as a user)
sudo adduser my_rtl433_user dialout

I add my script in a crontab (crontab -e)
@reboot /home/
my_rtl433_user/startRtl433.sh >>/tmp/rtl433.log
Not the "best way" to do it... but I'm quite happy with it.

In my startRtl433.sh, I have
--------------
#/usr/bin/sh

cd /home/
my_rtl433_user/

while true; do
echo "starting command"
rtl_433 -F "mqtt://10.0.0.60,events=/gabpi2/events,devices=/gabpi2/devices"
sleep 5
done
---------------

Another "magical" command is
nohup

In my "root" crontab, I have 2 useful commands not directly related.
@reboot /root/data/boot-lowenergy.sh > /dev/null
30 * * * * /root/data/check-inet.sh > /dev/null

----------------

This script shut down the hdmi interface (0.5 watts...)
in boot-lowenergy.sh

#/usr/bin/sh

#echo date
now=`date +%Y.%m.%d\ %H:%M:%S`
echo $now >"/root/reboot.txt"

# Shutdown TV service
/opt/vc/bin/tvservice -o

# Stop swap
swapoff -a

# Don't work on old RPB - Switch off power led - may be reversed on some RPI!!
# See: http://www.jeffgeerling.com/blogs/jeff-geerling/controlling-pwr-act-leds-raspberry-pi
echo 0 | sudo tee /sys/class/leds/led0/brightness
echo 0 | sudo tee /sys/class/leds/led1/brightness

# Create ramdisk
rm -rf /tmp/ram
mkdir /tmp/ram
mount -t ramfs -o size=16M ramfs /tmp/ram

--------------------

This script restart the wlan interface if disconnected (I have issues with some of the RPI).
in check-inet.sh
Don't forget to change the IP of your router.

#/usr/bin/sh

ping -c1 10.0.0.1 > /dev/null

if [ $? != 0 ]
then
    # If you want to restart the RPI.
    #sudo /sbin/shutdown -r now
    /sbin/ifdown 'wlan0'
    sleep 5

    # you can remove this line... create a "blinking red" led effect on my RPI
    # python /root/bin/led/lederror.py

    /sbin/ifup --force 'wlan0'
    sleep 5
fi

# Update local time
ntpdate pool.ntp.org

-------------------

It's a set of "tips"... but resolve some issues for me!
(I have some RPI cameras running since 4-5 years...)


It will keep you process in the background if you run it manually.

Best regards,
Gab
Reply all
Reply to author
Forward
0 new messages