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

How to Use DS18B20: Examples, Pinouts, and Specs

Image of DS18B20
Cirkit Designer LogoDesign with DS18B20 in Cirkit Designer

Introduction

The DS18B20 is a digital temperature sensor that communicates over a 1-Wire interface, requiring only one data line (and ground) for communication. It provides accurate temperature readings in the range of -55°C to +125°C with a user-selectable resolution of 9 to 12 bits. The sensor is widely used in applications such as weather stations, home automation systems, industrial temperature monitoring, and HVAC systems due to its simplicity, reliability, and precision.

Key features of the DS18B20 include:

  • Wide temperature range: -55°C to +125°C
  • High accuracy: ±0.5°C in the range of -10°C to +85°C
  • 1-Wire interface for easy communication
  • Ability to connect multiple sensors on the same data line
  • Programmable resolution (9 to 12 bits)

Explore Projects Built with DS18B20

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 Temperature Monitoring System with DS18B20 Sensor
Image of DS18b20 sim test: A project utilizing DS18B20 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-Based Multi-Sensor Environmental Monitoring System
Image of diagrama tesis: A project utilizing DS18B20 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
ESP8266 NodeMCU with DS18B20 Temperature Sensor Monitoring
Image of SUHU: A project utilizing DS18B20 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
Arduino UNO with Multiple DS18B20 Sensors for Temperature Monitoring
Image of Interfacing Multiple DS18B20 Digital Temperature Sensors With Arduino UNO: A project utilizing DS18B20 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

Explore Projects Built with DS18B20

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 DS18b20 sim test: A project utilizing DS18B20 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 diagrama tesis: A project utilizing DS18B20 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 SUHU: A project utilizing DS18B20 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
Image of Interfacing Multiple DS18B20 Digital Temperature Sensors With Arduino UNO: A project utilizing DS18B20 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

Technical Specifications

Key Technical Details

Parameter Value
Temperature Range -55°C to +125°C
Accuracy ±0.5°C (-10°C to +85°C)
Resolution 9 to 12 bits (programmable)
Supply Voltage 3.0V to 5.5V
Communication Protocol 1-Wire
Max Current Consumption 1.5 mA during conversion
Standby Current 750 nA (typical)
Conversion Time 93.75 ms (9-bit) to 750 ms (12-bit)
Unique 64-bit ROM Code Yes

Pin Configuration and Descriptions

The DS18B20 is typically available in a 3-pin TO-92 package. The pinout is as follows:

Pin Number Name Description
1 GND Ground
2 DQ Data line for 1-Wire communication (requires a pull-up resistor)
3 VDD Power supply (optional for parasitic power mode)

Note: The DS18B20 can operate in "parasitic power mode," where it draws power directly from the data line (DQ) and does not require a connection to the VDD pin.

Usage Instructions

How to Use the DS18B20 in a Circuit

  1. Wiring the Sensor:

    • Connect the GND pin to the ground of your circuit.
    • Connect the DQ pin to a digital I/O pin of your microcontroller (e.g., Arduino) and add a 4.7 kΩ pull-up resistor between DQ and the power supply (VDD).
    • Connect the VDD pin to a 3.3V or 5V power supply. If using parasitic power mode, leave the VDD pin unconnected.
  2. Programming the Sensor:

    • Use a microcontroller (e.g., Arduino UNO) to communicate with the DS18B20 via the 1-Wire protocol.
    • Install the necessary libraries, such as the "OneWire" and "DallasTemperature" libraries for Arduino.
  3. Reading Temperature:

    • Initialize the sensor in your code.
    • Request temperature readings and process the data.

Arduino Example Code

Below is an example of how to use the DS18B20 with an Arduino UNO:

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

// Pin connected to the DS18B20 data line
#define ONE_WIRE_BUS 2

// Create a OneWire instance to communicate with the sensor
OneWire oneWire(ONE_WIRE_BUS);

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

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

void loop() {
  sensors.requestTemperatures(); // Request temperature readings
  float temperatureC = sensors.getTempCByIndex(0); // Get temperature in Celsius
  if (temperatureC != DEVICE_DISCONNECTED_C) {
    Serial.print("Temperature: ");
    Serial.print(temperatureC);
    Serial.println(" °C");
  } else {
    Serial.println("Error: Sensor not found!");
  }
  delay(1000); // Wait 1 second before the next reading
}

Important Considerations and Best Practices

  • Use a 4.7 kΩ pull-up resistor on the DQ line to ensure proper communication.
  • Avoid long wires to minimize signal degradation, especially in noisy environments.
  • If using multiple DS18B20 sensors on the same data line, ensure each sensor's unique 64-bit ROM code is used to address them individually.
  • For higher accuracy, use a stable power supply and avoid rapid temperature changes.

Troubleshooting and FAQs

Common Issues and Solutions

  1. Sensor Not Detected:

    • Ensure the wiring is correct and the pull-up resistor is properly connected.
    • Verify that the data pin is connected to the correct microcontroller pin.
  2. Incorrect Temperature Readings:

    • Check for loose connections or poor soldering.
    • Ensure the sensor is not exposed to temperatures outside its operating range.
  3. Multiple Sensors on the Same Bus Not Working:

    • Verify that each sensor's unique ROM code is used in the code.
    • Ensure the pull-up resistor is strong enough to handle the total bus capacitance.
  4. Parasitic Power Mode Issues:

    • Ensure the DQ line is held high during temperature conversion.
    • Avoid using parasitic power mode in high-noise environments.

FAQs

Q: Can I use the DS18B20 with a 3.3V microcontroller?
A: Yes, the DS18B20 operates with a supply voltage range of 3.0V to 5.5V, making it compatible with 3.3V systems.

Q: How many DS18B20 sensors can I connect to a single data line?
A: Theoretically, you can connect up to 100 sensors on the same 1-Wire bus, but practical limitations such as wire length and capacitance may reduce this number.

Q: What is the default resolution of the DS18B20?
A: The default resolution is 12 bits, but it can be configured to 9, 10, or 11 bits for faster conversion times.

Q: Can the DS18B20 measure negative temperatures?
A: Yes, the DS18B20 can measure temperatures as low as -55°C. Negative temperatures are represented in two's complement format.

Q: Is the DS18B20 waterproof?
A: The standard DS18B20 is not waterproof, but waterproof versions are available in sealed stainless steel tubes for outdoor or liquid temperature measurements.