Is it possible to read the temperature sensors from the command line?
I have the Pi at a remote location that I can access using ssh and I would like to read the current temperature.
Re: Read temp sensors from command line
The Pi hardware doesn't include any temperature sensors. However you can hook up an I2C temperature sensor to the GPIO pins (and then read that from the command line) - search the forums for more info.
- Gert van Loo
- Posts: 2487
- Joined: Tue Aug 02, 2011 7:27 am
- Contact: Website
Re: Read temp sensors from command line
Actually: we have. In fact we have several of them in different places on the silicon to check the silicon temperature. It is not generally known and there is no use in knowing as they requires some very special SW to access and read. To use them you have to go trough the Reset-Power-Clock manager module and we keep that closed also because if you do wrong things there you can accidentally over voltage the chip. Even we 'in-the-know' do not access registers in that module directly and prefer to use dedicated, tested and verified routines to do the work for us.AndrewS wrote:The Pi hardware doesn't include any temperature sensors. ....
Re: Read temp sensors from command line
Learn something new every day 
Let me revise my statement to "The Pi hardware doesn't include any user-accessible temperature sensors. ...." then

Let me revise my statement to "The Pi hardware doesn't include any user-accessible temperature sensors. ...." then

Re: Read temp sensors from command line
it's very easy to monitor the temperature using an external sensor with a usb<>serial converter, check this: http://martybugs.net/electronics/tempse ... rdware.cgi
HTH
HTH
Re: Read temp sensors from command line
Temperature is probably the most often sensed physical property. Whatever measurements I make on any system, I always include ambient temperature, because it has some measurable effect on almost everything and it's useful to correlate just how much effect that is. So if there was some way to have visibility of the chip temperature from the user space, that would be very useful. Obviously chip temp != ambient temp, but at constant system power draw and ambient airflow they will move together.Gert van Loo wrote:In fact we have several of them in different places on the silicon to check the silicon temperature.... Even we 'in-the-know' do not access registers in that module directly and prefer to use dedicated, tested and verified routines to do the work for us.
Currently I use a LM35 3-terminal analog-output temperature sensor, with a I2C 18-bit ADC connecting to an Arduino, and that in turn reporting via USB-serial to the R-Pi. Once I get a chance, I plan to figure out the R-Pi I2C interfacing and cut out the Arduino. This is the I2C ADC module: http://jeelabs.com/products/analog-plug
With averaging it has usable resolution to 0.0001 degrees. My office temperature is currently 23.2520 C and rising at a rate of 0.0088 C per minute.
Re: Read temp sensors from command line
So, is there documentation available about how to access those sensors, at all? Warranty isn't something that troubles me, as I just overvolted it anyway, to try and see how greater clock speeds will feel like.
Surely, as long as there are docs, it cannot be so hard to *read* a couple of values out.
Surely, as long as there are docs, it cannot be so hard to *read* a couple of values out.
Re: Read temp sensors from command line
The short answer is no.
The only 'docs' available is the BCM2835 peripherals PDF linked to from http://elinux.org/RPi_Hardware#Components which has no mention of temperature sensors. The "very special SW to access and read" that Gert refers to can only be written by Broadcom employees.
The only 'docs' available is the BCM2835 peripherals PDF linked to from http://elinux.org/RPi_Hardware#Components which has no mention of temperature sensors. The "very special SW to access and read" that Gert refers to can only be written by Broadcom employees.
Re: Read temp sensors from command line
Alright, that clears up things a lot, thanks.
Re: Read temp sensors from command line
If you are willing to look into Arduino documentation, there are several detailed HOW-TOs on measuring temperature that would readily adapt to Raspi, either using, say an LM35 or a varistor.
If discrimination is not challenged then we are effectively in collusion with the perpetrators of such behaviour:-Oxford dictionaries
- Burngate
- Posts: 6427
- Joined: Thu Sep 29, 2011 4:34 pm
- Location: Berkshire UK Tralfamadore
- Contact: Website
Re: Read temp sensors from command line
Just out of interest ...Gert van Loo wrote:Actually: we have. In fact we have several of them in different places on the silicon to check the silicon temperature. It is not generally known and there is no use in knowing as they requires some very special SW to access and read. To use them you have to go trough the Reset-Power-Clock manager module and we keep that closed also because if you do wrong things there you can accidentally over voltage the chip. Even we 'in-the-know' do not access registers in that module directly and prefer to use dedicated, tested and verified routines to do the work for us.AndrewS wrote:The Pi hardware doesn't include any temperature sensors. ....
Those sensors are there for a reason - does the blob read them at any time, and does it do anything with the readings? Such as dropping volts or frequency to reduce power?
Or is it just for you to check on how we broke it when it gets returned?
Re: Read temp sensors from command line
There is a documented firmware interface to read the temperature from the Broadcom chip.
But someone needs to write a little linux tool to use it....
But someone needs to write a little linux tool to use it....
Re: Read temp sensors from command line
So there is a possibility to have a software acces of temparaure sensor(s) in the future ??
+°´°+,¸¸,+°´°~ Everyone should have a taste of UK Raspberry Pie =D ~°´°+,¸¸,+°´°+
Rasberry Pi, SoC @ 1225Mhz
, 256MB Ram @ 550Mhz, 16GB SD-Card, Raspbian
Rasberry Pi, SoC @ 1225Mhz

