{"id":133284,"date":"2023-09-13T21:55:45","date_gmt":"2023-09-13T21:55:45","guid":{"rendered":"https:\/\/randomnerdtutorials.com\/?p=133284"},"modified":"2024-01-08T12:25:27","modified_gmt":"2024-01-08T12:25:27","slug":"raspberry-pi-pico-ds18b20-arduino","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-ds18b20-arduino\/","title":{"rendered":"Raspberry Pi Pico: DS18B20 Temperature Sensor (Arduino IDE) &#8211; Single and Multiple"},"content":{"rendered":"\n<p>In this guide, you&#8217;ll learn how to interface the Raspberry Pi Pico with the DS18B20 temperature sensor and how to get temperature readings using Arduino IDE. The DS18B20 is an addressable temperature sensor, which means you can connect multiple sensors to the same GPIO. We&#8217;ll also show you how to get temperature from multiple DS18B20 sensors all at once.<\/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\/2023\/07\/Raspberry-Pi-Pico-DS18B20-Arduino-IDE.jpg?resize=1200%2C675&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Raspberry Pi Pico DS18B20 Temperature Sensor Arduino IDE Single and Multiple\" class=\"wp-image-133297\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/07\/Raspberry-Pi-Pico-DS18B20-Arduino-IDE.jpg?w=1280&amp;quality=100&amp;strip=all&amp;ssl=1 1280w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/07\/Raspberry-Pi-Pico-DS18B20-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\/2023\/07\/Raspberry-Pi-Pico-DS18B20-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\/2023\/07\/Raspberry-Pi-Pico-DS18B20-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\">We have a similar guide but using MicroPython firmware: <a href=\"https:\/\/randomnerdtutorials.com\/aspberry-pi-pico-ds18b20-micropython\/\" title=\"\">Raspberry Pi Pico: DS18B20 Temperature Sensor (MicroPython) \u2013 Single and Multiple<\/a>.<\/p>\n\n\n\n<p><strong>Table of Contents<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#ds18b20-intro\" title=\"\">Introducing DS18B20 Temperature Sensor<\/a><\/li>\n\n\n\n<li><a href=\"#rpi-pico-ds18b20-wiring\" title=\"\">Raspberry Pi Pico with DS18B20 (single) Wiring<\/a><\/li>\n\n\n\n<li><a href=\"#microds18b20-library\" title=\"\">Installing the microDS18B20 Library<\/a><\/li>\n\n\n\n<li><a href=\"#Get-Temperature-Readings-arduino-code\" title=\"\">Getting DS18B20 Temperature Readings (single) &#8211; Arduino Code<\/a><\/li>\n\n\n\n<li><a href=\"#multiple-ds18b20\" title=\"\">Raspberry Pi Pico with Multiple DS18B20 Sensors<\/a>\n<ul class=\"wp-block-list\">\n<li><a href=\"#ds18b20-address\" title=\"\">Getting DS18B20 Sensors&#8217; Individual Address<\/a><\/li>\n\n\n\n<li><a href=\"#Rpi-Pico-multiple-ds18b20-sensors-wiring\" title=\"\">Wiring Multiple DS18B20 Sensors with Raspberry Pi Pico<\/a><\/li>\n\n\n\n<li><a href=\"#multiple-ds18b20-raspberry-pi-pico-arduino-code\" title=\"\">Getting Temperature from Multiple DS18B20 Sensors &#8211; Arduino Code<\/a><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"prerequisites\">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<h2 class=\"wp-block-heading\" id=\"ds18b20-intro\">Introducing DS18B20 Temperature Sensor<\/h2>\n\n\n\n<p>The <a aria-label=\" (opens in a new tab)\" href=\"https:\/\/makeradvisor.com\/tools\/ds18b20-temperature-sensor-2\/\" target=\"_blank\" rel=\"noreferrer noopener\">DS18B20 temperature sensor<\/a> is a one-wire digital temperature sensor. This means that it just requires one data line (and GND) to communicate with your Raspberry Pi Pico.<\/p>\n\n\n\n<p>It can be powered by an external power supply or it can derive power from the data line (called &#8220;parasite mode&#8221;), which eliminates the need for an external power supply.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"750\" height=\"490\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/07\/DS18B20-tempeature-sensor-pinout.jpg?resize=750%2C490&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"DS18B20 Temperature Sensor Pinout Pins\" class=\"wp-image-86735\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/07\/DS18B20-tempeature-sensor-pinout.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/07\/DS18B20-tempeature-sensor-pinout.jpg?resize=300%2C196&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>Each DS18B20 temperature sensor has a unique 64-bit serial code. This allows you to wire multiple sensors to the same data wire. So, you can get temperature from multiple sensors using just one GPIO.<\/p>\n\n\n\n<p>The DS18B20 temperature sensor is also available in <a href=\"https:\/\/makeradvisor.com\/tools\/ds18b20-digital-temperature-sensor\/\" target=\"_blank\" rel=\"noopener\" title=\"\">waterproof version<\/a>.<\/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=\"421\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/07\/ds18b20-waterproof.jpg?resize=750%2C421&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"DS18B20 Temperature Sensor Waterproof version\" class=\"wp-image-86674\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/07\/ds18b20-waterproof.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/07\/ds18b20-waterproof.jpg?resize=300%2C168&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>Here&#8217;s a summary of the most relevant specs of the DS18B20 temperature sensor:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Communicates over one-wire bus communication<\/li>\n\n\n\n<li>Power supply range: 3.0V to 5.5V<\/li>\n\n\n\n<li>Operating temperature range: -55\u00baC to +125\u00baC<\/li>\n\n\n\n<li>Accuracy +\/-0.5 \u00baC (between the range -10\u00baC to 85\u00baC)<\/li>\n<\/ul>\n\n\n\n<p>For more information consult the <a aria-label=\" (opens in a new tab)\" href=\"https:\/\/datasheets.maximintegrated.com\/en\/ds\/DS18B20.pdf\" target=\"_blank\" rel=\"noreferrer noopener\">DS18B20 datasheet<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Parts Required<\/h2>\n\n\n\n<p>To follow this tutorial you need the following parts:<\/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=\"750\" height=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/07\/ds18b20-temperature-sensor.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-133302\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/07\/ds18b20-temperature-sensor.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/07\/ds18b20-temperature-sensor.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<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/raspberry-pi-pico-w\/\" title=\"\">Raspberry Pi Pico<\/a><\/li>\n\n\n\n<li><a rel=\"noreferrer noopener\" href=\"https:\/\/makeradvisor.com\/tools\/ds18b20-temperature-sensor-2\/\" target=\"_blank\">DS18B20 temperature sensor<\/a> (one or multiple sensors) \u2013&nbsp;<a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/makeradvisor.com\/tools\/ds18b20-digital-temperature-sensor\/\" target=\"_blank\">waterproof version<\/a><\/li>\n\n\n\n<li><a rel=\"noreferrer noopener\" aria-label=\"4.7k Ohm resistor\u2028 (opens in a new tab)\" href=\"https:\/\/makeradvisor.com\/tools\/resistors-kits\/\" target=\"_blank\">4.7k Ohm resistor<\/a><\/li>\n\n\n\n<li><a rel=\"noreferrer noopener\" aria-label=\"Jumper wires (opens in a new tab)\" href=\"https:\/\/makeradvisor.com\/tools\/jumper-wires-kit-120-pieces\/\" target=\"_blank\">Jumper wires<\/a><\/li>\n\n\n\n<li><a rel=\"noreferrer noopener\" aria-label=\"Breadboard (opens in a new tab)\" href=\"https:\/\/makeradvisor.com\/tools\/mb-102-solderless-breadboard-830-points\/\" target=\"_blank\">Breadboard<\/a><\/li>\n<\/ul>\n\n\n<p>You can use the preceding links or go directly to <a href=\"https:\/\/makeradvisor.com\/tools\/?utm_source=rnt&utm_medium=post&utm_campaign=post\" target=\"_blank\">MakerAdvisor.com\/tools<\/a> to find all the parts for your projects at the best price!<\/p><p style=\"text-align:center;\"><a href=\"https:\/\/makeradvisor.com\/tools\/?utm_source=rnt&utm_medium=post&utm_campaign=post\" target=\"_blank\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/10\/header-200.png?w=1200&#038;quality=100&#038;strip=all&#038;ssl=1\"><\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"rpi-pico-ds18b20-wiring\">Wiring the DS18B20 Temperature Sensor to the Raspberry Pi Pico<\/h2>\n\n\n\n<p>The DS18B20 temperature sensor comes with three pins: GND, data, and VCC. the DS18B20 temperature sensor can be powered through the VDD pin (<strong>normal mode<\/strong>), or it can derive its power from the data line (<strong>parasite mode<\/strong>). You can choose either mode. We prefer using the normal mode.<\/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=\"490\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/07\/DS18B20-tempeature-sensor-pinout.jpg?resize=750%2C490&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"DS18B20 Temperature Sensor Pinout Pins\" class=\"wp-image-86735\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/07\/DS18B20-tempeature-sensor-pinout.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2019\/07\/DS18B20-tempeature-sensor-pinout.jpg?resize=300%2C196&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>If you&#8217;re using the waterproof version, you can identify each pin by its color:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span class=\"rnthl rntcblack\">black<\/span>: GND<\/li>\n\n\n\n<li><span class=\"rnthl rntcred\">red<\/span>: VDD<\/li>\n\n\n\n<li><span class=\"rnthl rntcyellow\">yellow<\/span>: data line<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>DS18B20<\/strong><\/td><td><strong>Raspberry Pi Pico<\/strong><\/td><\/tr><tr><td><span class=\"rnthl rntcblack\">GND<\/span><\/td><td>GND<\/td><\/tr><tr><td>Data (<span class=\"rnthl rntcyellow\">DQ<\/span>)<\/td><td>Any digital GPIO (we&#8217;ll be using GPIO22); <br>you also need to connect a 4.7KOhm resistor between the data line and VCC<\/td><\/tr><tr><td><span class=\"rnthl rntcred\">VDD<\/span><\/td><td>3V3(OUT)<\/td><\/tr><\/tbody><\/table><figcaption class=\"wp-element-caption\">You can also take a look at the following schematic diagram:<\/figcaption><\/figure>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"772\" height=\"566\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/07\/raspberry-pi-pico-ds18b20-wiring_bb.png?resize=772%2C566&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Raspberry Pi Pico DS18B20 Single Wiring\" class=\"wp-image-133318\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/07\/raspberry-pi-pico-ds18b20-wiring_bb.png?w=772&amp;quality=100&amp;strip=all&amp;ssl=1 772w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/07\/raspberry-pi-pico-ds18b20-wiring_bb.png?resize=300%2C220&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/07\/raspberry-pi-pico-ds18b20-wiring_bb.png?resize=768%2C563&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 772px) 100vw, 772px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"microds18b20-library\">Installing the microDS18B20 Library<\/h2>\n\n\n\n<p>To read the temperature from the DS18B20 on the Raspberry Pi Pico using Arduino IDE, we&#8217;ll use the microSD18B20 library. Follow the next steps to install the library.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open your Arduino IDE;<\/li>\n\n\n\n<li>Go to Sketch &gt; Include Library &gt; Manage Libraries. The Library Manager should open.<\/li>\n\n\n\n<li>Search for <strong>microSD18B20<\/strong> and install the library.<\/li>\n<\/ol>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"786\" height=\"443\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/07\/microds18b20-arduino-ide-library.png?resize=786%2C443&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"microds18b20 arduino ide install library\" class=\"wp-image-133301\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/07\/microds18b20-arduino-ide-library.png?w=786&amp;quality=100&amp;strip=all&amp;ssl=1 786w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/07\/microds18b20-arduino-ide-library.png?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/07\/microds18b20-arduino-ide-library.png?resize=768%2C433&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 786px) 100vw, 786px\" \/><\/figure><\/div>\n\n\n<p>After installing the library, restart your Arduino IDE.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"Get-Temperature-Readings-arduino-code\">Raspberry Pi Pico with DS18B20 &#8211; Get Temperature (Arduino Code)<\/h2>\n\n\n\n<p>Open your Arduino IDE and copy the following code. It simply gets the temperature from the DS18B20 sensors and prints it in the Serial Monitor. This code is adapted from the microDS18B20 library&#8217;s examples.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">\/*********\n  Rui Santos\n  Complete project details at https:\/\/RandomNerdTutorials.com\/raspberry-pi-pico-ds18b20-arduino\/\n  \n  Example adapted from the microDS18B20 library examples folder - microSD18B20 library: https:\/\/github.com\/GyverLibs\/microDS18B20\n*********\/\n\n#include &lt;microDS18B20.h&gt;\n\n\/\/ We're using GPIO 22, change accordingly\nMicroDS18B20&lt;22&gt; sensor;\n\nvoid setup() {\n  Serial.begin(115200);\n}\n\nvoid loop() {\n  \/\/request temperature from sensor\n  sensor.requestTemp();\n\n  delay(1000);\n  \n  \/\/print the temperature\n  Serial.print(&quot;Temperature (\u00baC): &quot;);\n  Serial.println(sensor.getTemp());\n\n  \/\/Temperature in Fahrenheit\n  \/\/Serial.print(&quot;Temperature (\u00baF): &quot;);\n  \/\/Serial.println(sensor.getTemp()*(9.0\/5.0) + 32.0);\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\/DS18B20_Single.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How does the code work?<\/h2>\n\n\n\n<p>Continue reading to learn how the code works, or skip to the <a href=\"#demonstration\" title=\"\">Demonstration <\/a>section.<\/p>\n\n\n\n<p>Start by including the <span class=\"rnthl rntliteral\">microDS18B20<\/span> library, which provides the necessary functions to work with the DS18B20 temperature sensor.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#include &lt;microDS18B20.h&gt;<\/code><\/pre>\n\n\n\n<p>The following line declares an instance of the <span class=\"rnthl rntliteral\">MicroDS18B20<\/span> class, called <span class=\"rnthl rntliteral\">sensor<\/span> that refers to the temperature sensor connected to <strong>GPIO 22<\/strong>. If your DS18B20 sensor is connected to a different pin, modify the line of code accordingly.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>MicroDS18B20&lt;22&gt; sensor;<\/code><\/pre>\n\n\n\n<p>In the <span class=\"rnthl rntliteral\">setup()<\/span>, initialize a serial communication at a baud rate of 115200, so that you&#8217;re able to display the readings in the Serial Monitor later on.<\/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<p>In the <span class=\"rnthl rntliteral\">loop()<\/span> function is where we get the temperature from the sensor. The following line <span class=\"rnthl rntliteral\">sensor.requestTemp()<\/span> is called to request the temperature reading from the DS18B20 sensor.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>sensor.requestTemp();<\/code><\/pre>\n\n\n\n<p>A delay of 1000 milliseconds is used to give the sensor enough time to measure and provide the temperature reading.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>delay(100);<\/code><\/pre>\n\n\n\n<p>The temperature reading in Celsius degrees is obtained by calling <span class=\"rnthl rntliteral\">sensor.getTemp()<\/span>. The temperature value is then printed to the serial monitor.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>Serial.println(sensor.getTemp());<\/code><\/pre>\n\n\n\n<p>If you want to print the temperature in Fahrenheit, uncomment the following lines (remove the <span class=\"rnthl rntliteral\">\/\/<\/span> at the beginning of those lines):<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>\/\/Temperature in Fahrenheit\n\/\/Serial.print(\"Temperature (\u00baF): \");\n\/\/Serial.println(sensor.getTemp()*(9.0\/5.0) + 32.0);<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Uploading the Code to the Raspberry Pi Pico<\/h2>\n\n\n\n<p>For you to be able to upload code to the Raspberry Pi Pico, it needs to be in bootloader mode.<\/p>\n\n\n\n<p>If the Raspberry Pi is currently running MicroPython firmware, you need to manually put it into bootloader mode. For that, connect the Raspberry Pi Pico to your computer while holding the BOOTSEL button at the same time.<\/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=\"750\" height=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/05\/Raspberry-Pi-Pico-Bottloader-mode.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Raspberry Pi Pico Bootloader mode\" class=\"wp-image-130903\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/05\/Raspberry-Pi-Pico-Bottloader-mode.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/05\/Raspberry-Pi-Pico-Bottloader-mode.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>For future uploads using Arduino IDE, the board should go automatically into bootloader mode without the need to press the BOOTSEL button.<\/p>\n\n\n\n<p>Now, select your COM port in <strong>Tools <\/strong>&gt; <strong>Port<\/strong>. It may be the case that the COM port is grayed out. If that&#8217;s the case, don&#8217;t worry it will automatically find the port once you hit the upload 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=\"595\" height=\"684\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/06\/Raspberry-Pi-Pico-COM-port-not-showing.png?resize=595%2C684&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Raspberry Pi Pico - COM port not found Arduino IDE\" class=\"wp-image-132415\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/06\/Raspberry-Pi-Pico-COM-port-not-showing.png?w=595&amp;quality=100&amp;strip=all&amp;ssl=1 595w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/06\/Raspberry-Pi-Pico-COM-port-not-showing.png?resize=261%2C300&amp;quality=100&amp;strip=all&amp;ssl=1 261w\" sizes=\"(max-width: 595px) 100vw, 595px\" \/><\/figure><\/div>\n\n\n<p>Upload the code.<\/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=\"30\" height=\"30\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/05\/arduino-2-0-upload-button.png?resize=30%2C30&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Arduino 2.0 Upload Button\" class=\"wp-image-103678\"\/><\/figure><\/div>\n\n\n<p>You should get a success message.<\/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=\"595\" height=\"249\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/06\/success-uploading-code-Rpi-pico.png?resize=595%2C249&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Done uploading Arduino IDE Raspberry Pi Pico\" class=\"wp-image-132414\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/06\/success-uploading-code-Rpi-pico.png?w=595&amp;quality=100&amp;strip=all&amp;ssl=1 595w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/06\/success-uploading-code-Rpi-pico.png?resize=300%2C126&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 595px) 100vw, 595px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"demonstration\">Demonstration<\/h2>\n\n\n\n<p>Open the Serial Monitor at a baud rate of 115200. You should get new temperature readings every second.<\/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=\"601\" height=\"397\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/07\/ds18b20-raspberry-pi-pico-arduino-ide-demonstration.png?resize=601%2C397&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Raspberry Pi Pico Arduino IDE - Get Temperature from DS18B20 Temperature Sensor\" class=\"wp-image-133292\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/07\/ds18b20-raspberry-pi-pico-arduino-ide-demonstration.png?w=601&amp;quality=100&amp;strip=all&amp;ssl=1 601w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/07\/ds18b20-raspberry-pi-pico-arduino-ide-demonstration.png?resize=300%2C198&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 601px) 100vw, 601px\" \/><\/figure><\/div>\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity is-style-wide\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"multiple-ds18b20\">Raspberry Pi Pico with Multiple Temperature Sensors (Arduino IDE)<\/h2>\n\n\n\n<p>The DS18B20 temperature sensor communicates using one-wire protocol and each sensor has a unique 64-bit serial code, so you can read the temperature from multiple sensors using just one single GPIO. <\/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=\"750\" height=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/07\/raspberry-pi-pico-multiple-ds18b20-sensors.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Raspberry Pi Pico with Multiple Temperature Sensors (Arduino IDE)\" class=\"wp-image-133300\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/07\/raspberry-pi-pico-multiple-ds18b20-sensors.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-multiple-ds18b20-sensors.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<h3 class=\"wp-block-heading\" id=\"ds18b20-address\">Getting the DS18B20 Sensor Address<\/h3>\n\n\n\n<p>Each DS18B20 temperature sensor has a unique serial number. First, you need to find that number to label each sensor accordingly. You need to do this, so that later you know from which sensor you\u2019re reading the temperature. Upload the following code:<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">\/*********\n  Rui Santos\n  Complete project details at https:\/\/RandomNerdTutorials.com\/raspberry-pi-pico-ds18b20-arduino\/\n  \n  Example from the library microSD18B20.h: https:\/\/github.com\/GyverLibs\/microDS18B20\/tree\/main\/examples\n  Get the address of DS18B20 sensor (one sensor connected at a time)\n*********\/\n\n#include &lt;microDS18B20.h&gt;\n\n\/\/ We're using GPIO 22, change accordingly\nMicroDS18B20 &lt;22&gt; sensor;  \n\n\/\/ Array to store the sensor address\nuint8_t address[8];       \n\nvoid setup() {\n  Serial.begin(115200);\n}\n\nvoid loop() {\n  if (sensor.readAddress(address)) {\n    Serial.print('{');\n    for (uint8_t i = 0; i &lt; 8; i++) {\n      Serial.print(&quot;0x&quot;);\n      Serial.print(address[i], HEX); \n      if (i &lt; 7) Serial.print(&quot;, &quot;);\n    }\n    Serial.println('}');\n\n  } else Serial.println(&quot;Not connected&quot;);\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\/DS18B20_Get_Sensor_Address.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<p>Wire just one sensor at a time to the Raspberry Pi Pico on GPIO22 to find its address. The address of each sensor will be printed in the Serial Monitor.<\/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=\"601\" height=\"397\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/07\/ds18b20-get-sensor-address-arduino-ide.png?resize=601%2C397&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"DS18B20 Get Sensor Address Arduino IDE Raspberry Pi Pico\" class=\"wp-image-133294\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/07\/ds18b20-get-sensor-address-arduino-ide.png?w=601&amp;quality=100&amp;strip=all&amp;ssl=1 601w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/07\/ds18b20-get-sensor-address-arduino-ide.png?resize=300%2C198&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 601px) 100vw, 601px\" \/><\/figure><\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"Rpi-Pico-multiple-ds18b20-sensors-wiring\">Wiring Multiple Temperature Sensors to the Raspberry Pi Pico<\/h3>\n\n\n\n<p>To read temperature from multiple sensors on the same one-wire bus, you just need to wire all data lines together as shown in the following schematic diagram (as an example we&#8217;re using four sensors, but you can use two, three, or more) just make sure you have a 4.7k Ohm resistor on the data line:<\/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=\"850\" height=\"716\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/07\/raspberry-pi-pico-multiple-ds18b20-wiring_bb.png?resize=850%2C716&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Raspberry Pi Pico Wiring Multiple DS18B20 Sensors\" class=\"wp-image-133319\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/07\/raspberry-pi-pico-multiple-ds18b20-wiring_bb.png?w=850&amp;quality=100&amp;strip=all&amp;ssl=1 850w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/07\/raspberry-pi-pico-multiple-ds18b20-wiring_bb.png?resize=300%2C253&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/07\/raspberry-pi-pico-multiple-ds18b20-wiring_bb.png?resize=768%2C647&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 850px) 100vw, 850px\" \/><\/figure><\/div>\n\n\n<h3 class=\"wp-block-heading\" id=\"multiple-ds18b20-raspberry-pi-pico-arduino-code\">Getting Temperature from Multiple DS18B20 Sensors<\/h3>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/07\/multiple-ds18b20-sensors.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"multiple DS18B20 temperature sensors\" class=\"wp-image-133316\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/07\/multiple-ds18b20-sensors.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/07\/multiple-ds18b20-sensors.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>The following code reads the temperature from multiple DS18B20 temperature sensors. To define each sensor, you need to modify the code with the sensors&#8217; addresses you found in the previous step.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">\/*********\n  Rui Santos\n  Complete project details at https:\/\/RandomNerdTutorials.com\/raspberry-pi-pico-ds18b20-arduino\/\n*********\/\n\n#include &lt;microDS18B20.h&gt;\n\n#define SENS_AMOUNT 4\n\n\/\/ Add the address of each sensor\nconst uint8_t addr[][8] PROGMEM = {\n  {0x28, 0xFF, 0xA0, 0x11, 0x33, 0x17, 0x3, 0x96},\n  {0x28, 0xFF, 0xB4, 0x6, 0x33, 0x17, 0x3, 0x4B},\n  {0x28, 0xAE, 0x26, 0x45, 0x92, 0x1, 0x2, 0x4B},\n  {0x28, 0xFF, 0x11, 0x15, 0x33, 0x17, 0x3, 0x1A}\n};\n\n\/\/ All sensors are connected to GPIO22, adjust accordingly\nMicroDS18B20&lt;22, DS_ADDR_MODE, SENS_AMOUNT, DS_PROGMEM&gt; sensors;\n\nfloat sensor1TempC, sensor2TempC, sensor3TempC, sensor4TempC;\nfloat sensor1TempF, sensor2TempF, sensor3TempF, sensor4TempF;\n\nvoid setup() {\n  Serial.begin(115200);\n  \n  \/\/ set the addresses\n  sensors.setAddress((uint8_t*)addr);\n}\n\nvoid loop() {\n  delay (1000);\n\n  \/\/ Get temperature from each sensor\n  sensor1TempC =  sensors.getTemp(0);\n  sensor2TempC =  sensors.getTemp(1);\n  sensor3TempC =  sensors.getTemp(2);\n  sensor4TempC =  sensors.getTemp(3);\n\n  \/\/Convert temperatures to Fahrenheit\n  sensor1TempF = sensor1TempC *(9.0\/5.0) + 32.0;\n  sensor2TempF = sensor2TempC *(9.0\/5.0) + 32.0;\n  sensor3TempF = sensor3TempC *(9.0\/5.0) + 32.0;\n  sensor4TempF = sensor4TempC *(9.0\/5.0) + 32.0;\n  \n  Serial.print(&quot;Sensor 1 (temp \u00baC): &quot;); \n  Serial.print(sensor1TempC);\n  Serial.print(&quot; Sensor 1 (temp \u00baF): &quot;); \n  Serial.println(sensor1TempF);\n\n  Serial.print(&quot;Sensor 2 (temp \u00baC): &quot;); \n  Serial.print(sensor2TempC);\n  Serial.print(&quot; Sensor 2 (temp \u00baF): &quot;); \n  Serial.println(sensor2TempF);\n\n  Serial.print(&quot;Sensor 3 (temp \u00baC): &quot;); \n  Serial.print(sensor3TempC);\n  Serial.print(&quot; Sensor 3 (temp \u00baF): &quot;); \n  Serial.println(sensor3TempF);\n\n  Serial.print(&quot;Sensor 4 (temp \u00baC): &quot;); \n  Serial.print(sensor4TempC);\n  Serial.print(&quot; Sensor 4 (temp \u00baF): &quot;); \n  Serial.println(sensor4TempF);\n\n  Serial.print(&quot;&quot;);\n  Serial.println(&quot;-----------------------------------&quot;);\n\n  \/\/ request new temperature from all sensors\n  sensors.requestTempAll();\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\/DS18B20_Multiple_Sensors_Addresses.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<p>Let&#8217;s take a quick look at how the code works.<\/p>\n\n\n\n<p>Start by including the <span class=\"rnthl rntliteral\">microDS18B20<\/span> library to be able to read from the DS18B20 temperature sensors.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#include &lt;microDS18B20.h&gt;<\/code><\/pre>\n\n\n\n<p>The code defines a constant variable <span class=\"rnthl rntliteral\">SENS_AMOUNT<\/span> with a value of 4, indicating the number of sensors connected. If you&#8217;re using a different number of sensors, change accordingly.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#define SENS_AMOUNT 4<\/code><\/pre>\n\n\n\n<p>The <span class=\"rnthl rntliteral\">addr<\/span> array holds the address of each sensor. The addresses are specified in hexadecimal format. Modify the code with the addresses you got from the previous step.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>\/\/ Add the address of each sensor\nconst uint8_t addr&#091;]&#091;8] PROGMEM = {\n  {0x28, 0xFF, 0xA0, 0x11, 0x33, 0x17, 0x3, 0x96},\n  {0x28, 0xFF, 0xB4, 0x6, 0x33, 0x17, 0x3, 0x4B},\n  {0x28, 0xAE, 0x26, 0x45, 0x92, 0x1, 0x2, 0x4B},\n  {0x28, 0xFF, 0x11, 0x15, 0x33, 0x17, 0x3, 0x1A}\n};<\/code><\/pre>\n\n\n\n<p>Create an instance of the <span class=\"rnthl rntliteral\">MicroDS18B20<\/span> class called <span class=\"rnthl rntliteral\">sensors<\/span>, specifying the GPIO to which all the sensors are connected, the address mode, the number of sensors, and the memory type for storing the addresses. We&#8217;re connecting the sensors to <strong>GPIO22<\/strong>, if you&#8217;re using a different GPIO, modify the code accordingly.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>\/\/ All sensors are connected to GPIO22, adjust accordingly\nMicroDS18B20&lt;22, DS_ADDR_MODE, SENS_AMOUNT, DS_PROGMEM&gt; sensors;<\/code><\/pre>\n\n\n\n<p>We create variables to hold the temperature from the different sensors both in Celsius and Fahrenheit degrees. Adjust the number of variables accordingly to the number of sensors you&#8217;re using.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>float sensor1TempC, sensor2TempC, sensor3TempC, sensor4TempC;\nfloat sensor1TempF, sensor2TempF, sensor3TempF, sensor4TempF;<\/code><\/pre>\n\n\n\n<p>In the <span class=\"rnthl rntliteral\">setup()<\/span> set the addresses of the sensors using the <span class=\"rnthl rntliteral\">setAddress()<\/span> method on the <span class=\"rnthl rntliteral\">sensors<\/span> object.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>sensors.setAddress((uint8_t*)addr);<\/code><\/pre>\n\n\n\n<p>In the <span class=\"rnthl rntliteral\">loop()<\/span>, we&#8217;ll get the temperature readings from each sensor. The temperature values are obtained from each sensor using the <span class=\"rnthl rntliteral\">getTemp()<\/span> method on the <span class=\"rnthl rntliteral\">sensors<\/span> object. The argument refers to the address of the sensor (<span class=\"rnthl rntliteral\">0<\/span> corresponds to the first address of the array, <span class=\"rnthl rntliteral\">1<\/span> corresponds to the second address, and so on).<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>\/\/ Get temperature from each sensor\nsensor1TempC = sensors.getTemp(0);\nsensor2TempC = sensors.getTemp(1);\nsensor3TempC = sensors.getTemp(2);\nsensor4TempC = sensors.getTemp(3);<\/code><\/pre>\n\n\n\n<p>We also convert the temperature to Fahrenheit.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>sensor1TempF = sensor1TempC *(9.0\/5.0) + 32.0;\nsensor2TempF = sensor2TempC *(9.0\/5.0) + 32.0;\nsensor3TempF = sensor3TempC *(9.0\/5.0) + 32.0;\nsensor4TempF = sensor4TempC *(9.0\/5.0) + 32.0;<\/code><\/pre>\n\n\n\n<p>Finally, all readings are printed on the serial monitor.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>Serial.print(\"Sensor 1 (temp \u00baC): \"); \nSerial.print(sensor1TempC);\nSerial.print(\" Sensor 1 (temp \u00baF): \"); \nSerial.println(sensor1TempF);\n\nSerial.print(\"Sensor 2 (temp \u00baC): \"); \nSerial.print(sensor2TempC);\nSerial.print(\" Sensor 2 (temp \u00baF): \"); \nSerial.println(sensor2TempF);\n\nSerial.print(\"Sensor 3 (temp \u00baC): \"); \nSerial.print(sensor3TempC);\nSerial.print(\" Sensor 3 (temp \u00baF): \"); \nSerial.println(sensor3TempF);\n\nSerial.print(\"Sensor 4 (temp \u00baC): \"); \nSerial.print(sensor4TempC);\nSerial.print(\" Sensor 4 (temp \u00baF): \"); \nSerial.println(sensor4TempF);<\/code><\/pre>\n\n\n\n<p>In the end, don&#8217;t forget to call the <span class=\"rnthl rntliteral\">requestTempAll()<\/span> method to request new temperature readings from all the sensors.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>sensors.requestTempAll();<\/code><\/pre>\n\n\n\n<p>The code repeats this process indefinitely in the <span class=\"rnthl rntliteral\">loop()<\/span> function, continuously reading the temperatures from the sensors and printing the values to the serial monitor every one second.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Demonstration<\/h2>\n\n\n\n<p>After uploading the code to your Raspberry Pi Pico, open the Serial Monitor at a baud rate of 115200. You&#8217;ll get the temperature readings from all sensors 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=\"601\" height=\"413\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/07\/multiple-temperature-sensors-demonstration-arduino-ide-raspberry-pi-pico.png?resize=601%2C413&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Raspberry Pi Pico with Multiple DS18B20 Temperature Sensors - Arduino IDE Serial Monitor\" class=\"wp-image-133291\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/07\/multiple-temperature-sensors-demonstration-arduino-ide-raspberry-pi-pico.png?w=601&amp;quality=100&amp;strip=all&amp;ssl=1 601w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2023\/07\/multiple-temperature-sensors-demonstration-arduino-ide-raspberry-pi-pico.png?resize=300%2C206&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 601px) 100vw, 601px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\">Wrapping Up<\/h2>\n\n\n\n<p>In this tutorial, you learned how to interface the DS18B20 temperature sensor with the Raspberry Pi Pico and how to get temperature readings using Arduino IDE. The DS18B20 is an addressable temperature sensor. This means you can wire multiple sensors on the same GPIO and get temperature readings from all sensors all at once. We also covered that in our tutorial.<\/p>\n\n\n\n<p>If you like the Raspberry Pi Pico, make sure you take a look at some of the other tutorials on our blog:<\/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-pwm-analogwrite-arduino\/\">Raspberry Pi Pico: Fading an LED using PWM (Arduino IDE)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-dht11-dht22-arduino\/\">Raspberry Pi Pico: DHT11\/DHT22 Temperature and Humidity Sensor (Arduino IDE)<\/a><\/li>\n<\/ul>\n\n\n\n<p><a href=\"https:\/\/randomnerdtutorials.com\/projects-raspberry-pi-pico\/\">Check out all our Raspberry Pi Pico Guides \u00bb<\/a><\/p>\n\n\n\n<p>Thanks for reading.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this guide, you&#8217;ll learn how to interface the Raspberry Pi Pico with the DS18B20 temperature sensor and how to get temperature readings using Arduino IDE. The DS18B20 is an &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Raspberry Pi Pico: DS18B20 Temperature Sensor (Arduino IDE) &#8211; Single and Multiple\" class=\"read-more button\" href=\"https:\/\/randomnerdtutorials.com\/raspberry-pi-pico-ds18b20-arduino\/#more-133284\" aria-label=\"Read more about Raspberry Pi Pico: DS18B20 Temperature Sensor (Arduino IDE) &#8211; Single and Multiple\">CONTINUE READING \u00bb<\/a><\/p>\n","protected":false},"author":5,"featured_media":133297,"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-133284","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\/2023\/07\/Raspberry-Pi-Pico-DS18B20-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\/133284","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=133284"}],"version-history":[{"count":21,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/133284\/revisions"}],"predecessor-version":[{"id":145284,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/133284\/revisions\/145284"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/133297"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=133284"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=133284"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=133284"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}