Skip to content

Instantly share code, notes, and snippets.

@Parsiuk
Created July 13, 2019 12:35
Show Gist options
  • Select an option

  • Save Parsiuk/d229467f5ae065fea7665ccb7bcdc596 to your computer and use it in GitHub Desktop.

Select an option

Save Parsiuk/d229467f5ae065fea7665ccb7bcdc596 to your computer and use it in GitHub Desktop.
RaspberryPi 4 temperature logging
#!/bin/bash
# Run this script in cron, for example:
# */5 * * * * /home/user/temp.sh >> /home/user/temp_log.tsv
timestamp=`date "+%Y/%m/%d %H:%M:%S"`
temperature=`sudo cat /sys/class/thermal/thermal_zone0/temp`
cpu_frequency=`sudo cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq`
# `bc` is required, install it with `apt install bc`
temperature_calculated=`echo "scale=2; ${temperature}/1000" | bc`
frequency_calculated=`echo "scale=2; ${cpu_frequency}/1000" | bc`
echo -e "${timestamp}\t${temperature_calculated}\t${frequency_calculated}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment