Created
August 14, 2018 14:31
-
-
Save starbuck93/4b594ee655eef9c7febf5b2550c8ade1 to your computer and use it in GitHub Desktop.
Quick script to echo the CPU temperature in F and C of a Raspberry Pi Zero, in my case
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
<?php | |
$command = "cat /sys/class/thermal/thermal_zone0/temp"; | |
$temp = exec($command); | |
$tempC1 = ((float) $temp)/1000; | |
$tempF1 = ($tempC1*(9.0 / 5.0)) + 32.0; | |
$str = '{"cpu_temperature_F":'.number_format($tempF1,2).',"cpu_temperature_C":'.number_format($tempC1,2).'}'; | |
echo $str; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment