Skip to content

Instantly share code, notes, and snippets.

@ChrisWeiss
Last active January 22, 2020 02:02
Show Gist options
  • Save ChrisWeiss/92383868bebc1356077124ed20fc9b92 to your computer and use it in GitHub Desktop.
Save ChrisWeiss/92383868bebc1356077124ed20fc9b92 to your computer and use it in GitHub Desktop.
RTLAMR systemctl setup/files for raspberry pi.

Basic steps to get the server up and running on a Raspberry Pi with 2019-09-26-raspbian-buster-lite

Install OS, go through raspi-setup and set password, hostname, locale, time-zone, etc. Update all the things:

$ sudo apt-get update && sudo apt-get upgrade -y

Install Git and GoLang

$ sudo apt-get install git golang rtl-sdr

Add /home/pi/go to the path in .profile and source it

Install RTLAMR pieces

$ go get github.com/bemasher/rtlamr

$ go get github.com/bemasher/rtlamr-collect

To autostart everything, copy below files into /etc/systemd/system/ and update params as needed

$ sudo systemctl daemon-reload

$ sudo systemctl start rtl-tcp rtlamr-collect

Check /var/log/daemon.log for status

If everything looks good, set up the Pi to load those services on reboot

$ sudo systemctl enable rtl-tcp rtlamr-collect

[Unit]
Description=Software Defined Radio TCP Server
Wants=network.target
After=network.target
[Service]
ExecStart=/usr/bin/rtl_tcp
Restart=always
[Install]
WantedBy=multi-user.target
GOPATH=/home/pi/go
RTLAMR_FORMAT=json
RTLAMR_MSGTYPE=idm
#RTLAMR_FILTERID=00000000 # UPDATE TO MATCH YOUR METER ID
COLLECT_INFLUXDB_HOSTNAME=http://YOURINFLUXDBHOST:8086
COLLECT_INFLUXDB_DATABASE=rtlamr
COLLECT_INFLUXDB_USER=YOURINFLUXDBUSER
COLLECT_INFLUXDB_PASS=YOURINFLUXDPASSWORD
[Unit]
Description=RTLAMR Collector
BindsTo=rtl-tcp.service
After=rtl-tcp.service
[Service]
EnvironmentFile=/etc/systemd/system/rtlamr-collect.env
ExecStart=/bin/sh -c '/home/pi/go/bin/rtlamr | /home/pi/go/bin/rtlamr-collect'
Restart=always
RestartSec=30
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment