✨ Use RCAPP and get 5% off 👇
Skip to content
Free Delivery on Orders Above Rs 999/- Pan-India
Cash on Delivery Available for Orders above Rs.500/- and Upto Rs 3000/-
SAVE more when you BUY more. Upto 30% Off on BULK PURCHASE
GST Invoices for Your Business
Dedicated Technical Support Team
Safely Delivering Genuine Products PAN INDIA

DS18B20 Temperature Sensor with ESP32 – Complete Tutorial

DS18B20 Temperature Sensor with ESP32 – Complete Tutorial
D
Written By Daniel D'Souza
📅 Updated on 17 Jun 2026
Summarize with AI
✅ Prompt copied

Summary

Discover the future of temperature monitoring with the DS18B20 sensor and ESP32 duo! In our latest blog, we delve into the dynamic world of IoT-enabled temperature tracking. Uncover the myriad benefits and features of this powerful sensor combination, and unlock the true potential of ThingSpeak. From real-time data visualization to seamless integration, learn how ThingSpeak empowers you to harness the full spectrum of temperature insights. Dive in today and revolutionize your approach to monitoring with a single click!

Introduction

In this blog, we will learn how to interface the DS18b20 sensor with an ESP32 and also learn about Thingspeak. ThingSpeak™ is an IoT analytics platform service that allows you to aggregate, visualize, and analyze live data streams on the cloud. You can send data to ThingSpeak from your devices, create instant visualizations of live data, and send alerts using web services like Twitter® and Twilio®. With MATLAB® analytics inside ThingSpeak, you can write and execute MATLAB code to perform preprocessing, visualizations, and analyses. ThingSpeak enables engineers and scientists to prototype and build IoT systems without setting up servers or developing web software.

Each DS18B20 has a unique 64-bit serial code, which allows multiple DS18B20s to function on the same 1-Wire bus. Thus, it is simple to use one microprocessor to control many DS18B20s distributed over a large area.

 

 

 

Components and Supplies

