Short tip: Get Raspberry Pi temperature

There is no standard sensor that can be used with lm_sensors to get the temperature of the Raspberry Pi embedded board – what a pity! Fortunately for this function there is a dedicated command called vcgencmd which is already included in the Raspbian image. To make it work you will need to customize the LD library paths:

# echo "/opt/vc/lib" > /etc/ld.so.conf.d/raspberry-firmware.conf
# ldconfig
# /opt/vc/bin/vcgencmd measure_temp
temp=51.9'C

There is also an appropriate file underneath /sys/class to get the temperature:

# cat /sys/class/thermal/thermal_zone0/temp
51920
# awk '{printf "%3.1f°Cn", $1/1000}' /sys/class/thermal/thermal_zone0/temp
51.9°C

Sharing is caring

Leave a Reply