Guest User

Raspberry Pi 3 Temp / CPU script

a guest
Mar 19th, 2016
1,471
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # Usage: sh-pi-get_cpu_temp
  4. #
  5. # Monitors CPU clock speed and temperature.
  6. #
  7. # This program is free software: you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation, either version 3 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # This program is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. #
  20.  
  21. cpu_freq=/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
  22. cpu_temp=/sys/class/thermal/thermal_zone0/temp
  23. if [ -e $cpu_freq ] ; then
  24. if [ -e $cpu_temp ] ; then
  25. while [ true ] ; do
  26. clk=$(cat $cpu_freq)
  27. cpu=$(cat $cpu_temp)
  28. echo --------------------------------------------------------
  29. echo CPU Frequency is: $(($clk/1000))" Mhz \r"
  30. awk '{print "Temp in degrees Fahrenheit is:",$1/1000 * 1.8 + 32}' /sys/class/thermal/thermal_zone0/temp
  31. awk '{printf("Temp in degrees Celcius is: %.1f °C\n",$1/1e3)}' /sys/class/thermal/thermal_zone0/temp
  32. echo --------------------------------------------------------
  33. sleep 1
  34. done
  35. fi
  36. fi
Advertisement
Add Comment
Please, Sign In to add comment