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 both Celsius and Fahrenheit. It communicates using a 1-Wire interface, which allows multiple sensors to be connected to a single data line, simplifying wiring and reducing complexity. Known for its precision and reliability, the DS18B20 is widely used in applications such as weather stations, HVAC systems, industrial temperature monitoring, and home automation projects.

Key features of the DS18B20 include:

  • High accuracy of ±0.5°C over a range of -10°C to +85°C.
  • Wide operating temperature range: -55°C to +125°C.
  • Programmable resolution from 9 to 12 bits.
  • Unique 64-bit serial code for each sensor, enabling multiple sensors on the same bus.

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

Below are the key technical details of the DS18B20 sensor:

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)
Communication Protocol 1-Wire
Resolution Programmable (9 to 12 bits)
Conversion Time 93.75ms (12-bit resolution)
Unique Serial Code 64-bit
Maximum Current Consumption 1.5mA during conversion

Pin Configuration

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

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 pin by drawing power from the data line.

Usage Instructions

Connecting the DS18B20 to a Circuit

To use the DS18B20 sensor, 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. If not using parasite power mode, connect the VDD pin to a 3.3V or 5V power supply.
  4. Place a 4.7kΩ pull-up resistor between the DQ pin and the power supply (VDD). This is required for proper 1-Wire communication.

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.

Arduino Code

#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); // Initialize serial communication
  sensors.begin();    // Start the DS18B20 sensor
}

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

  // Get temperature in Celsius
  float temperatureC = sensors.getTempCByIndex(0);

  // Check if the reading is valid
  if (temperatureC != DEVICE_DISCONNECTED_C) {
    Serial.print("Temperature (C): ");
    Serial.println(temperatureC);
  } else {
    Serial.println("Error: Sensor not found!");
  }

  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 for reliable communication.
  • Cable Length: For long cables, use a lower pull-up resistor value (e.g., 2.2kΩ) to maintain signal integrity.
  • Parasite Power Mode: If using parasite power mode, ensure the data line is powered during temperature conversion.
  • Multiple Sensors: Each DS18B20 has a unique 64-bit serial code, allowing multiple sensors to share the same data line. Use the DallasTemperature library to address individual sensors.

Troubleshooting and FAQs

Common Issues

  1. Sensor Not Detected:

    • Ensure the pull-up resistor is correctly connected between the data line and VDD.
    • Verify that the sensor is properly powered (check connections to GND and VDD).
    • Check the data pin connection to the microcontroller.
  2. Incorrect Temperature Readings:

    • Verify that the sensor is operating within its specified voltage range (3.0V to 5.5V).
    • Ensure the pull-up resistor value is appropriate for the cable length.
    • Check for electrical noise or interference on the data line.
  3. Intermittent Communication Failures:

    • Use shorter cables or shielded wires to reduce noise.
    • Lower the pull-up resistor value if using long cables.

FAQs

Q: Can I connect multiple DS18B20 sensors to the same pin?
A: Yes, the DS18B20 supports multiple sensors on the same data line. Each sensor has a unique 64-bit serial code for identification.

Q: What is parasite power mode?
A: In parasite power mode, the sensor draws power from the data line instead of using the VDD pin. This reduces wiring but requires careful timing during temperature conversion.

Q: How do I increase the resolution of the temperature readings?
A: The DS18B20 supports programmable resolution (9 to 12 bits). Use the DallasTemperature library to configure the desired resolution.

Q: What is the maximum cable length for the DS18B20?
A: The maximum cable length depends on factors like pull-up resistor value and cable quality. Typically, lengths up to 30 meters are achievable with proper wiring and a strong pull-up resistor.

By following this documentation, you can effectively integrate the DS18B20 temperature sensor into your projects and troubleshoot common issues.