Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Component Documentation

How to Use DS18B20 Digital Temperature Sensor: Examples, Pinouts, and Specs

Image of DS18B20 Digital Temperature Sensor
Cirkit Designer LogoDesign with DS18B20 Digital Temperature Sensor in Cirkit Designer

Introduction

The DS18B20 Digital Temperature Sensor, manufactured by DF Robot (Part ID: Temperature Sensor), is a versatile and accurate temperature sensor designed for a wide range of applications. It provides temperature readings in both Celsius and Fahrenheit with a high degree of precision. The sensor communicates using a 1-Wire interface, enabling multiple sensors to be connected to a single data line, making it ideal for scalable and space-efficient designs.

Explore Projects Built with DS18B20 Digital Temperature Sensor

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Arduino UNO-Based Multi-Sensor Environmental Monitoring System
Image of diagrama tesis: A project utilizing DS18B20 Digital Temperature Sensor in a practical application
This circuit involves an Arduino UNO microcontroller interfacing with a DS18B20 temperature sensor. The sensor is powered by the Arduino's 5V and GND pins, and its data pin is connected to a digital I/O pin on the Arduino, with a pull-up resistor in place. The setup is designed to read temperature data from the sensor.
Cirkit Designer LogoOpen Project in Cirkit Designer
Arduino UNO Based Temperature Monitoring System with DS18B20 Sensor
Image of DS18b20 sim test: A project utilizing DS18B20 Digital Temperature Sensor in a practical application
This circuit is designed to measure temperature using a DS18B20 sensor interfaced with an Arduino UNO. The Arduino reads temperature data from the sensor via a 1-Wire bus with a pull-up resistor and outputs the readings to the serial console.
Cirkit Designer LogoOpen Project in Cirkit Designer
Arduino UNO with Multiple DS18B20 Sensors for Temperature Monitoring
Image of Interfacing Multiple DS18B20 Digital Temperature Sensors With Arduino UNO: A project utilizing DS18B20 Digital Temperature Sensor in a practical application
This circuit is designed to monitor temperatures using multiple DS18B20 1-Wire temperature sensors connected to an Arduino UNO microcontroller. The sensors are powered by the Arduino's 5V output and share a common data line (DQ) connected to digital pin 2 through a 4.7kΩ pull-up resistor, allowing for simultaneous temperature readings. The Arduino runs a sketch that reads temperatures from each sensor and outputs the readings to the serial monitor in both Celsius and Fahrenheit.
Cirkit Designer LogoOpen Project in Cirkit Designer
ESP8266 NodeMCU with DS18B20 Temperature Sensor Monitoring
Image of SUHU: A project utilizing DS18B20 Digital Temperature Sensor in a practical application
This circuit features an ESP8266 NodeMCU microcontroller connected to a DS18B20 temperature sensor. The sensor's data line (DQ) is connected to the D2 pin of the NodeMCU through a 4.7k ohm pull-up resistor, which is a common configuration for one-wire temperature sensors. The sensor is powered by the 3.3V supply from the NodeMCU, and both the sensor and the NodeMCU share a common ground.
Cirkit Designer LogoOpen Project in Cirkit Designer

Explore Projects Built with DS18B20 Digital Temperature Sensor

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of diagrama tesis: A project utilizing DS18B20 Digital Temperature Sensor in a practical application
Arduino UNO-Based Multi-Sensor Environmental Monitoring System
This circuit involves an Arduino UNO microcontroller interfacing with a DS18B20 temperature sensor. The sensor is powered by the Arduino's 5V and GND pins, and its data pin is connected to a digital I/O pin on the Arduino, with a pull-up resistor in place. The setup is designed to read temperature data from the sensor.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of DS18b20 sim test: A project utilizing DS18B20 Digital Temperature Sensor in a practical application
Arduino UNO Based Temperature Monitoring System with DS18B20 Sensor
This circuit is designed to measure temperature using a DS18B20 sensor interfaced with an Arduino UNO. The Arduino reads temperature data from the sensor via a 1-Wire bus with a pull-up resistor and outputs the readings to the serial console.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of Interfacing Multiple DS18B20 Digital Temperature Sensors With Arduino UNO: A project utilizing DS18B20 Digital Temperature Sensor in a practical application
Arduino UNO with Multiple DS18B20 Sensors for Temperature Monitoring
This circuit is designed to monitor temperatures using multiple DS18B20 1-Wire temperature sensors connected to an Arduino UNO microcontroller. The sensors are powered by the Arduino's 5V output and share a common data line (DQ) connected to digital pin 2 through a 4.7kΩ pull-up resistor, allowing for simultaneous temperature readings. The Arduino runs a sketch that reads temperatures from each sensor and outputs the readings to the serial monitor in both Celsius and Fahrenheit.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of SUHU: A project utilizing DS18B20 Digital Temperature Sensor in a practical application
ESP8266 NodeMCU with DS18B20 Temperature Sensor Monitoring
This circuit features an ESP8266 NodeMCU microcontroller connected to a DS18B20 temperature sensor. The sensor's data line (DQ) is connected to the D2 pin of the NodeMCU through a 4.7k ohm pull-up resistor, which is a common configuration for one-wire temperature sensors. The sensor is powered by the 3.3V supply from the NodeMCU, and both the sensor and the NodeMCU share a common ground.
Cirkit Designer LogoOpen Project in Cirkit Designer

