It then rounds that value to at most two decimals. then converts the CPU number to Fahrenheit (for Americans like me) with help from the ‘awk’ utility, since a bash script by itself can’t do floating point math.and the GPU temperature from vcgencmd (in Celsius),.gets the Pi’s CPU temperature from a system file under /sys/class/….# get the CPU temp in Celsius as a numberĬpu=$( $(/opt/vc/bin/vcgencmd measure_temp)"įar=$(echo - | awk -v cpu=$cpu '')Ĭurrentdatestamp=``date +"%A, %b %d, %Y %I:%M %p"`` message="Pi temp $far2 degrees F - as of "Įcho $message $currentdatestamp > /home/pi/www/html/pitemp.txt Get yourself into the Pi user’s home folder:Įxecute this command to create the shell script: Here’s what that looks like now that it’s all setup:ġ - Write a shell script to get the temp and save it into a text file.Ģ - Run that on a regular basis via cron (a crontab file really).ģ - Add some JavaScript and HTML to the Pi’s web page which reads that text file and then adds that info to the page.Īnd here are the details (these steps assume you have Raspbian running as the operating system on the Pi but if not, you will need to adjust to use whatever text editor or other things you have) So I then figured out how to get the Pi’s html home web page to include that info. I recently figured out how to determine the core CPU and GPU temperatures for my new Raspberry Pi 4 by way of a shell script, and it didn’t take long before I got tired of running that manually.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |