

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.








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. |
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
}
No Temperature Reading:
Incorrect Temperature Values:
Multiple Sensors Not Detected:
sensors.getAddress() function in the DallasTemperature library to identify each sensor.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.