[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: What is the command to access the temp sensors in a rpi4?



On Sun, 17 Jan 2021 23:47:48 -0500
Gene Heskett <gheskett@shentel.net> wrote:

> Greetings all;

> Cheers, Gene Heskett

cpu=$(</sys/class/thermal/thermal_zone0/temp) ; echo -e "CPU
temperature: $((cpu/100)) Celsius"   | sed 's/\B[0-9]\{1\}\>/,&/'

This oneliner works on pi3 and pi4


I use this oneliner for some color:
cpu=$(</sys/class/thermal/thermal_zone0/temp) ; echo -e "CPU
temperature: \e[31m  $((cpu/100)) Celsius \e[0m"   | sed
's/\B[0-9]\{1\}\>/,&/'

Or in a script:

#!/bin/bash
cpu=$(</sys/class/thermal/thermal_zone0/temp)
echo -e "CPU temperatuur: \e[31m  $((cpu/100)) Celsius \e[0m" | sed
's/\B[0-9]\{1\}\>/,&/' 
#eof

hope this helps


Reply to: