LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware > Slackware - ARM
User Name
Password
Slackware - ARM This forum is for the discussion of Slackware ARM.

Notices


Reply
  Search this Thread
Old 11-12-2016, 03:52 PM   #1
ag33k
Member
 
Registered: Mar 2013
Location: Portugal
Distribution: Slackware
Posts: 98

Rep: Reputation: Disabled
RPi CPU and GPU temperatures


This how I did on my RPi3 running Slackware14.2 current

Code:
cd /usr/local/bin
ln -s /opt/vc/bin/vcgencmd


Edit /etc/ld.so.conf thus:
Code:
    /lib
    /usr/lib
    /usr/local/lib
    /usr/arm-slackware-linux-gnueabi/lib
    /opt/vc/lib
Run

Code:
ldconfig
Edit /etc/rc.d/rc.local

Code:
# vcgencmd available to video group
chmod 660 /dev/vchiq
chgrp video /dev/vchiq

Test it using this script

Code:
#!/bin/bash
cpuTemp0=$(cat /sys/class/thermal/thermal_zone0/temp)
cpuTemp1=$(($cpuTemp0/1000))
cpuTemp2=$(($cpuTemp0/100))
cpuTempM=$(($cpuTemp2 % $cpuTemp1))

gpuTemp0=$(/opt/vc/bin/vcgencmd measure_temp)
gpuTemp0=${gpuTemp0//\'/º}
gpuTemp0=${gpuTemp0//temp=/}

echo CPU Temp: $cpuTemp1"."$cpuTempM"ºC"
echo GPU Temp: $gpuTemp0
And I also made conky show them:

termal_conky.sh
Code:
#!/bin/bash
cpuTemp0=$(cat /sys/class/thermal/thermal_zone0/temp)
cpuTemp1=$(($cpuTemp0/1000))
cpuTemp2=$(($cpuTemp0/100))
cpuTempM=$(($cpuTemp2 % $cpuTemp1))

gpuTemp0=$(/opt/vc/bin/vcgencmd measure_temp)
gpuTemp0=${gpuTemp0//\'/º}
gpuTemp0=${gpuTemp0//temp=/}

echo $cpuTemp1"."$cpuTempM"ºC" > $HOME/programming/Raspberry_RPi3/scripts/CPU_Temp.txt
echo $gpuTemp0 > $HOME/programming/Raspberry_RPi3/scripts/GPU_Temp.txt
.conkyrc

Code:
...

TEXT


${exec $HOME/programming/Raspberry_RPi3/scripts/termal_conky.sh}

...
${font Prototype:size=8}${color1}CPU temp: ${color2}${exec cat $HOME/programming/Raspberry_RPi3/scripts/CPU_Temp.txt }${color1}
${font Prototype:size=8}${color1}GPU temp: ${color2}${exec cat $HOME/programming/Raspberry_RPi3/scripts/GPU_Temp.txt }${color1}
 
Old 11-12-2016, 11:59 PM   #2
louigi600
Member
 
Registered: Dec 2013
Location: Italy
Distribution: Slackware
Posts: 635
Blog Entries: 20

Rep: Reputation: 81
If you declare your integer variabes you can do something like this:
Code:
root@nwrap:~# declare -i A
root@nwrap:~# A=$(cat /sys/class/thermal/thermal_zone0/temp)/1000
root@nwrap:~# echo $A
29
root@nwrap:~#
But then you loose the floating point precision
yow could use awk to keep 2 decimal places
Code:
root@nwrap:~# A=$(awk '{printf("%.2f\n",$1/1000)}' < /sys/class/thermal/thermal_zone0/temp)
root@nwrap:~# echo $A
29.86
root@nwrap:~#
I wrote this for my RPI2 ... I think most of it would be good for the RPI3 too.

Code:
#!/bin/bash
NAME=$(basename $0)

VCGENCMD=/opt/vc/bin/vcgencmd

show_temp ()
{ echo "TEMPERATURES"
  echo "  SOC $($VCGENCMD measure_temp)"
}

show_voltages ()
{ echo "TENSION"
  for id in core sdram_c sdram_i sdram_p
  do
    echo -e "  $id: $($VCGENCMD measure_volts $id)"
  done
}

acpi_info ()
{ show_temp 
  show_voltages
}

show_freq ()
{ echo "Frequencies"
  for src in arm core h264 isp v3d uart pwm emmc pixel vec hdmi dpi
  do
    echo -e "  $src: $($VCGENCMD measure_clock $src |awk -F= '{printf("%.3f Mhz\n",$NF/1000000)}')"
  done
}

codec_info ()
{ echo "Codecs"
  for codec in H264 MPG2 WVC1 MPG4 MJPG WMV9
  do
    echo -e "  $($VCGENCMD codec_enabled $codec)"
  done
}

mem_info ()
{ echo "Memory"
  $VCGENCMD get_mem arm && $VCGENCMD get_mem gpu
}

show_conf ()
{ case $1 in
    int) $VCGENCMD get_config int ;;
    str) $VCGENCMD get_config str ;;
    all) $VCGENCMD get_config int ; $VCGENCMD get_config str ;;
    *) $VCGENCMD get_config $1 ;;
  esac
}

