{"id":146346,"date":"2024-03-12T18:04:42","date_gmt":"2024-03-12T18:04:42","guid":{"rendered":"https:\/\/randomnerdtutorials.com\/?p=146346"},"modified":"2024-05-06T10:50:13","modified_gmt":"2024-05-06T10:50:13","slug":"raspberry-pi-pico-internal-temperature-micropython","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-internal-temperature-micropython\/","title":{"rendered":"Raspberry Pi Pico: Read the Internal Temperature Sensor (MicroPython)"},"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. We&#8217;ll show you two different methods to get the temperature using: analog read and <span class=\"rnthl rntliteral\">picozero<\/span> module.<\/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\/01\/Raspberry-Pi-Pico-Internal-Temperature-Sensor-MicroPython-f.jpg?resize=1200%2C675&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Raspberry Pi Pico Read the Internal Temperature Sensor MicroPython\" class=\"wp-image-150056\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/01\/Raspberry-Pi-Pico-Internal-Temperature-Sensor-MicroPython-f.jpg?w=1280&amp;quality=100&amp;strip=all&amp;ssl=1 1280w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/01\/Raspberry-Pi-Pico-Internal-Temperature-Sensor-MicroPython-f.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/01\/Raspberry-Pi-Pico-Internal-Temperature-Sensor-MicroPython-f.jpg?resize=1024%2C576&amp;quality=100&amp;strip=all&amp;ssl=1 1024w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/01\/Raspberry-Pi-Pico-Internal-Temperature-Sensor-MicroPython-f.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 rntclblue\"><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<p><strong>Table of Contents:<\/strong><\/p>\n\n\n\n<p>Throughout this tutorial, we\u2019ll cover the following contents:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#raspberry-pi-pico-internal-temperature-sensor\" title=\"\">The Raspberry Pi Pico&#8217;s Internal Temperature Sensor<\/a><\/li>\n\n\n\n<li><a href=\"#reading-the-temperature-using-adc\" title=\"\">Reading the Temperature using ADC<\/a><\/li>\n\n\n\n<li><a href=\"#reading-temperature-picozero\" title=\"\">Reading the Temperature using picozero<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"prerequisites\">MicroPython Firmware<\/h2>\n\n\n\n<p>To follow this tutorial you need MicroPython firmware installed in your Raspberry Pi Pico board. You also need an IDE to write and upload the code to your board.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-thumbnail\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"150\" height=\"150\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/micropython-logo.png?resize=150%2C150&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"micorpython logo\" class=\"wp-image-148797\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/micropython-logo.png?resize=150%2C150&amp;quality=100&amp;strip=all&amp;ssl=1 150w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/02\/micropython-logo.png?w=250&amp;quality=100&amp;strip=all&amp;ssl=1 250w\" sizes=\"(max-width: 150px) 100vw, 150px\" \/><\/figure><\/div>\n\n\n<p>The recommended MicroPython IDE for the Raspberry Pi Pico is Thonny IDE. Follow the next tutorial to learn how to install Thonny IDE, flash MicroPython firmware, and upload code to the board.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/getting-started-raspberry-pi-pico-w\/#install-thonny-ide\" title=\"\">Programming Raspberry Pi Pico using MicroPython<\/a><\/li>\n<\/ul>\n\n\n\n<p>Alternatively, if you like programming using VS Code, you can start with the following tutorial:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-vs-code-micropython\/\">Programming Raspberry Pi Pico with VS Code and MicroPython<\/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>According to the datasheet, when it&#8217;s 27 degrees Celsius, the voltage is around 0.706V, and for every degree the temperature changes, the voltage goes down by about 1.721mV.<\/p>\n\n\n\n<p>To find the temperature in Celsius using the voltage, you can use this formula:<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>T = 27 - (ADC_voltage - 0.706)\/0.001721<\/code><\/pre>\n\n\n\n<p>Accurate temperature measurements with this sensor can be challenging due to variations in voltage and slope between devices. Consider it more as a reference tool than a precise measurement device. You may need to make adjustments for accuracy.<\/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 get the temperature from the internal temperature sensor, you can use the following code.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-python\"># Rui Santos &amp; Sara Santos - Random Nerd Tutorials\n# Complete project details at https:\/\/RandomNerdTutorials.com\/raspberry-pi-pico-internal-temperature-micropython\/\n\nfrom machine import ADC\n\n# Internal temperature sensor is connected to ADC channel 4\ntemp_sensor = ADC(4)\n\ndef read_internal_temperature():\n    # Read the raw ADC value\n    adc_value = temp_sensor.read_u16()\n\n    # Convert ADC value to voltage\n    voltage = adc_value * (3.3 \/ 65535.0)\n\n    # Temperature calculation based on sensor characteristics\n    temperature_celsius = 27 - (voltage - 0.706) \/ 0.001721\n\n    return temperature_celsius\n\ndef celsius_to_fahrenheit(temp_celsius): \n    temp_fahrenheit = temp_celsius * (9\/5) + 32 \n    return temp_fahrenheit\n\n# Reading and printing the internal temperature\ntemperatureC = read_internal_temperature()\ntemperatureF = celsius_to_fahrenheit(temperatureC)\nprint(&quot;Internal Temperature:&quot;, temperatureC, &quot;\u00b0C&quot;)\nprint(&quot;Internal Temperature:&quot;, temperatureF, &quot;\u00b0F&quot;)\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\/MicroPython\/Pico_Internal_Temperature_Sensor.py\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<p class=\"rntbox rntclgreen\">Recommended reading: <a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-analog-inputs-micropython\/\" title=\"\">Raspberry Pi Pico: Read Analog Inputs (MicroPython)<\/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<h4 class=\"wp-block-heading\">Creating an ADC Object<\/h4>\n\n\n\n<p>You start by importing the <span class=\"rnthl rntliteral\">ADC<\/span> class from the <span class=\"rnthl rntliteral\">machine<\/span> module to read analog signals.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>from machine import ADC<\/code><\/pre>\n\n\n\n<p>The internal temperature sensor is connected to ADC4. So, we create an <span class=\"rnthl rntliteral\">ADC<\/span> object on that pin called <span class=\"rnthl rntliteral\">temp_sensor<\/span>.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>temp_sensor = ADC(4)<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Reading the Internal Temperature Sensor<\/h4>\n\n\n\n<p>Then, we create a function to read the internal temperature sensor called <span class=\"rnthl rntliteral\">read_internal_temperature()<\/span>.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>def read_internal_temperature():<\/code><\/pre>\n\n\n\n<p>We get the ADC reading using the <span class=\"rnthl rntliteral\">read_u16()<\/span> function. <a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-analog-inputs-micropython\/\" title=\"\">Learn how to read analog signals with the Raspberry Pi Pico with this guide<\/a>.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>adc_value = temp_sensor.read_u16()<\/code><\/pre>\n\n\n\n<p>Then, we need to convert that number to a voltage value. We know that 3.3V corresponds to 65535, so, we can calculate it as follows.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>voltage = adc_value * (3.3 \/ 65535.0)<\/code><\/pre>\n\n\n\n<p>Finally, we can use the formula provided by the datasheet to get the temperature in Celsius.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>temperature_celsius = 27 - (voltage - 0.706) \/ 0.001721<\/code><\/pre>\n\n\n\n<p>The function returns the temperature in Celsius.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>return temperature_celsius<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Converting to Fahrenheit<\/h4>\n\n\n\n<p>We also included the <span class=\"rnthl rntliteral\">celsius_to_fahrenheit()<\/span> function to convert the temperature in Celsius to Fahrenheit.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>def celsius_to_fahrenheit(temp_celsius): \n    temp_fahrenheit = temp_celsius * (9\/5) + 32 \n    return temp_fahrenheit<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Getting and Printing the Temperature Readings<\/h4>\n\n\n\n<p>We call the <span class=\"rnthl rntliteral\">read_internal_temperature()<\/span> function to get the temperature in Celsius and save it to the <span class=\"rnthl rntliteral\">temperatureC<\/span> variable.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>temperatureC = read_internal_temperature()<\/code><\/pre>\n\n\n\n<p>Then, we call the <span class=\"rnthl rntliteral\">celsius_to_fahrenheit()<\/span> function and pass as an argument the <span class=\"rnthl rntliteral\">temperatureC<\/span> to get the temperature in Fahrenheit.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>temperatureF = celsius_to_fahrenheit(temperatureC)<\/code><\/pre>\n\n\n\n<p>Finally, we print the readings in the shell.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>print(\"Internal Temperature:\", temperatureC, \"\u00b0C\")\nprint(\"Internal Temperature:\", temperatureF, \"\u00b0F\")<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Testing the Code<\/h2>\n\n\n\n<p>Copy the code provided to Thonny IDE. Click on the green <strong>Run<\/strong> button.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"470\" height=\"114\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/12\/thonny-ide-run-button.png?resize=470%2C114&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Testing the Raspberry Pi Pico Code on Thonny IDE\" class=\"wp-image-144594\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/12\/thonny-ide-run-button.png?w=470&amp;quality=100&amp;strip=all&amp;ssl=1 470w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/12\/thonny-ide-run-button.png?resize=300%2C73&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 470px) 100vw, 470px\" \/><\/figure><\/div>\n\n\n<p>The temperature of the sensor will be printed in the Shell both in Celsius and Fahrenheit degrees.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"664\" height=\"216\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/01\/internal-temperature-sensor-testing-Copy.png?resize=664%2C216&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Raspberry Pi Pico, read internal temperature sensor\" class=\"wp-image-146348\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/01\/internal-temperature-sensor-testing-Copy.png?w=664&amp;quality=100&amp;strip=all&amp;ssl=1 664w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/01\/internal-temperature-sensor-testing-Copy.png?resize=300%2C98&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 664px) 100vw, 664px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"reading-temperature-picozero\">Reading the Temperature using picozero<\/h2>\n\n\n\n<p>There\u2019s an easier way to get a reading from the internal temperature sensor using the <span class=\"rnthl rntliteral\">picozero<\/span> module. The <span class=\"rnthl rntliteral\">picozero<\/span> module is a beginner-friendly library with easy \u201crecipes\u201d to use the most common sensors. If you want to learn more about the picozero library, you can check the <a href=\"https:\/\/picozero.readthedocs.io\/en\/latest\/index.html\" target=\"_blank\" rel=\"noopener\" title=\"\">picozero documentation<\/a>.<\/p>\n\n\n\n<p>The <span class=\"rnthl rntliteral\">picozero<\/span> library comes with a class called <span class=\"rnthl rntliteral\">pico_temp_sensor<\/span> that allows you to easily get the temperature without the need for any calculations (everything is done in the background).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Installing the picozero Package<\/h3>\n\n\n\n<p>You need to install the <span class=\"rnthl rntliteral\">picozero<\/span> package before proceeding.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Go to <strong>Tools<\/strong> &gt; <strong>Manage<\/strong> <strong>Packages<\/strong>.<\/li>\n\n\n\n<li>Search for <strong>picozero<\/strong>.<\/li>\n\n\n\n<li>Click on the first <em>picozero @ PyPi<\/em> option.<\/li>\n\n\n\n<li>Finally, click <strong>Install<\/strong>.<\/li>\n<\/ol>\n\n\n\n<p>After a few seconds, the package will be installed.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"644\" height=\"464\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/01\/install-picozero.png?resize=644%2C464&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Raspberry Pi Pico installing the picozero package\" class=\"wp-image-146347\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/01\/install-picozero.png?w=644&amp;quality=100&amp;strip=all&amp;ssl=1 644w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/01\/install-picozero.png?resize=300%2C216&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 644px) 100vw, 644px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\">Code<\/h2>\n\n\n\n<p>The following code does the same as the previous example, but it uses the <span class=\"rnthl rntliteral\">picozero<\/span> library instead.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-python\"># Rui Santos &amp; Sara Santos - Random Nerd Tutorials\n# Complete project details at https:\/\/RandomNerdTutorials.com\/raspberry-pi-pico-internal-temperature-micropython\/\n\nfrom picozero import pico_temp_sensor\n\n# Convert from celsius to fahrenheit\ndef celsius_to_fahrenheit(temp_celsius): \n    temp_fahrenheit = temp_celsius * (9\/5) + 32 \n    return temp_fahrenheit\n\n# Reading and printing the internal temperature\ntemperatureC = pico_temp_sensor.temp\ntemperatureF = celsius_to_fahrenheit(temperatureC)\n\nprint(&quot;Internal Temperature:&quot;, temperatureC, &quot;\u00b0C&quot;)\nprint(&quot;Internal Temperature:&quot;, temperatureF, &quot;\u00b0F&quot;)\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\/MicroPython\/Internal_Temperature_Sensor_picozero.py\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<p>We first, need to import the <span class=\"rnthl rntliteral\">pico_temp_sensor<\/span> class from the <span class=\"rnthl rntliteral\">picozero<\/span> module.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>from picozero import pico_temp_sensor<\/code><\/pre>\n\n\n\n<p>Then, we get the temperature using <span class=\"rnthl rntliteral\">pico_temp_sensor.temp<\/span>. We save the temperature in Celsius degrees on the <span class=\"rnthl rntliteral\">temperatureC<\/span> variable.<\/p>\n\n\n\n<pre class=\"wp-block-code language-python\"><code>temperatureC = pico_temp_sensor.temp<\/code><\/pre>\n\n\n\n<p>If you run this code on your Raspberry Pi Pico, you\u2019ll get the same result as the previous example.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Continuous Temperature Readings<\/h3>\n\n\n\n<p>If you want to continuously get new temperature readings, you can read and print the readings inside a <span class=\"rnthl rntliteral\">while<\/span> loop. In that case, the code will look as follows:<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-python\"># Rui Santos &amp; Sara Santos - Random Nerd Tutorials\n# Complete project details at https:\/\/RandomNerdTutorials.com\/raspberry-pi-pico-internal-temperature-micropython\/\n\nfrom time import sleep\nfrom picozero import pico_temp_sensor\n\n# Convert from celsius to fahrenheit\ndef celsius_to_fahrenheit(temp_celsius): \n    temp_fahrenheit = temp_celsius * (9\/5) + 32 \n    return temp_fahrenheit\n\nwhile True:\n    # Reading and printing the internal temperature\n    temperatureC = pico_temp_sensor.temp\n    temperatureF = celsius_to_fahrenheit(temperatureC)\n\n    print(&quot;Internal Temperature:&quot;, temperatureC, &quot;\u00b0C&quot;)\n    print(&quot;Internal Temperature:&quot;, temperatureF, &quot;\u00b0F&quot;)\n    \n    # Wait one second between each reading\n    sleep(1)\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\/MicroPython\/Internal_Temperature_Sensor_picozero_loop.py\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<p>With this example, you&#8217;ll get new temperature readings printed on the MicroPython shell every second until you stop the program.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"664\" height=\"378\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/01\/internal-temperature-sensor-testing-loop-Copy.png?resize=664%2C378&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Raspberry Pi Pico read internal temperature sensor\" class=\"wp-image-146350\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/01\/internal-temperature-sensor-testing-loop-Copy.png?w=664&amp;quality=100&amp;strip=all&amp;ssl=1 664w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/01\/internal-temperature-sensor-testing-loop-Copy.png?resize=300%2C171&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 664px) 100vw, 664px\" \/><\/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 temperature is as easy as reading the voltage on ADC4 and then making the necessary calculations. Alternatively, you can also use the <span class=\"rnthl rntliteral\">picozero<\/span> package.<\/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-micropython\/\" title=\"\">Raspberry Pi Pico: Read Analog Inputs (MicroPython)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-outputs-inputs-micropython\/\" title=\"\">Raspberry Pi Pico: Control Digital Outputs and Read Digital Inputs (MicroPython)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-pwm-micropython\/\" title=\"\">Raspberry Pi Pico: PWM Fading an LED (MicroPython)<\/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=\"\"><strong>Learn Raspberry Pi Pico with MicroPython eBook<\/strong><\/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. We&#8217;ll show you &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Raspberry Pi Pico: Read the Internal Temperature Sensor (MicroPython)\" class=\"read-more button\" href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-internal-temperature-micropython\/#more-146346\" aria-label=\"Read more about Raspberry Pi Pico: Read the Internal Temperature Sensor (MicroPython)\">CONTINUE READING \u00bb<\/a><\/p>\n","protected":false},"author":5,"featured_media":150056,"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,326],"tags":[],"class_list":["post-146346","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-raspberry-pi-pico","category-raspberry-pi-pico-micropython"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/01\/Raspberry-Pi-Pico-Internal-Temperature-Sensor-MicroPython-f.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\/146346","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=146346"}],"version-history":[{"count":6,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/146346\/revisions"}],"predecessor-version":[{"id":154859,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/146346\/revisions\/154859"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/150056"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=146346"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=146346"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=146346"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}