DS18B20 Wiring Diagram – A Comprehensive Guide

The DS18B20 is a digital temperature sensor that provides accurate and reliable temperature readings. It is a popular sensor used in various applications, including Internet of Things (IoT) devices, weather monitoring systems, and industrial automation systems. In this article, we will share a comprehensive guide on DS18B20 wiring diagram, including step-by-step instructions, FAQs, and tables. So, let’s get started!

What is DS18B20 Sensor?

The DS18B20 is a digital temperature sensor that uses a 1-wire communication protocol. It can measure temperature from -55°C to +125°C with ±0.5°C accuracy. The sensor is small in size and can be easily integrated with different devices. It has a unique 64-bit address that allows multiple sensors to be connected on the same data line.

The DS18B20 sensor has three pins, namely GND, VDD, and DQ. GND is the ground pin, VDD is the power supply pin, and DQ is the data pin. The sensor requires 3.0V to 5.5V power supply and draws a maximum of 1.5mA current. It has a resolution of 12 bits, which means it can measure temperature with a precision of 0.0625°C.

DS18B20 Wiring Diagram – Step-by-Step Guide

The DS18B20 sensor can be easily wired to different microcontrollers, including Arduino, Raspberry Pi, and ESP32. Here’s a step-by-step guide on how to wire the sensor:

Step 1: Gather the Required Materials

The following are the materials required to wire the DS18B20 sensor:

Material Description
DS18B20 Sensor A digital temperature sensor
4.7kΩ Resistor A pull-up resistor
Breadboard A board to make temporary connections
Jumper Wires Wires to make connections

Step 2: Connect the Sensor to the Breadboard

Connect the DS18B20 sensor to the breadboard as follows:

  • Connect the GND pin of the sensor to the ground rail of the breadboard.
  • Connect the VDD pin of the sensor to the 3.3V or 5V rail of the breadboard.
  • Connect the DQ pin of the sensor to any free row of the breadboard.

Step 3: Connect the Resistor to the Breadboard

Connect the 4.7kΩ resistor to the breadboard as follows:

  • Connect one end of the resistor to the same row where the DQ pin of the sensor is connected.
  • Connect the other end of the resistor to the 3.3V or 5V rail of the breadboard.

Step 4: Connect the Sensor to the Microcontroller

Connect the DS18B20 sensor to the microcontroller as follows:

  • Connect the DQ pin of the sensor to any digital pin of the microcontroller.
  • Connect the GND pin of the sensor to the ground pin of the microcontroller.
  • Connect the VDD pin of the sensor to the 3.3V or 5V pin of the microcontroller.

Step 5: Code to Read Temperature

Upload the following code to the microcontroller to read the temperature:

#include <OneWire.h>#include <DallasTemperature.h>#define ONE_WIRE_BUS 2OneWire oneWire(ONE_WIRE_BUS);DallasTemperature sensors(&oneWire);void setup() {Serial.begin(9600);sensors.begin();}void loop() {sensors.requestTemperatures();float temperature = sensors.getTempCByIndex(0);Serial.print("Temperature: ");Serial.print(temperature);Serial.println("°C");delay(1000);}

Congratulations! You have successfully wired the DS18B20 sensor and read the temperature using the microcontroller.

DS18B20 Wiring Diagram – FAQs

Q1. What is the range of DS18B20 sensor temperature measurement?

The DS18B20 sensor can measure temperature from -55°C to +125°C with ±0.5°C accuracy.

Q2. What is the resolution of DS18B20 sensor temperature measurement?

The DS18B20 sensor has a resolution of 12 bits, which means it can measure temperature with a precision of 0.0625°C.

Q3. How many DS18B20 sensors can be connected to the same data line?

The DS18B20 sensor has a unique 64-bit address that allows multiple sensors to be connected on the same data line. So, theoretically, we can connect up to 64 sensors on the same data line.

Conclusion

The DS18B20 wiring diagram is a crucial aspect of using the sensor in various applications. In this article, we have discussed the step-by-step guide on wiring the sensor to different microcontrollers, including Arduino, Raspberry Pi, and ESP32. We have also answered some of the frequently asked questions related to the sensor. We hope that this guide will help you in using the DS18B20 sensor in your projects.