{"id":76,"date":"2021-08-20T16:44:19","date_gmt":"2021-08-20T10:44:19","guid":{"rendered":"https:\/\/bytegeeks.net\/blog\/?p=76"},"modified":"2021-08-20T17:08:14","modified_gmt":"2021-08-20T11:08:14","slug":"raspberry-pi-temperature-script","status":"publish","type":"post","link":"https:\/\/bytegeeks.net\/blog\/raspberry-pi-temperature-script\/","title":{"rendered":"Raspberry Pi Temperature Script"},"content":{"rendered":"\n<p>There is no default way to check the Pi&#8217;s temperature. I have found a few blogs where they explain how to create a script to check the temperature but failed to find one that is easy to follow and straight forward. This is why I am going to show you how to create a Raspberry Pi temperature script as well create a command to execute it as standard linux command.<\/p>\n\n\n\n<p>Now I am no expert script writer. I have mostly followed two blog posts and combined the best parts, credits are <a href=\"#credits\">here<\/a>.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Creating the script<\/h4>\n\n\n\n<p>We will create a simple bash script. Copy the following command and paste it in the terminal. This should create the &#8220;temp.sh&#8221; script and open in edit mode.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism off-numbers lang-bash\" data-lang=\"Bash\" data-show-lang=\"0\"><code>nano temp.sh<\/code><\/pre><\/div>\n\n\n\n<p>Copy the following code and paste it in the script file. <\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism off-numbers lang-bash\" data-lang=\"Bash\" data-show-lang=\"0\"><code>#!\/bin\/bash\n# Script: temp.sh\n# Purpose: Display the ARM CPU and GPU temperature of Raspberry Pi\n# Author: Ahmed Redwan &lt;www.bytegeeks.net&gt; under GPL v3.0\n# -------------------------------------------------------\ncpu=$(&lt;\/sys\/class\/thermal\/thermal_zone0\/temp)\nc=$(bc -l &lt;&lt;&lt; &quot;scale=1; ($cpu)\/1000&quot;)\necho &quot;$(date) @ $(hostname)&quot;\necho &quot;-------------------------------------------&quot;\necho &quot;GPU =&gt; $(\/opt\/vc\/bin\/vcgencmd measure_temp)&quot;\necho &quot;CPU =&gt; temp=$c&#39;C&quot;<\/code><\/pre><\/div>\n\n\n\n<p>Now save and exit the file (<strong>Ctrl<\/strong> + <strong>S<\/strong>, then <strong>Ctrl <\/strong>+ <strong>X<\/strong>). Once this is done, we need to make the script as executable. The following command is used to make it executable.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism off-numbers lang-bash\" data-lang=\"Bash\" data-show-lang=\"0\"><code>chmod +x temp.sh<\/code><\/pre><\/div>\n\n\n\n<p>To run any executable script we have to append &#8220;.\/&#8221; to the name of the script<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism off-numbers lang-bash\" data-lang=\"Bash\" data-show-lang=\"0\"><code>.\/temp.sh<\/code><\/pre><\/div>\n\n\n\n<p>You should see something like this.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"659\" height=\"447\" src=\"https:\/\/bytegeeks.net\/blog\/wp-content\/uploads\/2021\/08\/Output1.png\" alt=\"output of temp script in Raspberry Pi\" class=\"wp-image-112\" title=\"output of the temp.sh script\" srcset=\"https:\/\/bytegeeks.net\/blog\/wp-content\/uploads\/2021\/08\/Output1.png 659w, https:\/\/bytegeeks.net\/blog\/wp-content\/uploads\/2021\/08\/Output1-300x203.png 300w\" sizes=\"auto, (max-width: 659px) 100vw, 659px\" \/><\/figure><\/div>\n\n\n\n<p>Now we need to copy this script to <code>\/usr\/bin\/<\/code> directory to be able to execute the bash script like regular linux commands as shown in the second temperature output.<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism off-numbers lang-bash\" data-lang=\"Bash\" data-show-lang=\"0\"><code>sudo cp temp.sh \/usr\/bin\/temp<\/code><\/pre><\/div>\n\n\n\n<p>Once we have copied it to the directory, typing only &#8220;temp&#8221; should run the script and output the CPU and GPU temperature of your <a href=\"https:\/\/bytegeeks.net\/blog\/category\/linux\/raspberrypi\/\">Raspberry Pi<\/a>.<\/p>\n\n\n\n<h6 class=\"wp-block-heading\" id=\"credits\">Credits<\/h6>\n\n\n\n<p><a href=\"https:\/\/www.cyberciti.biz\/faq\/linux-find-out-raspberry-pi-gpu-and-arm-cpu-temperature-command\/\" target=\"_blank\" rel=\"noreferrer noopener\">Vivek Gite<\/a> and <a href=\"https:\/\/linuxhint.com\/raspberry_pi_temperature_monitor\/\" target=\"_blank\" rel=\"noreferrer noopener\">Shahriar Shovon<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>There is no default way to check the Pi&#8217;s temperature. I have found a few blogs where they explain how to create a script to check the temperature but failed to find one that is easy to follow and straight forward. This is why I am going to show you how to create a Raspberry [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":101,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[7],"tags":[14],"class_list":["post-76","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-raspberrypi","tag-how-to"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Raspberry Pi Temperature Script - ByteGeeks<\/title>\n<meta name=\"description\" content=\"An easy to follow and straight forward no nonsense guide to creating a simple bash script for quickly checking the temperature of your Pi.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/bytegeeks.net\/blog\/raspberry-pi-temperature-script\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Raspberry Pi Temperature Script - ByteGeeks\" \/>\n<meta property=\"og:description\" content=\"An easy to follow and straight forward no nonsense guide to creating a simple bash script for quickly checking the temperature of your Pi.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/bytegeeks.net\/blog\/raspberry-pi-temperature-script\/\" \/>\n<meta property=\"og:site_name\" content=\"ByteGeeks\" \/>\n<meta property=\"article:published_time\" content=\"2021-08-20T10:44:19+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-08-20T11:08:14+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/bytegeeks.net\/blog\/wp-content\/uploads\/2021\/08\/RPi-Temp-Script-Featured-Photo.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"630\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Redwan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Redwan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/bytegeeks.net\/blog\/raspberry-pi-temperature-script\/\",\"url\":\"https:\/\/bytegeeks.net\/blog\/raspberry-pi-temperature-script\/\",\"name\":\"Raspberry Pi Temperature Script - ByteGeeks\",\"isPartOf\":{\"@id\":\"https:\/\/bytegeeks.net\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/bytegeeks.net\/blog\/raspberry-pi-temperature-script\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/bytegeeks.net\/blog\/raspberry-pi-temperature-script\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/bytegeeks.net\/blog\/wp-content\/uploads\/2021\/08\/RPi-Temp-Script-Featured-Photo.png\",\"datePublished\":\"2021-08-20T10:44:19+00:00\",\"dateModified\":\"2021-08-20T11:08:14+00:00\",\"author\":{\"@id\":\"https:\/\/bytegeeks.net\/blog\/#\/schema\/person\/419ede240aa968b3bf8202cf9e94e792\"},\"description\":\"An easy to follow and straight forward no nonsense guide to creating a simple bash script for quickly checking the temperature of your Pi.\",\"breadcrumb\":{\"@id\":\"https:\/\/bytegeeks.net\/blog\/raspberry-pi-temperature-script\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/bytegeeks.net\/blog\/raspberry-pi-temperature-script\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/bytegeeks.net\/blog\/raspberry-pi-temperature-script\/#primaryimage\",\"url\":\"https:\/\/bytegeeks.net\/blog\/wp-content\/uploads\/2021\/08\/RPi-Temp-Script-Featured-Photo.png\",\"contentUrl\":\"https:\/\/bytegeeks.net\/blog\/wp-content\/uploads\/2021\/08\/RPi-Temp-Script-Featured-Photo.png\",\"width\":1200,\"height\":630,\"caption\":\"RPi Temp Script Featured Photo\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/bytegeeks.net\/blog\/raspberry-pi-temperature-script\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/bytegeeks.net\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Raspberry Pi Temperature Script\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/bytegeeks.net\/blog\/#website\",\"url\":\"https:\/\/bytegeeks.net\/blog\/\",\"name\":\"ByteGeeks\",\"description\":\"Your one-stop shop for everything IT\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/bytegeeks.net\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/bytegeeks.net\/blog\/#\/schema\/person\/419ede240aa968b3bf8202cf9e94e792\",\"name\":\"Redwan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/bytegeeks.net\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/785ee4165b07a924d3e8538e8fd845bbd1d22e2680c18ebb16aa54890455e008?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/785ee4165b07a924d3e8538e8fd845bbd1d22e2680c18ebb16aa54890455e008?s=96&d=mm&r=g\",\"caption\":\"Redwan\"},\"description\":\"Just your average IT guy talking about IT stuff.\",\"sameAs\":[\"https:\/\/bytegeeks.net\/blog\"],\"url\":\"https:\/\/bytegeeks.net\/blog\/author\/redmin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Raspberry Pi Temperature Script - ByteGeeks","description":"An easy to follow and straight forward no nonsense guide to creating a simple bash script for quickly checking the temperature of your Pi.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/bytegeeks.net\/blog\/raspberry-pi-temperature-script\/","og_locale":"en_US","og_type":"article","og_title":"Raspberry Pi Temperature Script - ByteGeeks","og_description":"An easy to follow and straight forward no nonsense guide to creating a simple bash script for quickly checking the temperature of your Pi.","og_url":"https:\/\/bytegeeks.net\/blog\/raspberry-pi-temperature-script\/","og_site_name":"ByteGeeks","article_published_time":"2021-08-20T10:44:19+00:00","article_modified_time":"2021-08-20T11:08:14+00:00","og_image":[{"width":1200,"height":630,"url":"https:\/\/bytegeeks.net\/blog\/wp-content\/uploads\/2021\/08\/RPi-Temp-Script-Featured-Photo.png","type":"image\/png"}],"author":"Redwan","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Redwan","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/bytegeeks.net\/blog\/raspberry-pi-temperature-script\/","url":"https:\/\/bytegeeks.net\/blog\/raspberry-pi-temperature-script\/","name":"Raspberry Pi Temperature Script - ByteGeeks","isPartOf":{"@id":"https:\/\/bytegeeks.net\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/bytegeeks.net\/blog\/raspberry-pi-temperature-script\/#primaryimage"},"image":{"@id":"https:\/\/bytegeeks.net\/blog\/raspberry-pi-temperature-script\/#primaryimage"},"thumbnailUrl":"https:\/\/bytegeeks.net\/blog\/wp-content\/uploads\/2021\/08\/RPi-Temp-Script-Featured-Photo.png","datePublished":"2021-08-20T10:44:19+00:00","dateModified":"2021-08-20T11:08:14+00:00","author":{"@id":"https:\/\/bytegeeks.net\/blog\/#\/schema\/person\/419ede240aa968b3bf8202cf9e94e792"},"description":"An easy to follow and straight forward no nonsense guide to creating a simple bash script for quickly checking the temperature of your Pi.","breadcrumb":{"@id":"https:\/\/bytegeeks.net\/blog\/raspberry-pi-temperature-script\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/bytegeeks.net\/blog\/raspberry-pi-temperature-script\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/bytegeeks.net\/blog\/raspberry-pi-temperature-script\/#primaryimage","url":"https:\/\/bytegeeks.net\/blog\/wp-content\/uploads\/2021\/08\/RPi-Temp-Script-Featured-Photo.png","contentUrl":"https:\/\/bytegeeks.net\/blog\/wp-content\/uploads\/2021\/08\/RPi-Temp-Script-Featured-Photo.png","width":1200,"height":630,"caption":"RPi Temp Script Featured Photo"},{"@type":"BreadcrumbList","@id":"https:\/\/bytegeeks.net\/blog\/raspberry-pi-temperature-script\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/bytegeeks.net\/blog\/"},{"@type":"ListItem","position":2,"name":"Raspberry Pi Temperature Script"}]},{"@type":"WebSite","@id":"https:\/\/bytegeeks.net\/blog\/#website","url":"https:\/\/bytegeeks.net\/blog\/","name":"ByteGeeks","description":"Your one-stop shop for everything IT","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/bytegeeks.net\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/bytegeeks.net\/blog\/#\/schema\/person\/419ede240aa968b3bf8202cf9e94e792","name":"Redwan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/bytegeeks.net\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/785ee4165b07a924d3e8538e8fd845bbd1d22e2680c18ebb16aa54890455e008?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/785ee4165b07a924d3e8538e8fd845bbd1d22e2680c18ebb16aa54890455e008?s=96&d=mm&r=g","caption":"Redwan"},"description":"Just your average IT guy talking about IT stuff.","sameAs":["https:\/\/bytegeeks.net\/blog"],"url":"https:\/\/bytegeeks.net\/blog\/author\/redmin\/"}]}},"jetpack_featured_media_url":"https:\/\/bytegeeks.net\/blog\/wp-content\/uploads\/2021\/08\/RPi-Temp-Script-Featured-Photo.png","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/bytegeeks.net\/blog\/wp-json\/wp\/v2\/posts\/76","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bytegeeks.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bytegeeks.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bytegeeks.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bytegeeks.net\/blog\/wp-json\/wp\/v2\/comments?post=76"}],"version-history":[{"count":18,"href":"https:\/\/bytegeeks.net\/blog\/wp-json\/wp\/v2\/posts\/76\/revisions"}],"predecessor-version":[{"id":115,"href":"https:\/\/bytegeeks.net\/blog\/wp-json\/wp\/v2\/posts\/76\/revisions\/115"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/bytegeeks.net\/blog\/wp-json\/wp\/v2\/media\/101"}],"wp:attachment":[{"href":"https:\/\/bytegeeks.net\/blog\/wp-json\/wp\/v2\/media?parent=76"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bytegeeks.net\/blog\/wp-json\/wp\/v2\/categories?post=76"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bytegeeks.net\/blog\/wp-json\/wp\/v2\/tags?post=76"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}