Get temperature of your Raspberry Pi
You Raspberry Pi has some nice commands that comes from its firmware that gets you information about the condition of some hardware components. One of this commands is able to measure and prints out the current temperature of your temperature sensor on your board. This may sounds complicated, but is really simple!
All you need is vcgencmd which gets you different informations based on parameters you set. You can get a list of all possible commands if you type this command into command line:
You will get a list of all possible parameters. Some of them are really interesting.
Get system temperature
For this you need the measure_temp param. With it you will get the current temperature on your board:
You will get the current temperature in degree Celsius. The output is not good formatted. I want to get a better output and a temperature in Fahrenheit. So for this use the following script:
tc=`echo $tm| cut -d '=' -f2 | sed 's/..$//'`
tf=$(echo "scale=2;((9/5) * $tc) + 32" |bc)
echo temp = $tc\°C \($tf\°F\)
You can call the script with this command and you may get following output:
temp = 49.8°C (121.64°F)
Get current clock frequency
You can get clock frequency information with the measure_clock param. For this you also need the name of the component which should get measured. There are many different possible components, you can find a list here. One of this components is ARM which gets you your current clock speed of your processor:
vcgencmd measure_clock arm
I get the standard value of 700 Million Hertz or 700 MHz.
Get the voltage
Another nice possibility is to measure the voltage. You need the measure_volts param and again you need the name of the component. Here you have 4 possibilities: core (standard), sdram_c, sdram_i, sdram_p:
vcgencmd measure_volts core
You have now learned how to get online board information! It is a good idea to write a script to get this values regularly. Maybe you want to store it into database and display it with a small PHP web app?