- Licaon_Kter
- Posts: 240
- Joined: Wed Sep 05, 2012 10:12 am
- Location: Between the keyboard and the chair.
Re: Read temp sensors from command line
run sudo rpi-update now
reboot
run /opt/vc/bin/vcgencmd measure_temp ( info: http://www.raspberrypi.org/phpBB3/viewt ... 26#p169726 )
reboot
run /opt/vc/bin/vcgencmd measure_temp ( info: http://www.raspberrypi.org/phpBB3/viewt ... 26#p169726 )
BFQ+BFS or RT on a RPi? 4'real: https://github.com/licaon-kter/ (source and compiled!)
-
- Raspberry Pi Engineer & Forum Moderator
- Posts: 5708
- Joined: Wed Aug 17, 2011 7:41 pm
- Location: Cambridge
Re: Read temp sensors from command line
The sensor is mainly there for adjusting sdram refresh with temperature (you need to refresh more at high temperature).Burngate wrote:Those sensors are there for a reason - does the blob read them at any time, and does it do anything with the readings? Such as dropping volts or frequency to reduce power?
Or is it just for you to check on how we broke it when it gets returned?
The latest firmware does disable overclock/overvolt when it reaches 85'C which should bring it back down.
However at 24'C ambient, I couldn't get the temperature above 77'C with absolute maximum overclock/overvolt settings and stress testing ARM+GPU. I doubt if this limit will be hit by many.
Re: Read temp sensors from command line
this is just awsome !
do i need to use rpi-update or is the kernel in raspbian bleeding edge repo also updated with this ?
do i need to use rpi-update or is the kernel in raspbian bleeding edge repo also updated with this ?
+°´°+,¸¸,+°´°~ Everyone should have a taste of UK Raspberry Pie =D ~°´°+,¸¸,+°´°+
Rasberry Pi, SoC @ 1225Mhz
, 256MB Ram @ 550Mhz, 16GB SD-Card, Raspbian
Rasberry Pi, SoC @ 1225Mhz

Re: Read temp sensors from command line
wow, that is great to have a protection like thatdom wrote:The sensor is mainly there for adjusting sdram refresh with temperature (you need to refresh more at high temperature).Burngate wrote:Those sensors are there for a reason - does the blob read them at any time, and does it do anything with the readings? Such as dropping volts or frequency to reduce power?
Or is it just for you to check on how we broke it when it gets returned?
The latest firmware does disable overclock/overvolt when it reaches 85'C which should bring it back down.
However at 24'C ambient, I couldn't get the temperature above 77'C with absolute maximum overclock/overvolt settings and stress testing ARM+GPU. I doubt if this limit will be hit by many.

+°´°+,¸¸,+°´°~ Everyone should have a taste of UK Raspberry Pie =D ~°´°+,¸¸,+°´°+
Rasberry Pi, SoC @ 1225Mhz
, 256MB Ram @ 550Mhz, 16GB SD-Card, Raspbian
Rasberry Pi, SoC @ 1225Mhz

Re: Read temp sensors from command line
Wanted the output in F instead of C. Script gives both.
https://gist.github.com/3748975
Outputs:
temp=122.54'F (50.3'C)
https://gist.github.com/3748975
Outputs:
temp=122.54'F (50.3'C)
Dweeber A.K.A. Kevin...
My RPI Info Pages including Current Setup - http://rpi.tnet.com
My RPI Info Pages including Current Setup - http://rpi.tnet.com
Re: Read temp sensors from command line
The following script builds on Dweeber’s output in Fahrenheit example to provide information from frequency and voltage sensors. Those who think in Celsius can uncomment line 9.
#!/bin/bash
echo
date
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)" ;
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
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
echo 'firmware version'
/opt/vc/bin/vcgencmd version
#!/bin/bash
echo
date
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)" ;
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
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
echo 'firmware version'
/opt/vc/bin/vcgencmd version
Re: Read temp sensors from command line
Simple Script to get version / temperature of CPU / Voltage of memory cards
#!/bin/bash
clear
#Getting System Information
/opt/vc/bin/vcgencmd version
/opt/vc/bin/vcgencmd measure_temp
/opt/vc/bin/vcgencmd measure_volts core
/opt/vc/bin/vcgencmd measure_volts sdram_c
/opt/vc/bin/vcgencmd measure_volts sdram_i
/opt/vc/bin/vcgencmd measure_volts sdram_p
#!/bin/bash
clear
#Getting System Information
/opt/vc/bin/vcgencmd version
/opt/vc/bin/vcgencmd measure_temp
/opt/vc/bin/vcgencmd measure_volts core
/opt/vc/bin/vcgencmd measure_volts sdram_c
/opt/vc/bin/vcgencmd measure_volts sdram_i
/opt/vc/bin/vcgencmd measure_volts sdram_p
-
- Posts: 8
- Joined: Mon Jul 09, 2012 4:14 pm
Re: Read temp sensors from command line
This is a pretty economical and simple way to get temperature.
http://learn.adafruit.com/adafruits-ras ... ng/ds18b20
http://www.ebay.com/itm/2PCS-IC-DS18B20 ... 43b133fe6b
The ds18b20 can be daisy chained so you can read multiple temperatures. I won't go into lots of details, just wanted to throw it out there in case you weren't familiar with the 1-wire system.
Ryan
http://learn.adafruit.com/adafruits-ras ... ng/ds18b20
http://www.ebay.com/itm/2PCS-IC-DS18B20 ... 43b133fe6b
The ds18b20 can be daisy chained so you can read multiple temperatures. I won't go into lots of details, just wanted to throw it out there in case you weren't familiar with the 1-wire system.
Ryan
Re: Read temp sensors from command line
Hi, This is my first post, so please forgive me if I leave any essential information out.
I am using the latest version of Raspbian and following the Adafruit instructions you mention. I can obtain a temperature reading using the 'cat w1 slave' command, but when I follow the software instructions on page 11, I get a message telling me 'list index out of range' in Line 9. The line containing the error is: device_folder=glob.glob(base_dir+'28*')[0]. I have replaced the '*' with the sensor number '-000004ab6156'. Any help would be greatly appreciated. Please note GPIO pins have been installed, but not set as I understand latest software versions already have this set to automatically read inputs on all pins. Also I ran 'sudo apt-get update' and 'sudo apt-get upgrade' on 27 April 2013, so system is completely up to date.
Many thanks for any help anyone can offer.
Luckyloo
I am using the latest version of Raspbian and following the Adafruit instructions you mention. I can obtain a temperature reading using the 'cat w1 slave' command, but when I follow the software instructions on page 11, I get a message telling me 'list index out of range' in Line 9. The line containing the error is: device_folder=glob.glob(base_dir+'28*')[0]. I have replaced the '*' with the sensor number '-000004ab6156'. Any help would be greatly appreciated. Please note GPIO pins have been installed, but not set as I understand latest software versions already have this set to automatically read inputs on all pins. Also I ran 'sudo apt-get update' and 'sudo apt-get upgrade' on 27 April 2013, so system is completely up to date.
Many thanks for any help anyone can offer.
Luckyloo
Re: Read temp sensors from command line
Luckyloo,
I made a few slight modifications to my earlier post; however, everything reported just fine. Here is the modified code see if this will work for you.
#!/bin/bash
clear
sleep 2
echo
date
echo
echo 'Firmeare 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/vcgencmd measure_clock $sr$
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
I made a few slight modifications to my earlier post; however, everything reported just fine. Here is the modified code see if this will work for you.
#!/bin/bash
clear
sleep 2
echo
date
echo
echo 'Firmeare 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/vcgencmd measure_clock $sr$
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
PIV8DR, I think there is a slight syntax error on line 16 of your latest script ("for src in arm core h264 ..."), but the following works for me:
Here is my output:
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/vcgencmd measure_clock $src)" ; done
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
Code: Select all
Sun Apr 28 08:30:40 PDT 2013
Firmware Version
Apr 25 2013 01:07:36
Copyright (c) 2012 Broadcom
version 386589 (release)
temp: 88.7'F (31.5'C)
arm: frequency(45)=700000000
core: frequency(1)=250000000
h264: frequency(28)=0
isp: frequency(42)=250000000
v3d: frequency(43)=250000000
uart: frequency(22)=3000000
pwm: frequency(25)=0
emmc: frequency(47)=100000000
pixel: frequency(29)=108000000
vec: frequency(10)=0
hdmi: frequency(9)=163682000
dpi: frequency(4)=0
core: volt=1.20V
sdram_c: volt=1.20V
sdram_i: volt=1.20V
sdram_p: volt=1.23V
H264: H264=enabled
MPG2: MPG2=disabled
WVC1: WVC1=disabled
pi tty2 2013-04-25 20:13
pi ttyAMA0 2013-04-27 13:36
08:30:40 up 2 days, 12:54, 2 users, load average: 0.18, 0.27, 0.42
Re: Read temp sensors from command line
Thanks for your help guys,
The problem is now resolved.
Luckyloo
The problem is now resolved.

Luckyloo