Arduino DS18B20 digital Temperature Sensor Library, wiring & Programming

(Last Updated On: July 1, 2020)

Arduino DS18B20


Arduino DS18B20- In this Tutorial, you will learn how to use Ds18b20 waterproof one-wire digital temperature sensor with Arduino and display the temperature in Celsius and Fahrenheit on a 16×2 LCD. So far I have covered different temperature sensors like

Dht11, which can monitor temperature and humidity

Bmp180 can monitor temperature, pressure and altitude and a K type thermocouple, which can measure temperatures up to 1000 Centigrade.  I will provide links at the end of this Article.

In today’s tutorial, we will cover

  1. Ds18b20 waterproof digital temperature sensor introduction
  2. Complete circuit diagram
  3. Programming and finally
  4. Testing

Let’s get started!!!!!

Amazon Purchase Links:

Arduino Uno:
DS12b20 waterproof digital temperature sensor: best offer
16×2 LCD:


Please Note: these are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

About the DS18B20 Waterproof Temperature Sensor:

Arduino DS18B20

One-wire temperature sensors like the DS18B20 are devices that can measure temperature with a minimal amount of hardware and wiring.  These sensors use a digital protocol to send accurate temperature readings directly to your development board without the need for an analog to digital converter or other extra hardware. You can get one-wire sensors in different form factors like waterproof and high-temperature probes–these are perfect for sensing temperature in many different projects and applications.  And since these sensors use the one-wire protocol you can even have multiple of them connected to the same pin and read all their temperature values independently.

Arduino DS18B20

The DS18B20 Waterproof Temperature Sensor has three wires

  • The red wire is the VCC wire: the operating voltage is 3 to 5 volts. In my case, I will use 3.3 volts.
  • Yellow Wire is the Data wire: we usually connect a resistor between the data wire and VCC wire, I will explain this in the circuit diagram.
  • The black wire is the Ground wire. This wire is connected with the Nodemcu Esp8266 wifi module ground.

This temperature sensor is capable of measuring the temperature ranging from -55°C to 125°C

Arduino DS18B20 Circuit Diagram:

Arduino DS18B20

This schematic is designed in cadsoft eagle 9.1.0 version. If you want to learn how to make schematics and pcb then watch my tutorial.



Let’s start with the DS18b20 digital temperature sensor. As you can see a 330 ohm resistor is connected between the Vcc and data wires. You can also use a 4.7k resistor. The Vcc is connected with 3.3 volts. While the ground is connected with the Arduino’s ground.

As you can see ground from the Arduino is connected with pin number 1, 5 and pin number 16 of the LCD. 5v from the Arduino is connected with pin number 2 and pin number 15. The middle pin of the variable resistor or potentiometer is connected with pin number 3 of the LCD. while the other two pins are connected with the ground and 5v. Pin’s 4 to 7 of the Arduino are connected with pins D7 to D4 of the LCD.

Pin number 8 of the Arduino is connected with the enable pin of the LCD. Pin number 9 of the Arduino is connected with the RS pin of the LCD, watch my tutorial on 16×2 LCD if you want to learn the basics, like soldering, troubleshooting.


Libraries needed for the DS18B20:

Before you start the programming first off all, download the following libraries.

Arduino DS18B20 Library “onewire”

Download: onewire

Arduino DS18B20 Library “DallasTemperature”

Download: DallasTemperature

Arduino DS18B20 digital Temperature Sensor Programming:

For the Program explanation watch video Tutorial given below. Don’t forget to subscribe my channel. Support my channel by liking and sharing the video.

Watch Video Tutorial:

Recommended For You

About the Author: Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Leave a Reply