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

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

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

Introduction

The DS18B20 is a digital temperature sensor that provides accurate temperature readings in the range of -55°C to +125°C. It communicates using a 1-Wire interface, which allows multiple sensors to be connected to a single data line. This feature makes it highly versatile and suitable for a wide range of applications, including:

  • HVAC systems
  • Weather monitoring stations
  • Industrial temperature control
  • Home automation
  • Data logging systems

The DS18B20 is known for its simplicity, reliability, and ability to operate over long distances with minimal wiring.

Explore Projects Built with DS18B20 Temperature

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 Temperature 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 DS18B20 Temperature Sensor Monitoring
Image of Measure Temperature With Arduino UNO and DS18B20: A project utilizing DS18B20 Temperature in a practical application
This circuit is designed to measure temperature using a DS18B20 temperature sensor interfaced with an Arduino UNO microcontroller. The sensor's data line is connected to digital pin 4 of the Arduino through a 4.7k Ohm pull-up resistor, and the Arduino runs a sketch that reads the temperature in Celsius and Fahrenheit, then outputs the readings to the serial monitor. The purpose of the circuit is to provide a digital temperature reading for monitoring or control applications.
Cirkit Designer LogoOpen Project in Cirkit Designer
Arduino UNO-Based Multi-Sensor Environmental Monitoring System
Image of diagrama tesis: A project utilizing DS18B20 Temperature 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 Temperature Monitoring System with DS18B20 Sensor and Built-in Pull-up Resistor
Image of DS18b20 sim test - no extra libs: A project utilizing DS18B20 Temperature in a practical application
This circuit uses an Arduino UNO to read temperature data from a DS18B20 sensor. The DS18B20 is powered by the Arduino's 5V and GND pins, and its data line is connected to pin D2 with a pull-up resistor on pin D3. The Arduino reads the temperature and prints it to the serial console.
Cirkit Designer LogoOpen Project in Cirkit Designer

Explore Projects Built with DS18B20 Temperature

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 Temperature 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 Measure Temperature With Arduino UNO and DS18B20: A project utilizing DS18B20 Temperature in a practical application
Arduino UNO with DS18B20 Temperature Sensor Monitoring
This circuit is designed to measure temperature using a DS18B20 temperature sensor interfaced with an Arduino UNO microcontroller. The sensor's data line is connected to digital pin 4 of the Arduino through a 4.7k Ohm pull-up resistor, and the Arduino runs a sketch that reads the temperature in Celsius and Fahrenheit, then outputs the readings to the serial monitor. The purpose of the circuit is to provide a digital temperature reading for monitoring or control applications.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of diagrama tesis: A project utilizing DS18B20 Temperature 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 - no extra libs: A project utilizing DS18B20 Temperature in a practical application
Arduino UNO Temperature Monitoring System with DS18B20 Sensor and Built-in Pull-up Resistor
This circuit uses an Arduino UNO to read temperature data from a DS18B20 sensor. The DS18B20 is powered by the Arduino's 5V and GND pins, and its data line is connected to pin D2 with a pull-up resistor on pin D3. The Arduino reads the temperature and prints it to the serial console.
Cirkit Designer LogoOpen Project in Cirkit Designer

Technical Specifications

The DS18B20 has the following key technical details:

Parameter Value
Operating Voltage 3.0V to 5.5V
Temperature Range -55°C to +125°C
Accuracy ±0.5°C (from -10°C to +85°C)
Resolution Programmable: 9-bit to 12-bit
Interface 1-Wire
Maximum Current (Active) 1.5 mA
Standby Current 750 nA
Conversion Time 93.75 ms (12-bit resolution)
Package Types TO-92, SOIC, or waterproof probe

Pin Configuration and Descriptions

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

Pin Name Description
1 GND Ground connection
2 DQ Data line for 1-Wire communication
3 VDD Power supply (optional, can operate in parasite mode)

Note: In parasite power mode, the sensor can operate without a dedicated VDD connection, drawing power from the data line.

Usage Instructions

Connecting the DS18B20 to a Circuit

To use the DS18B20, follow these steps:

  1. Connect the GND pin to the ground of your circuit.
  2. Connect the DQ pin to a digital I/O pin on your microcontroller (e.g., Arduino).
  3. Use a 4.7kΩ pull-up resistor between the DQ pin and the VDD pin to ensure proper communication.
  4. Optionally, connect the VDD pin to a 3.3V or 5V power supply. If using parasite power mode, leave the VDD pin unconnected.

Example Circuit with Arduino UNO

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

  • GND → Arduino GND
  • DQ → Arduino digital pin 2 (with a 4.7kΩ pull-up resistor to 5V)
  • VDD → Arduino 5V (optional, leave unconnected for parasite power mode)

Arduino Code Example

The following code demonstrates how to read temperature data from the DS18B20 using the Arduino IDE. This example uses the OneWire and DallasTemperature libraries, which can be installed via the Arduino Library Manager.

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

// Data wire is connected to Arduino digital pin 2
#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 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
  
  // Check if the reading is valid
  if (temperatureC != DEVICE_DISCONNECTED_C) {
    Serial.print("Temperature: ");
    Serial.print(temperatureC);
    Serial.println(" °C");
  } else {
    Serial.println("Error: Sensor not connected!");
  }
  
  delay(1000); // Wait 1 second before the next reading
}

Important Considerations

  • Pull-up Resistor: Always use a 4.7kΩ pull-up resistor on the data line to ensure reliable communication.
  • Cable Length: The 1-Wire protocol supports long cable lengths, but excessive lengths may require lower pull-up resistor values or additional power considerations.
  • Resolution Settings: The DS18B20 supports 9-bit to 12-bit resolution. Higher resolution increases accuracy but also increases conversion time.

Troubleshooting and FAQs

Common Issues and Solutions

  1. No Temperature Reading:

    • Ensure the sensor is properly connected to the circuit.
    • Verify the pull-up resistor is correctly placed between the DQ pin and VDD.
    • Check the wiring for loose connections or shorts.
  2. Incorrect Temperature Values:

    • Ensure the sensor is not exposed to temperatures outside its operating range.
    • Verify the resolution settings in your code.
  3. Device Not Detected:

    • Confirm the correct digital pin is defined in the code.
    • Check for multiple sensors on the same data line and ensure unique addresses are used.
  4. Intermittent Readings:

    • Reduce cable length or use a lower pull-up resistor value (e.g., 2.2kΩ).
    • Ensure the power supply is stable and within the operating voltage range.

FAQs

Q: Can I connect multiple DS18B20 sensors to the same data line?
A: Yes, the DS18B20 supports multiple devices on the same 1-Wire bus. Each sensor has a unique 64-bit address for identification.

Q: What is parasite power mode?
A: In parasite power mode, the DS18B20 draws power from the data line instead of requiring a dedicated VDD connection. This reduces wiring but may limit performance in some cases.

Q: How do I increase the accuracy of temperature readings?
A: Use the 12-bit resolution setting for maximum accuracy. Ensure the sensor is properly calibrated and not exposed to rapid temperature fluctuations.

Q: Can the DS18B20 be used in waterproof applications?
A: Yes, the DS18B20 is available in a waterproof probe version, making it suitable for liquid temperature measurements.

By following this documentation, you can effectively integrate the DS18B20 into your projects for reliable temperature monitoring.