Information used in this Post
- https://forums.raspberrypi.com/viewtopic.php?f=37&t=98407
- https://askubuntu.com/questions/1233708/permanently-disable-wlan0-on-raspberrypi-running-ubuntu-20
- https://docs.influxdata.com/influxdb/v2.1/write-data/no-code/use-telegraf/manual-config/
- https://medium.com/@benmorel/creating-a-linux-service-with-systemd-611b5c8b91d6
Boot Firmware usercfg
sudo nano /boot/firmware/usercfg.txt
# Place "config.txt" changes (dtparam, dtoverlay, disable_overscan, etc.) in
# this file. Please refer to the README file for a description of the various
# configuration files on the boot partition.
dtoverlay=w1-gpio-pullup,gpiopin=4
sys bus w1 devices
cat /sys/bus/w1/devices/28-0516a33f0dff/w1_slave
Shoud output sensor data.
8b 01 4b 46 7f ff 0c 10 88 : crc=88 YES
8b 01 4b 46 7f ff 0c 10 88 t=24687
Create Bash Script
Create a script to output the temperature only.
#!/bin/sh
cat /sys/bus/w1/devices/28-0516a33f0dff/w1_slave | grep t= | cut -c 30-34
Configure Telegraf
[[inputs.exec]]
commands = ["/home/ubuntu/temperatur/temp.sh"]
name_override = "temperature"
data_format = "value"
data_type = "integer"
Create Service
sudo nano /etc/systemd/system/temperatur.service
[Unit]
Description=Temperatur Sensor loggen
After=network.target
StarLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=5
User=ubuntu
ExecStart=/home/ubuntu/temperatur/telegraf --config /home/ubuntu/temperatur/telegraf.conf
[Install]
WantedBy=multi-user.target
Enable Service
sudo systemctl enable temperatur.service