Created
July 13, 2019 12:35
-
-
Save Parsiuk/d229467f5ae065fea7665ccb7bcdc596 to your computer and use it in GitHub Desktop.
RaspberryPi 4 temperature logging
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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