Common Applications and Use Cases

  • Environmental monitoring systems
  • HVAC (Heating, Ventilation, and Air Conditioning) systems
  • Industrial temperature control
  • Weather stations
  • Home automation projects
  • Data logging and IoT applications

Technical Specifications

The DS18B20 sensor is designed to operate efficiently in various environments. Below are its key technical details:

Parameter Value
Operating Voltage 3.0V to 5.5V
Temperature Range -55°C to +125°C (-67°F to +257°F)
Accuracy ±0.5°C (from -10°C to +85°C)
Resolution Programmable: 9 to 12 bits
Communication Protocol 1-Wire
Maximum Current Draw 1.5mA during conversion
Sensor Type Digital

Pin Configuration and Descriptions

The DS18B20 sensor typically comes in a 3-pin TO-92 package. Below is the pinout:

Pin Name Description
1 GND Ground pin. Connect to the ground of the power supply.
2 DQ Data pin. Used for 1-Wire communication. Requires a pull-up resistor (4.7kΩ).
3 VDD Power supply pin. Connect to 3.0V to 5.5V.

Usage Instructions

The DS18B20 is easy to integrate into circuits, thanks to its 1-Wire communication protocol. Below are the steps to use the sensor effectively:

Connecting the DS18B20

  1. Power Supply: Connect the VDD pin to a 3.3V or 5V power source and the GND pin to ground.
  2. Data Line: Connect the DQ pin to a digital I/O pin of your microcontroller. Use a 4.7kΩ pull-up resistor between the DQ pin and the VDD pin to ensure proper communication.
  3. Multiple Sensors: If using multiple DS18B20 sensors, connect all DQ pins to the same data line. Each sensor has a unique 64-bit serial code for identification.

Example: Using DS18B20 with Arduino UNO

Below is an example of how to use the DS18B20 sensor with an Arduino UNO. This code reads the temperature and displays it on the Serial Monitor.

Required Libraries

  • OneWire: For 1-Wire communication.
  • DallasTemperature: For handling DS18B20 sensors.

Install these libraries via the Arduino Library Manager.

Arduino Code

#include <OneWire.h>
#include <DallasTemperature.h>

// Data wire is connected to pin 2 on the Arduino
#define ONE_WIRE_BUS 2

// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);

// Pass the oneWire reference to DallasTemperature library
DallasTemperature sensors(&oneWire);

void setup() {
  Serial.begin(9600); // Start the serial communication
  sensors.begin();    // Start the DS18B20 sensor
  Serial.println("DS18B20 Temperature Sensor Initialized");
}

void loop() {
  sensors.requestTemperatures(); // Request temperature readings from the sensor

  // Get temperature in Celsius
  float tempC = sensors.getTempCByIndex(0);
  // Get temperature in Fahrenheit
  float tempF = sensors.getTempFByIndex(0);

  // Print the temperature readings to the Serial Monitor
  Serial.print("Temperature: ");
  Serial.print(tempC);
  Serial.print(" °C / ");
  Serial.print(tempF);
  Serial.println(" °F");

  delay(1000); // Wait 1 second before the next reading
}

Important Considerations and Best Practices

  • Pull-Up Resistor: Always use a 4.7kΩ pull-up resistor on the DQ line to ensure reliable communication.
  • Cable Length: For long cable runs, use twisted-pair or shielded cables to reduce noise.
  • Powering Multiple Sensors: If using multiple sensors, ensure the power supply can handle the total current draw.
  • Parasitic Power Mode: The DS18B20 can operate in parasitic power mode (using only two wires), but this requires careful design to avoid communication issues.

Troubleshooting and FAQs

Common Issues and Solutions

  1. No Temperature Reading

    • Cause: Missing or incorrect pull-up resistor on the DQ line.
    • Solution: Ensure a 4.7kΩ pull-up resistor is connected between the DQ pin and VDD.
  2. Incorrect Temperature Values

    • Cause: Noise or interference on the data line.
    • Solution: Use shorter cables or shielded wires. Verify proper grounding.
  3. Multiple Sensors Not Detected

    • Cause: Sensors not uniquely addressed.
    • Solution: Use the getAddress() function from the DallasTemperature library to identify each sensor's unique address.
  4. Sensor Overheating

    • Cause: Excessive current draw or incorrect wiring.
    • Solution: Verify the wiring and ensure the power supply voltage is within the specified range.

FAQs

Q: Can the DS18B20 measure negative temperatures?
A: Yes, the DS18B20 can measure temperatures as low as -55°C (-67°F).

Q: How many sensors can be connected to a single data line?
A: Theoretically, up to 100 sensors can be connected to a single data line, but this depends on the power supply and cable length.

Q: Can I use the DS18B20 in outdoor environments?
A: Yes, but it is recommended to use a waterproof version of the sensor for outdoor applications.

Q: What is the default resolution of the DS18B20?
A: The default resolution is 12 bits, providing a temperature resolution of 0.0625°C.

By following this documentation, you can effectively integrate the DS18B20 Digital Temperature Sensor into your projects and troubleshoot common issues with ease.