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

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

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

Introduction

The DS18B20 is a digital temperature sensor that provides temperature readings in degrees Celsius with an accuracy of ±0.5°C. It communicates with microcontrollers and other digital devices using the 1-Wire protocol, which allows multiple sensors to be connected to a single data wire. This sensor is widely used in a variety of applications, including environmental monitoring, home automation, and industrial control systems.

Explore Projects Built with DS18B20 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 Temperature Monitoring System with DS18B20 Sensor
Image of DS18b20 sim test: A project utilizing DS18B20 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
ESP8266 NodeMCU with DS18B20 Temperature Sensor Monitoring
Image of SUHU: A project utilizing DS18B20 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
Arduino UNO-Based Multi-Sensor Environmental Monitoring System
Image of diagrama tesis: A project utilizing DS18B20 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 with Multiple DS18B20 Sensors for Temperature Monitoring
Image of Interfacing Multiple DS18B20 Digital Temperature Sensors With Arduino UNO: A project utilizing DS18B20 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

Explore Projects Built with DS18B20 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 DS18b20 sim test: A project utilizing DS18B20 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 SUHU: A project utilizing DS18B20 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
Image of diagrama tesis: A project utilizing DS18B20 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 Interfacing Multiple DS18B20 Digital Temperature Sensors With Arduino UNO: A project utilizing DS18B20 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

Technical Specifications

Key Technical Details

  • Supply Voltage: 3.0V to 5.5V
  • Operating Temperature Range: -55°C to +125°C
  • Accuracy: ±0.5°C from -10°C to +85°C
  • Resolution: Selectable from 9 to 12 bits
  • Unique 64-bit Serial Code: Allows for multiple sensors on the same 1-Wire bus
  • Conversion Time: 750ms at 12-bit resolution

Pin Configuration and Descriptions

Pin Number Name Description
1 GND Ground pin, connected to the system ground
2 DQ Data pin, used for 1-Wire communication
3 VDD Power supply pin, 3.0V to 5.5V

Usage Instructions

Connecting the DS18B20 to a Circuit

  1. Connect the GND pin to the ground of the power supply.
  2. Connect the VDD pin to a 3.0V to 5.5V power supply.
  3. Connect the DQ pin to a digital input/output pin on your microcontroller.
  4. Place a 4.7kΩ pull-up resistor between the DQ pin and the VDD pin.

Important Considerations and Best Practices

  • Ensure that the power supply voltage is within the specified range to avoid damaging the sensor.
  • Use the 4.7kΩ pull-up resistor on the DQ line for reliable communication.
  • Avoid running the sensor wires close to high-voltage or high-current lines to minimize interference.
  • For long cable runs, consider using a lower value pull-up resistor and shielded cable.

Example Code for Arduino UNO

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

// Data wire is connected to pin 2 on the Arduino
#define ONE_WIRE_BUS 2

// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature sensor 
DallasTemperature sensors(&oneWire);

void setup(void)
{
  // Start serial communication for debugging
  Serial.begin(9600);
  // Start up the library
  sensors.begin();
}

void loop(void)
{ 
  // Request temperature measurements from the sensor
  sensors.requestTemperatures(); 
  // Fetch and print the temperature in Celsius
  Serial.print("Temperature is: ");
  Serial.print(sensors.getTempCByIndex(0)); 
  Serial.println("°C");
  
  // Wait 1 second before requesting new data
  delay(1000);
}

Troubleshooting and FAQs

Common Issues

  • No Temperature Readings: Ensure the pull-up resistor is correctly placed and the sensor is properly powered.
  • Inaccurate Readings: Check for proper grounding and stable power supply. Ensure the sensor is not exposed to rapid temperature changes.
  • Multiple Sensors Not Working: Verify each sensor has a unique address and that the 1-Wire bus is correctly configured.

Solutions and Tips for Troubleshooting

  • Double-check wiring, especially the pull-up resistor on the DQ line.
  • Use the sensors.getAddress() function to ensure each sensor has a unique address.
  • For issues with multiple sensors, use the sensors.search() function to find all devices on the bus.

FAQs

Q: Can I use the DS18B20 sensor without an external power supply?

A: Yes, the DS18B20 supports "parasite power" mode, where it draws power from the data line. This requires only two wires: the data line and ground.

Q: How many DS18B20 sensors can I connect to a single microcontroller pin?

A: You can connect many sensors to a single pin, limited by the bus capacitance and the quality of your pull-up resistor. In practice, around 10-20 sensors are often manageable.

Q: How do I waterproof the DS18B20 sensor for outdoor use?

A: You can purchase the DS18B20 in a waterproof probe form, or you can waterproof a standard sensor using appropriate sealing techniques and materials like heat shrink tubing and silicone sealant.