Page 2 of 2

Re: Read temp sensors from command line

Posted: Tue May 14, 2013 2:06 am
by 67comet
This is a great little script for us headless guys.

I run into an error however (and this is exactly how it prints in the terminal via ssh).

Code: Select all

pi@SteigerMotion ~ $ sh ./system-script.sh 
























Mon May 13 20:02:34 MDT 2013

Firmware Version
May  5 2013 13:06:56 
Copyright (c) 2012 Broadcom
version 388665 (release)

./system-script.sh: 12: ./system-script.sh: bc: not found
-e temp:	 'F (59.5'C)

-e arm:	 frequency(45)=700000000
-e core:	 frequency(1)=250000000
-e h264:	 frequency(28)=250000000
-e isp:	 frequency(42)=250000000
-e v3d:	 frequency(43)=250000000
-e uart:	 frequency(22)=3000000
-e pwm:	 frequency(25)=0
-e emmc:	 frequency(47)=100000000
-e pixel:	 frequency(29)=0
-e vec:	 frequency(10)=108000000
-e hdmi:	 frequency(9)=0
-e dpi:	 frequency(4)=0
-e core:	 volt=1.20V
-e sdram_c: volt=1.20V
-e sdram_i: volt=1.20V
-e sdram_p: volt=1.23V
-e H264:	 H264=enabled
-e MPG2:	 MPG2=disabled
-e WVC1:	 WVC1=disabled

pi       pts/0        2013-05-13 19:53 (orion.openlug.com)

 20:02:35 up 9 min,  1 user,  load average: 0.84, 0.78, 0.49
I'm not sure if I'm supposed to have something to run bc but it kicks that error out every time.

I'd love to read my temps in F*.

Thanks for any goodness...

P.S. The code I've got verbatim:

Code: Select all

#!/bin/bash
clear
sleep 2
echo
date
echo
echo 'Firmware Version'
/opt/vc/bin/vcgencmd version
echo
tm=`/opt/vc/bin/vcgencmd measure_temp`
tc=`echo $tm| cut -d '=' -f2 | sed 's/..$//'`
tf=$(echo "scale=1; (1.8*$tc)+32" | bc)
echo -e "temp:\t $tf'F ($tc'C)"
#echo -e "temp:\t $(/opt/vc/bin/vcgencmd measure_temp)" ;
echo
for src in arm core h264 isp v3d uart pwm emmc pixel vec hdmi dpi ; do echo -e "$src:\t $(/opt/vc/bin/vcg$
for id in core ; do echo -e "$id:\t $(/opt/vc/bin/vcgencmd measure_volts $id)" ; done
for id in sdram_c sdram_i sdram_p ; do echo -e "$id: $(/opt/vc/bin/vcgencmd measure_volts $id)" ; done
for codec in H264 MPG2 WVC1 ; do echo -e "$codec:\t $(/opt/vc/bin/vcgencmd codec_enabled $codec)" ; done
echo
who
echo
uptime
echo

Re: Read temp sensors from command line

Posted: Tue May 14, 2013 2:28 am
by ukscone
67comet wrote:

Code: Select all

for src in arm core h264 isp v3d uart pwm emmc pixel vec hdmi dpi ; do echo -e "$src:\t $(/opt/vc/bin/vcg$
that line is truncated

it should be

Code: Select all

for src in arm core h264 isp v3d uart pwm emmc pixel vec hdmi dpi ; do echo -e "$src:\t $(/opt/vc/bin/vcgencmd measure_clock $src)" ; done

Re: Read temp sensors from command line

Posted: Tue May 14, 2013 7:29 pm
by MoonTEC
Code needs GNU bc arbitrary precision calculator language, shorter bc.
On raspbian or debian:

Code: Select all

apt-get update && apt-get install bc

Re: Read temp sensors from command line

Posted: Wed May 15, 2013 7:57 am
by graysky
Jordi just pushed some changes to monitorix that logs to an rrd database many if not all of the sensor output of the pi. Screenshot:
Image

Re: Read temp sensors from command line

Posted: Fri Oct 11, 2013 5:52 pm
by KunalGautam
I'm not an expert but I think you can read it from

Code: Select all

cat /sys/class/thermal/thermal_zone0/temp 
Divide by 1000 will give temperature on board.

Re: Read temp sensors from command line

Posted: Sat Oct 12, 2013 6:43 pm
by walt09241984
I don't know if any of you are familiar with conky.

apt-get install conky-all

It works for X and ncurses. Yet, I have not tried ncurses ability.

Code: Select all

minimum_size 200 200
maximum_width 700
gap_x 170
gap_y 140
alignment top_right
update_interval 1
use_xft yes
xftfont Monaco:size=8
own_window yes
own_window_type desktop
own_window_transparent yes
own_window_colour 000000
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
#own_window_argb_visual yes
#own_window_argb_value 170
double_buffer yes
draw_shades no
draw_graph_borders no
uppercase no
border_inner_margin 10
default_color ffffff

TEXT
UPTIME  $uptime

CPU        ${alignr}${cpu cpu0} %
FREQ       ${alignr}$freq Mhz
TEMP       ${alignr}${execi 30 cat /sys/class/thermal/thermal_zone0/temp | awk '{print substr($0,0,3)}' }°C
SDCARD     ${alignr}${fs_used /} / ${fs_size /}
RAM        ${alignr}$mem / $memmax
SWAP       ${alignr}$swap
WHOAMI     ${alignr}$user_names
HOST       ${alignr}$nodename



Walt