🏆 Best seller
ESP32 NodeMCU Dev Board (CP2102, 30-Pin) – WiFi & BLE support. -Nodemcu ESP Board -RobocrazeESP32 NodeMCU Dev Board (CP2102, 30-Pin) – WiFi & BLE support. -Nodemcu ESP Board -Robocraze

    ESP32 Node MCU Development Board with Wifi and Bluetooth (CP2102 Driver, 30 PIN)

    ESP32 (CP2102 Driver, 30 Pin) WiFi + Bluetooth NodeMCU-32 Development Board) Looking to supercharge your IoT projects? The ESP32 NodeMCU Development Board with Wi-Fi and Bluetooth (CP2102) 30-Pin is your go-to solution. This NodeMCU ESP32 development board is widely considered the best ESP32 board...
    Rs 383/-
    Rs 383/-
    Rs 597/-
    Save Rs 214/-
    DS18B20 Waterproof Sensor – Digital Temperature for accurate temp readings. -RobocrazeDS18B20 Waterproof Sensor – Digital Temperature for accurate temp readings. -Robocraze

      DS18B20 Waterproof Digital Temperature Sensor Probe

      DS18B20 Waterproof Digital Temperature Sensor Probe This is a pre-wired and waterproofed version. Handy for when you need to measure something far away or in wet conditions. While the sensor is good up to 125°C the cable is jacketed in PVC so we suggest...
      Rs 64/-
      Rs 64/-
      Rs 89/-
      Save Rs 25/-
      💥 Hot deal
      Original Arduino Uno R3 microcontroller board with ATmega328P and USB port - Arduino Uno Board -RobocrazeOriginal Arduino Uno R3 microcontroller board with ATmega328P and USB port - Arduino Uno Board -Robocraze

        Arduino Uno R3 Original

        Arduino UNO R3 Original The Arduino Uno R3 is a microcontroller board based on the ATmega328P chip and is widely recognized as the best original Arduino Uno board for beginners and projects. This board has 14 digital I/O pins (6 support PWM), 6 analog...
        Rs 2,619/-
        Rs 2,619/-
        Rs 2,649/-
        Save Rs 30/-
        Male to Female Jumper Wires (20cm) (20pcs) – Essential jumper wires for projects. Electronic Components - RobocrazeMale to Female Jumper Wires (20cm) (20pcs) – Essential jumper wires for projects. Electronic Components - Robocraze

          Male to Female Jumper Wires (20cm) (20pcs)

          20cm 20pcs Male to Female Jumper Wires These Male to female jumper wires are best for any electronic prototyping and testing project. They allow for easy and convenient interconnection between components without the need for soldering. These wires come in groups or cables with...
          Rs 23/-
          Rs 23/-
          Rs 49/-
          Save Rs 26/-
          GL12 840 Points Solderless Breadboard for Large Prototyping - Electronic Components -RobocrazeGL12 840 Points Solderless Breadboard for Large Prototyping - Electronic Components -Robocraze

            GL12 840 Points Solderless Breadboard

            GL12 MB102 840 Points Solderless Breadboard Introducing the GL12 840 Points Breadboard at Robocraze! This solderless breadboard is an essential tool for any electronics engineer or hobbyist. It allows you to make temporary prototypes for your electronics projects, making it perfect for experimenting with...
            Rs 70/-
            Rs 70/-
            Rs 90/-
            Save Rs 20/-

            Benefits and Features:

             

            • Unique 1-Wire® Interface Requires Only One Port Pin for Communication
            • Reduce Component Count with Integrated Temperature Sensor and EEPROM
            • Measures Temperatures from -55°C to +125°C (-67°F to +257°F)
            • ±0.5°C Accuracy from -10°C to +85°C.
            • Programmable Resolution from 9 Bits to 12 Bits
            • Parasitic Power Mode Requires Only 2 Pins for Operation (DQ and GND)
            • Simplifies Distributed Temperature-Sensing Applications with Multidrop Capability
            • Each Device Has a Unique 64-Bit Serial Code Stored in On-Board ROM
            • Flexible User-Definable Nonvolatile (NV) Alarm Settings with Alarm Search Command Identifies Devices with Temperatures Outside Programmed Limits.

            Key capabilities of ThingSpeak include:

             

            • Configure devices to send data to ThingSpeak using a REST API or MQTT.
            • Aggregate data on-demand from devices and third-party sources.
            • Get instant visualizations of live or historical sensor data.
            • Preprocess and analyze your collected data using integrated MATLAB.
            • Run your IoT analytics automatically based on schedules or events.
            • Act on your data and communicate using third-party services like Twilio or Twitter.

             

            We start off by making a thingspeak account. Head over to https://thingspeak.com and create your account. A verification mail will be sent to your registered mail ID. Once you verify, thingspeak will redirect you to create a MathWorks account as well as thingspeak uses MATLAB for analysis. Once your MathWorks account is also created, you can log in to the thingspeak account and create a channel where the temperature data from the DS18b20 will be logged and can be accessed anytime.

             

            After you log in, you can see a “Create New Channel” option pop up on the screen. You will have to fill out the following data about the channel.

             

            Fill out the Channel Settings page and click on save channel at the bottom of the page to create the channel. You can refer to the below-mentioned points if you have a doubt regarding the details to be filled out.

             

            • Channel Name *: Enter a unique name for the ThingSpeak channel.
            • Description *: Enter a description of the ThingSpeak channel.
            • Field# *: Check the box to enable the field, and enter a field name. Each ThingSpeak channel can have up to 8 fields.
            • Metadata: Enter information about channel data, including JSON, XML, or CSV data.
            • Tags: Enter keywords that identify the channel. Separate tags with commas.
            • Link to External Site: If you have a website that contains information about your ThingSpeak channel, specify the URL.
            • Show Channel Location:
            • Latitude: Specify the latitude position in decimal degrees. For example, the latitude of the city of London is 51.5072.
            • Longitude: Specify the longitude position in decimal degrees. For example, the longitude of the city of London is -0.1275.
            • Elevation: Specify the elevation position meters. For example, the elevation of the city of London is 35.052.
            • Video URL: If you have a YouTube or Vimeo video that displays your channel information, specify the full path of the video URL.
            • Link to GitHub: If you store your ThingSpeak code on GitHub, specify the GitHub repository URL.

             

            Mandatory fields to fill:

             

            Once the channel is created, click on the API Keys tab and make a note of the “Channel ID” and “Write API Key”. An interesting feature of thingspeak is that the data saved on the Cloud can be accessed by Android and IOS applications. One such application is called PocketIOT. Install this app from the play store and with the help of the channel details such as Channel ID and Read API Key, you can monitor the stored data on your phone anytime.

            You can download the android application from the following link: https://play.google.com/store/apps/details?id=com.buzsikdev.pocketiot&hl=en

            The hardware connections for the DS18b20 sensor are pretty straightforward. There are 3 wires coming out of the sensor, Vcc, GND, and Data. The sensor works best in the following configuration:

            • Vcc 3.3V(in this case powered through an ESP32)
            • GND ( common ground provided to both ESP32 and Arduino)
            • Data line connected to a 5V source through a 10k resistor(in this case powered through the Arduino)
            • Through the Arduino IDE upload the following code to the ESP32. This code will read the temperature value from the sensor continuously and publish this value to thingspeak at an interval of 2 seconds.

             

            You can download the thingspeak library from the following link: https://github.com/mathworks/thingspeak-arduino

            The code used in this example has been uploaded to our GitHub account: https://github.com/Robocraze/DS18B20

             

            Conclusion

            As we conclude this exciting journey into the realm of temperature sensing and IoT innovation, it's clear that the DS18B20 sensor paired with the ESP32 opens a world of possibilities. From accurate temperature readings to seamless connectivity, this dynamic duo offers unparalleled benefits. But that's not all – with ThingSpeak's key capabilities, you can effortlessly transform raw data into meaningful insights, all in real-time. Imagine the potential for industries ranging from agriculture to healthcare. Ready to take the plunge into smarter, data-driven decision-making? Embrace the future with DS18B20, ESP32, and ThingSpeak today! Your next level of temperature monitoring awaits – don't miss out!

             

            Excerpt

            Learn how to use the DS18B20 waterproof temperature sensor with ESP32. Understand working, wiring, 1-Wire protocol, and practical use cases.
            Prev Post
            Next Post

            Leave a comment

            Please note, comments need to be approved before they are published.

            Thanks for subscribing!

            This email has been registered!

            Shop the look

            Choose Options

            Edit Option
            Back In Stock Notification
            Compare
            Product SKU Description Collection Availability Product Type Other Details

            Choose Options

            this is just a warning
            Login
            Shopping Cart
            0 items
            FREE SHIPPING!
            ₹100 OFF
            ₹200 OFF
            ₹999
            ₹2500
            ₹4900
            WhatsApp Chat Chat