Last active
January 14, 2019 07:19
-
-
Save discarn8/cdf3557bcaa31ac089a8432c867788db to your computer and use it in GitHub Desktop.
Raspberry_PI_CPU_GPU_TEMP_in_FAHRENHEIT_write_to_mysql
This file contains 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 | |
#using: awk '{print $1/1000 * 1.8 + 32}' /sys/class/thermal/thermal_zone0/temp | |
CPUSOURCE=`cat /sys/class/thermal/thermal_zone0/temp` | |
GPUSOURCE=`vcgencmd measure_temp | cut -c 6-9` | |
CPUCALC=`expr $CPUSOURCE / 1000` | |
CPU=`echo “scale=2;((9/5) * $CPUCALC ) + 32”| bc` | |
GPU=`echo “scale=2;((9/5) * $GPUSOURCE ) + 32”| bc` | |
#Or use | |
#CPU=$(awk '{print $1/1000 * 1.8 + 32}' /sys/class/thermal/thermal_zone0/temp | awk '{printf("%d\n",$1 + 0.5)}') | |
echo CPU = $CPU | |
echo GPU = $GPU | |
#Output: | |
#CPU = 100.40 | |
#GPU = 100.22 | |
#write the temps to a table, assuming a .my.cnf is in place | |
/usr/bin/mysql -h 192.168.0.2 -D temp_table -e "INSERT INTO temps (ctemp, gtemp) VALUES ('$CPU','$GPU')" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Requirements:
bc