Raspberry Pi: Current System Information

I’ve written a simple bash script to show the current temperature, voltage, and core clock on my Raspberry Pi (Model B running Raspbian). I had to install bc (a basic calculator) as it wasn’t installed by default. You can get it by running the command

sudo apt-get install bc

Then run this code:

echo Raspberry Pi System Information
echo -------------------------------
temp_measured=`sudo /opt/vc/bin/vcgencmd measure_temp`
temp_centigrade=`echo $temp_measured| cut -d '=' -f2 | sed 's/..$//'`
temp_fahrenheit=$(echo "scale=2;((9/5) * $temp_centigrade) + 32" |bc)
core_measured=`sudo /opt/vc/bin/vcgencmd measure_clock arm`
core_cut=`echo $core_measured| cut -c15-`
core_mhz=$(echo "scale=1;($core_cut / 1000000)" |bc)
volt_measured=`sudo /opt/vc/bin/vcgencmd measure_volts core`
volt_cut=`echo $volt_measured| cut -d '=' -f2 | sed 's/.$//'`
echo Temperature = $temp_centigrade\*C \($temp_fahrenheit\*F\)
echo Voltage = $volt_cut V
echo Core clock = $core_mhz MHz

The output should like this:

Leave a Reply

Your email address will not be published. Required fields are marked *