The DS18B20 Digital Temperature Sensor by DF Robot (Manufacturer Part ID: Temperature Sensor) is a versatile and highly accurate temperature sensor. It provides temperature readings in both Celsius and Fahrenheit 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 such as weather monitoring, home automation, industrial systems, and scientific experiments.
Below are the key technical details of the DS18B20 Digital Temperature Sensor:
Parameter | Value |
---|---|
Operating Voltage | 3.0V to 5.5V |
Temperature Range | -55°C to +125°C (-67°F to +257°F) |
Accuracy | ±0.5°C (from -10°C to +85°C) |
Resolution | 9 to 12 bits (user-selectable) |
Interface | 1-Wire |
Maximum Current Draw | 1.5mA during conversion |
Communication Protocol | 1-Wire Digital |
Sensor Type | Digital |
The DS18B20 sensor typically comes in a 3-pin TO-92 package. Below is the pinout:
Pin | Name | Description |
---|---|---|
1 | GND | Ground pin. Connect to the ground of the power supply. |
2 | DQ | Data pin. Used for communication via the 1-Wire protocol. Requires a pull-up resistor. |
3 | VDD | Power supply pin. Connect to a voltage source between 3.0V and 5.5V. |
Note: A 4.7kΩ pull-up resistor is required on the data line (DQ) for proper operation.
Wiring the Sensor:
Using with 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 the oneWire reference to DallasTemperature library
DallasTemperature sensors(&oneWire);
void setup() {
Serial.begin(9600); // Start serial communication at 9600 baud
sensors.begin(); // Initialize the DS18B20 sensor
}
void loop() {
sensors.requestTemperatures(); // Request temperature readings from the sensor
// Print the temperature in Celsius
Serial.print("Temperature (C): ");
Serial.println(sensors.getTempCByIndex(0));
// Print the temperature in Fahrenheit
Serial.print("Temperature (F): ");
Serial.println(sensors.getTempFByIndex(0));
delay(1000); // Wait 1 second before taking the next reading
}
getAddress()
function in the DallasTemperature library to identify each sensor.No Temperature Readings:
Inaccurate Temperature Readings:
Sensor Not Detected:
Multiple Sensors Not Working:
Q1: Can I use the DS18B20 with a 3.3V power supply?
A1: Yes, the DS18B20 operates within a voltage range of 3.0V to 5.5V.
Q2: How many sensors can I connect to a single data line?
A2: Theoretically, you can connect up to 100 sensors on a single data line, but this depends on the pull-up resistor value and cable length.
Q3: Can the DS18B20 measure negative temperatures?
A3: Yes, the DS18B20 can measure temperatures as low as -55°C.
Q4: What is the default resolution of the DS18B20?
A4: The default resolution is 12 bits, but it can be configured to 9, 10, or 11 bits for faster readings.
By following this documentation, you can effectively integrate the DS18B20 Digital Temperature Sensor into your projects and troubleshoot any issues that arise.