{"id":150059,"date":"2024-03-10T16:34:21","date_gmt":"2024-03-10T16:34:21","guid":{"rendered":"https:\/\/randomnerdtutorials.com\/?p=150059"},"modified":"2024-03-12T17:58:03","modified_gmt":"2024-03-12T17:58:03","slug":"raspberry-pi-pico-internal-temperature-arduino","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-internal-temperature-arduino\/","title":{"rendered":"Raspberry Pi Pico: Read the Internal Temperature Sensor (Arduino IDE)"},"content":{"rendered":"\n<p>The Raspberry Pi Pico comes with a built-in temperature sensor connected to ADC4. In this quick guide, you\u2019ll learn how to get temperature data from that sensor using Arduino IDE.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" width=\"1200\" height=\"675\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Raspberry-Pi-Pico-Internal-Temperature-Sensor-Arduino-IDE.jpg?resize=1200%2C675&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Raspberry Pi Pico Read the Internal Temperature Sensor Arduino IDE\" class=\"wp-image-150062\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Raspberry-Pi-Pico-Internal-Temperature-Sensor-Arduino-IDE.jpg?w=1280&amp;quality=100&amp;strip=all&amp;ssl=1 1280w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Raspberry-Pi-Pico-Internal-Temperature-Sensor-Arduino-IDE.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Raspberry-Pi-Pico-Internal-Temperature-Sensor-Arduino-IDE.jpg?resize=1024%2C576&amp;quality=100&amp;strip=all&amp;ssl=1 1024w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Raspberry-Pi-Pico-Internal-Temperature-Sensor-Arduino-IDE.jpg?resize=768%2C432&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/figure><\/div>\n\n\n<p class=\"rntbox rntclgreen\"><strong>New to the Raspberry Pi Pico?<\/strong>&nbsp;Read the following guide:&nbsp;<a href=\"https:\/\/randomnerdtutorials.com\/getting-started-raspberry-pi-pico-w\/\">Getting Started with Raspberry Pi Pico (and Pico W)<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p>You need to install the Raspberry Pi Pico boards on Arduino IDE and you must know how to upload code to the board. Check out the following tutorial first if you haven\u2019t already:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/programming-raspberry-pi-pico-w-arduino-ide\/\">Programming Raspberry Pi Pico with Arduino IDE<\/a><\/li>\n<\/ul>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"raspberry-pi-pico-internal-temperature-sensor\">The Internal Temperature Sensor<\/h1>\n\n\n\n<p>The <a href=\"https:\/\/makeradvisor.com\/tools\/raspberry-pi-pico-w\/\" target=\"_blank\" rel=\"noopener\" title=\"\">Raspberry Pi Pico<\/a> internal temperature sensor works by checking the voltage of a special diode connected to <strong>ADC4 <\/strong>on the Raspberry Pi Pico.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"750\" height=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/07\/raspberry-pi-pico-gpio-pins.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Raspberry Pi Pico\" class=\"wp-image-133903\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/07\/raspberry-pi-pico-gpio-pins.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/07\/raspberry-pi-pico-gpio-pins.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>Accurate temperature measurements with this sensor can be challenging. Consider it more as a reference tool than a precise measurement device.<\/p>\n\n\n\n<h1 class=\"wp-block-heading\" id=\"reading-the-temperature-using-adc\">Reading the Temperature using ADC<\/h1>\n\n\n\n<p>To read the Raspberry Pi Pico internal temperature sensor using Arduino IDE, you can use the <span class=\"rnthl rntliteral\">analogReadTemp()<\/span> function that returns the temperature in Celsius degrees.<\/p>\n\n\n\n<p>You can use the following code to test it. This code prints the temperature in Celsius and Fahrenheit degrees to the Serial Monitor.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">\/*********\n  Rui Santos &amp; Sara Santos - Random Nerd Tutorials\n  Complete project details at https:\/\/RandomNerdTutorials.com\/raspberry-pi-pico-internal-temperature-arduino\/\n*********\/\n\nfloat tempC;\nfloat tempF;\n\nvoid setup() {\n  Serial.begin(115200);\n}\n\nvoid loop() {\n  tempC = analogReadTemp(); \/\/ Get internal temperature\n  tempF = tempC * 9.0 \/ 5.0 + 32.0; \/\/ Fahrenheit conversion\n  Serial.print(&quot;Temperature Celsius (\u00baC): &quot;);\n  Serial.println(tempC);\n  Serial.print(&quot;Temperature Fahrenheit (\u00baF): &quot;);\n  Serial.println(tempF);\n  delay(1000);\n}\n<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/Raspberry-Pi-Pico\/Arduino\/Pico_Internal_Temperature_Sensor.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How the Code Works<\/h3>\n\n\n\n<p>Let\u2019s take a quick look at how the code works.<\/p>\n\n\n\n<p class=\"rntbox rntclgreen\">Recommended reading: <a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-analog-inputs-arduino\/\">Raspberry Pi Pico: Read Analog Inputs (Arduino IDE)<\/a><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Initializing variables<\/h4>\n\n\n\n<p>Start by creating two variables <span class=\"rnthl rntliteral\">tempC<\/span>, and <span class=\"rnthl rntliteral\">tempF<\/span> to hold the temperature values in Celsius and Fahrenheit degrees.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>float tempC;\nfloat tempF;<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Initialize the Serial Monitor<\/h4>\n\n\n\n<p>In the <span class=\"rnthl rntliteral\">setup()<\/span>, initialize the Serial Monitor at a baud rate of 115200<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>void setup() {\n  Serial.begin(115200);\n}<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Get and Print the Temperature<\/h4>\n\n\n\n<p>We get the Raspberry Pi Pico internal temperature sensor in Celsius degrees by using the <span class=\"rnthl rntliteral\">analogReadTemp()<\/span> function.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>tempC = analogReadTemp(); \/\/ Get internal temperature<\/code><\/pre>\n\n\n\n<p>Then, we convert the temperature in Celsius to Fahrenheit degrees.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>tempF = tempC * 9.0 \/ 5.0 + 32.0; \/\/ Fahrenheit conversion<\/code><\/pre>\n\n\n\n<p>Finally, we print the readings in the Serial Monitor.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>Serial.print(\"Temperature Celsius (\u00baC): \");\nSerial.println(tempC);\nSerial.print(\"Temperature Fahrenheit (\u00baF): \");\nSerial.println(tempF);<\/code><\/pre>\n\n\n\n<p>The readings are printed every second (1000 milliseconds).<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>delay(1000);<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Testing the Code<\/h2>\n\n\n\n<p>Upload the code to the Raspberry Pi Pico. <strong>Don&#8217;t know how to upload code?<\/strong> Check this tutorial: <a href=\"https:\/\/randomnerdtutorials.com\/programming-raspberry-pi-pico-w-arduino-ide\/\" title=\"\">Programming Raspberry Pi Pico with Arduino IDE<\/a>.<\/p>\n\n\n\n<p>Open the Serial Monitor at a baud rate of 115200.<\/p>\n\n\n\n<p>New temperature readings in Celsius and Fahrenheit degrees will be printed in the Serial Monitor every second.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"672\" height=\"372\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/raspberry-pi-pico-internal-temperature-sensor-demonstration.png?resize=672%2C372&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Reading Raspberry Pi Pico Internal Temperature Sensor\" class=\"wp-image-150060\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/raspberry-pi-pico-internal-temperature-sensor-demonstration.png?w=672&amp;quality=100&amp;strip=all&amp;ssl=1 672w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/raspberry-pi-pico-internal-temperature-sensor-demonstration.png?resize=300%2C166&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 672px) 100vw, 672px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\">Wrapping Up<\/h2>\n\n\n\n<p>The Raspberry Pi Pico comes with an internal temperature sensor to give you a general idea of the Pico&#8217;s internal temperature.<\/p>\n\n\n\n<p>Reading the Pico&#8217;s temperature using Arduino IDE is as easy as using the <span class=\"rnthl rntliteral\">analogReadTemp()<\/span> function. You may take this project further and display the temperature on an OLED display: <a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-ssd1306-oled-arduino\/\">Raspberry Pi Pico: SSD1306 OLED Display (Arduino IDE)<\/a>.<\/p>\n\n\n\n<p>We hope you&#8217;ve found this tutorial useful. If you&#8217;re just getting started with the Raspberry Pi Pico, you might also like the following tutorials:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-analog-inputs-arduino\/\">Raspberry Pi Pico: Read Analog Inputs (Arduino IDE)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-outputs-inputs-arduino\/\">Raspberry Pi Pico: Control Digital Outputs and Read Digital Inputs (Arduino IDE)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-pwm-analogwrite-arduino\/\">Raspberry Pi Pico: Fading an LED using PWM (Arduino IDE)<\/a><\/li>\n<\/ul>\n\n\n\n<p>Learn more about the Raspberry Pi Pico with our resources:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/projects-raspberry-pi-pico\/\" title=\"\">Raspberry Pi Pico Projects and Guides<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-w-micropython-ebook\/\" title=\"\">Learn Raspberry Pi Pico with MicroPython eBook<\/a><\/li>\n<\/ul>\n\n\n\n<p>Thanks for reading.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Raspberry Pi Pico comes with a built-in temperature sensor connected to ADC4. In this quick guide, you\u2019ll learn how to get temperature data from that sensor using Arduino IDE. &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Raspberry Pi Pico: Read the Internal Temperature Sensor (Arduino IDE)\" class=\"read-more button\" href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-internal-temperature-arduino\/#more-150059\" aria-label=\"Read more about Raspberry Pi Pico: Read the Internal Temperature Sensor (Arduino IDE)\">CONTINUE READING \u00bb<\/a><\/p>\n","protected":false},"author":5,"featured_media":150062,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[324,325],"tags":[],"class_list":["post-150059","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-raspberry-pi-pico","category-raspberry-pi-pico-arduino-ide"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/03\/Raspberry-Pi-Pico-Internal-Temperature-Sensor-Arduino-IDE.jpg?fit=1280%2C720&quality=100&strip=all&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/150059","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/comments?post=150059"}],"version-history":[{"count":5,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/150059\/revisions"}],"predecessor-version":[{"id":150188,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/150059\/revisions\/150188"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/150062"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=150059"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=150059"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=150059"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}