case ${1:-$NAME} in
  temp) show_temp ;;
  tension) show_voltages ;;
  acpi) acpi_info  ;;
  freq) show_freq ;;
  codec) codec_info ;;
  mem) mem_info ;;
  all) show_temp ; show_voltages ; show_freq ; codec_info ; mem_info ;;
  config) show_conf ${2:-all} ;;
  *)  echo "$NAME <temp|tension|acpi|freq|codec|mem|config [int|str|config_option_name]>"
      echo "$NAME $* : unsupported" ;;
esac
I'm not sure if /sys/class/thermal/thermal_zone0/temp and vcgencmd measure_temp actually physically read in different locations of the SOC or if the slight differences in temperature readings are dew nose ... I'm assuming that since the die inside the SOCK is small the 2 temperatures aren't going to get very different .. if it does it would be receiving very hard thermal stress dew to the temperature gradient.

Last edited by louigi600; 11-13-2016 at 12:33 AM.
 
Old 11-18-2016, 08:29 PM   #3
glorsplitz
Senior Member
 
Registered: Dec 2002
Distribution: slackware!
Posts: 1,308

Rep: Reputation: 368Reputation: 368Reputation: 368Reputation: 368
louigi600

I tried your script above and each code block works but not the case statements.

The whole script as is outputs
temps <temp|tension|acpi|freq|codec|mem|config [int|str|config_option_name]>
temps : unsupported

I don't understand case statements and passing variables, at least that's what I think show_conf ${2:-all} is doing with show_conf ().
 
Old 11-18-2016, 11:28 PM   #4
louigi600
Member
 
Registered: Dec 2013
Location: Italy
Distribution: Slackware
Posts: 635
Blog Entries: 20

Rep: Reputation: 81
Higlorsplitz.
It works on my pi2 :

Code:
root@nwrap:~# acpi -?
acpi <temp|tension|acpi|freq|codec|mem|config [int|str|config_option_name]>
acpi -? : unsupported
root@nwrap:~# acpi config
arm_freq=900
audio_pwm_mode=1
config_hdmi_boost=5
disable_commandline_tags=2
disable_l2cache=1
enable_uart=1
force_eeprom_read=1
force_pwm_open=1
framebuffer_ignore_alpha=1
framebuffer_swap=1
hdmi_force_cec_address=65535
hdmi_force_edid_audio=1
init_uart_clock=0x2dc6c00
lcd_framerate=60
mask_gpu_interrupt1=0x10000
over_voltage_avs=0x1b774
overscan_bottom=37
overscan_left=37
overscan_right=37
overscan_top=37
pause_burst_frames=1
program_serial_random=1
sdram_freq=450
temp_limit=85
device_tree=-
root@nwrap:~#
Yes if you input unsupported option you get back that message ... it's telling you what it supports:
you called it temps (I called it acpi). It's telling you that an option argument is mandatory and can be any one of:
  • temp
  • tension
  • acpi
  • freq
  • codec
  • mem
  • config [int|str|config_option_name]

I think you're just using it wrong ... try using option "all" that gives you everything but the config.
${2:-all} simply means use the second option string if present else use "all" (bash reference manual if in doubt).
So if you tell it you want config and omit whether you want string or integer config options you get both back.

If you want the temperature reading you should be typing
Code:
temps temp
Code:
case ${1:-$NAME} in
Means that if $1 is not set use the name of the script itself ... now I called it acpi so acpi is a supported option and gives you back temperature and voltages, in your case temps is not a supported option so you get an error message if you just type temps with no arguments.

Last edited by louigi600; 11-18-2016 at 11:42 PM.
 
1 members found this post helpful.
Old 11-19-2016, 12:05 PM   #5
glorsplitz
Senior Member
 
Registered: Dec 2002
Distribution: slackware!
Posts: 1,308

Rep: Reputation: 368Reputation: 368Reputation: 368Reputation: 368
Thanks louigi600!

It all works fine, silly me, I wasn't telling your script what to do, temp, tension, etc.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: How to fix your discrete GPU temperatures LXer Syndicated Linux News 0 08-01-2012 01:41 PM
[SOLVED] High cpu temperatures after replacing the motherboard Hungry ghost Linux - Hardware 18 01-22-2010 11:41 PM
ATI Gpu Temperatures Nucomer Linux - Hardware 0 01-05-2007 12:38 PM
App to display CPU, disk temperatures? Randux Slackware 8 02-22-2006 03:17 PM
Reading cpu temperatures. minm Linux - Software 8 09-09-2004 09:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware > Slackware - ARM

All times are GMT -5. The time now is 07:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration