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 manufactured by DS18B20. It communicates over a 1-Wire bus, requiring only one data line (and ground) for communication. This sensor provides temperature readings in Celsius with a resolution ranging from 9 to 12 bits, making it highly versatile for applications requiring precise temperature monitoring. Its compact design and ease of integration make it a popular choice for hobbyists and professionals alike.

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

Common Applications and Use Cases

  • Home automation systems (e.g., HVAC control)
  • Environmental monitoring (e.g., weather stations)
  • Industrial temperature sensing
  • Data logging systems
  • IoT (Internet of Things) devices

Technical Specifications

The DS18B20 is designed to operate efficiently in a wide range of environments. Below are its 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 to 12 bits)
Communication Protocol 1-Wire
Max Current Consumption 1.5mA during conversion
Standby Current 750nA (typical)
Conversion Time 93.75ms (12-bit resolution)
Package Types TO-92, SOIC-8, or waterproof probe

Pin Configuration and Descriptions

The DS18B20 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

The DS18B20 is straightforward to use in a circuit, thanks to its 1-Wire communication protocol. Below are the steps and considerations for using the sensor:

Circuit Connection

  1. Basic Wiring:

    • 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).
    • Connect a 4.7kΩ pull-up resistor between the DQ pin and the VDD pin (or the power supply line if using parasite power mode).
    • If not using parasite power mode, connect the VDD pin to a 3.3V or 5V power supply.
  2. Parasite Power Mode:

    • Leave the VDD pin unconnected.
    • Ensure the pull-up resistor is properly connected to the DQ pin.

Arduino UNO Example Code

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

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

// Pin where the DS18B20 data line is connected
#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); // Initialize serial communication at 9600 baud
  sensors.begin();    // Start the DS18B20 sensor
}

void loop() {
  sensors.requestTemperatures(); // Request temperature from the sensor
  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 detected!");
  }
  
  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 proper communication.
  • Cable Length: For long cable runs, use twisted-pair or shielded cables to reduce noise.
  • Power Supply: Ensure a stable power supply, especially when using multiple sensors on the same bus.
  • Resolution vs. Conversion Time: Higher resolutions (e.g., 12-bit) require longer conversion times. Adjust your code accordingly.

Troubleshooting and FAQs

Common Issues and Solutions

  1. Sensor Not Detected:

    • Check the wiring and ensure the pull-up resistor is correctly connected.
    • Verify that the DQ pin is connected to the correct microcontroller pin.
    • Ensure the sensor is powered correctly (VDD or parasite power mode).
  2. Incorrect Temperature Readings:

    • Verify the accuracy of the power supply voltage.
    • Check for noise or interference on the data line.
    • Ensure the sensor is not exposed to temperatures outside its operating range.
  3. Multiple Sensors on the Same Bus:

    • Use the getAddress() function in the DallasTemperature library to identify each sensor's unique address.
    • Ensure all sensors are properly connected with pull-up resistors.

FAQs

Q: Can I use multiple DS18B20 sensors on 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 sensor draws power directly from the data line, eliminating the need for a dedicated VDD connection.

Q: How do I increase the accuracy of temperature readings?
A: Use the highest resolution (12-bit) setting and ensure the sensor is properly calibrated and powered.

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

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