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 DFRobot (Part ID: Temperature Sensor), is a versatile and highly accurate temperature sensor. It provides temperature readings in the range of -55°C to +125°C with a resolution of up to 12 bits. The sensor communicates using a 1-Wire interface, enabling multiple sensors to share a single data line. This makes it an excellent choice for applications requiring distributed temperature sensing, such as HVAC systems, weather monitoring, industrial automation, and home automation projects.

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:

  • Environmental monitoring systems
  • Industrial temperature control
  • Smart home devices
  • Data logging and weather stations
  • Medical equipment

Technical Specifications

The DS18B20 is designed for ease of use and reliable performance. 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 9 to 12 bits (programmable)
Interface 1-Wire
Maximum Current Draw 1.5mA during conversion
Communication Protocol 1-Wire digital protocol
Response Time < 750ms (12-bit resolution)

Pin Configuration:

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

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

  1. Wiring the Sensor:

    • Connect the GND pin to the ground of your circuit.
    • Connect the DQ pin to a digital I/O pin on your microcontroller (e.g., Arduino).
    • Connect the VDD pin to a 3.3V or 5V power supply (or leave it unconnected for parasite power mode).
    • Place a 4.7kΩ pull-up resistor between the DQ pin and the power supply (VDD).
  2. Using Multiple Sensors:

    • Each DS18B20 sensor has a unique 64-bit serial code, allowing multiple sensors to be connected to the same data line.
    • Ensure that each sensor is properly addressed in your code.

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 connected to the DS18B20 data line
#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
  sensors.begin();    // Start the DS18B20 sensor
  Serial.println("DS18B20 Temperature Sensor Initialized");
}

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 detected!");
  }
  
  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 proper communication.
  • Power Supply: Ensure the sensor operates within its voltage range (3.0V to 5.5V). For parasite power mode, verify that the microcontroller can provide sufficient power.
  • Cable Length: For long cable runs, use twisted-pair or shielded cables to reduce noise and interference.

Troubleshooting and FAQs

Common Issues and Solutions:

  1. Sensor Not Detected:

    • Verify the wiring connections, especially the pull-up resistor on the data line.
    • Ensure the sensor is powered correctly (check voltage levels).
  2. Incorrect Temperature Readings:

    • Check for loose or faulty connections.
    • Ensure the sensor is not exposed to conditions outside its operating range (-55°C to +125°C).
  3. Multiple Sensors Not Working:

    • Confirm that each sensor has a unique address.
    • Use the sensors.getAddress() function in the DallasTemperature library to retrieve and verify sensor addresses.
  4. Interference on Long Cables:

    • Use shielded cables or twisted-pair wires for long-distance connections.
    • Add decoupling capacitors (e.g., 0.1µF) near the sensor to stabilize the power supply.

FAQs:

Q: Can the DS18B20 operate without a dedicated power supply?
A: Yes, the DS18B20 can operate in parasite power mode, drawing power from the data line. However, this mode may not work reliably in all setups, especially with long cables or multiple sensors.

Q: How many DS18B20 sensors can I connect to a single data line?
A: Theoretically, you can connect up to 100 sensors on a single data line, but practical limits depend on factors like cable length, power supply, and noise.

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 response 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.

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