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 DF Robot (Part ID: Temperature Sensor), is a versatile and accurate temperature sensor designed for a wide range of applications. It provides temperature readings in both Celsius and Fahrenheit with a high degree of precision. The sensor utilizes a 1-Wire communication protocol, allowing for easy integration with microcontrollers and minimal wiring requirements. Its compact design and robust performance make it ideal for use in weather monitoring systems, HVAC controls, 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

Technical Specifications

  • Manufacturer: DF Robot
  • Part ID: Temperature Sensor
  • Temperature Range: -55°C to +125°C (-67°F to +257°F)
  • Accuracy: ±0.5°C (from -10°C to +85°C)
  • Resolution: Programmable from 9 to 12 bits
  • Operating Voltage: 3.0V to 5.5V
  • Interface: 1-Wire protocol
  • Power Consumption: Low-power operation with a standby mode
  • Package Type: TO-92 or waterproof probe (varies by model)

Pin Configuration and Descriptions

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

Pin Name Description
1 GND Ground pin. Connect to the ground of the circuit.
2 DQ Data pin. Used for 1-Wire communication. Requires a pull-up resistor (4.7kΩ).
3 VDD Power supply pin. Connect to 3.0V to 5.5V.

Usage Instructions

Connecting the DS18B20 to a Circuit

  1. Power Supply: Connect the VDD pin to a 3.3V or 5V power source and the GND pin to the ground.
  2. Data Line: Connect the DQ pin to a digital I/O pin on your microcontroller. Use a 4.7kΩ pull-up resistor between the DQ pin and the VDD pin to ensure proper communication.
  3. 1-Wire Communication: The DS18B20 uses a single data line for communication, which simplifies wiring but requires precise timing for data exchange.

Important Considerations

  • Pull-Up Resistor: Always use a 4.7kΩ pull-up resistor on the DQ line to ensure reliable communication.
  • Cable Length: For long cable runs, use twisted-pair or shielded cables to minimize noise.
  • Multiple Sensors: The DS18B20 supports multiple sensors on the same 1-Wire bus. Each sensor has a unique 64-bit address for identification.

Example Code for Arduino UNO

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
  float temperatureF = sensors.toFahrenheit(temperatureC); // Convert to Fahrenheit

  // Print temperature readings to Serial Monitor
  Serial.print("Temperature: ");
  Serial.print(temperatureC);
  Serial.print(" °C / ");
  Serial.print(temperatureF);
  Serial.println(" °F");

  delay(1000); // Wait 1 second before the next reading
}

Best Practices

  • Avoid placing the sensor near heat sources or in direct sunlight to ensure accurate readings.
  • For waterproof models, ensure the probe is fully submerged in the medium being measured.
  • Use proper decoupling capacitors near the power supply pin for stable operation in noisy environments.

Troubleshooting and FAQs

Common Issues

  1. No Temperature Reading:

    • Ensure the pull-up resistor (4.7kΩ) is correctly connected between the DQ pin and VDD.
    • Verify that the sensor is properly powered (3.0V to 5.5V).
    • Check the wiring for loose or incorrect connections.
  2. Incorrect Temperature Values:

    • Ensure the sensor is not exposed to extreme environmental conditions beyond its operating range.
    • Verify that the resolution settings in the code match the desired precision (9 to 12 bits).
  3. Multiple Sensors Not Detected:

    • Ensure each sensor has a unique 64-bit address.
    • Use the sensors.getAddress() function in the DallasTemperature library to identify each sensor.

FAQs

Q: Can I use the DS18B20 with a 3.3V microcontroller?
A: Yes, the DS18B20 operates within a 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 1-Wire bus?
A: Theoretically, you can connect up to 100 sensors on a single 1-Wire bus, but practical limits depend on cable length and power supply.

Q: What is the default resolution of the DS18B20?
A: The default resolution is 12 bits, which provides a temperature precision of 0.0625°C.

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

By following this documentation, you can effectively integrate the DS18B20 Digital Temperature Sensor into your projects and troubleshoot common issues with ease.