DS18B20 Temperature Sensor

DS18B20 Digital Temperature Sensor
Precision 1-Wire Interface Temperature Measurement for Arduino and Microcontrollers
Introduction
The DS18B20 is a digital temperature sensor with ±0.5°C accuracy over the range of -10°C to +85°C. It uses the 1-Wire communication protocol, allowing multiple sensors to be connected on a single data line.
Key Features
High Accuracy
±0.5°C from -10°C to +85°C
Simple Wiring
1-Wire interface (single data line)
Multi-Drop
Multiple sensors on one bus
Parasitic Power
Can operate without external power
Technical Specifications
Temperature Range | -55°C to +125°C |
---|---|
Accuracy | ±0.5°C (-10°C to +85°C) |
Resolution | User-selectable 9-12 bits |
Supply Voltage | 3.0V to 5.5V |
Current Draw | 1mA (active), 750nA (standby) |
Conversion Time | 750ms max (12-bit resolution) |
Interface | 1-Wire |
Package Options | TO-92, SOIC, µSOP |
Pin Configuration
Pin | Description | Connection |
---|---|---|
1 (GND) | Ground | GND |
2 (DQ) | Data I/O (1-Wire) | Digital Pin (with 4.7KΩ pull-up) |
3 (VDD) | Power Supply (optional) | 3.3V-5V (for powered mode) |
Note: The 4.7KΩ pull-up resistor between DQ and VDD is required for proper operation
Wiring Diagrams
Library Setup
- Install the OneWire and DallasTemperature libraries
- Include the required libraries:
#include <OneWire.h> #include <DallasTemperature.h>
- Initialize the sensor:
#define ONE_WIRE_BUS 2 // Data wire connected to digital pin 2 OneWire oneWire(ONE_WIRE_BUS); DallasTemperature sensors(&oneWire); void setup() { Serial.begin(9600); sensors.begin(); }
Basic Temperature Reading
void loop() { sensors.requestTemperatures(); // Send command to all sensors float tempC = sensors.getTempCByIndex(0); // First sensor Serial.print("Temperature: "); Serial.print(tempC); Serial.println("°C"); delay(1000); }
Advanced Features
Multiple Sensors
void loop() { sensors.requestTemperatures(); // Send command to all sensors float tempC = sensors.getTempCByIndex(0); // First sensor Serial.print("Temperature: "); Serial.print(tempC); Serial.println("°C"); delay(1000); }
Resolution Control
void setHighResolution() { sensors.setResolution(12); // 9-12 bits (0.0625°C resolution) Serial.print("Resolution: "); Serial.println(sensors.getResolution()); }
Fahrenheit Conversion
float getTempF() { float tempC = sensors.getTempCByIndex(0); return DallasTemperature::toFahrenheit(tempC); }
Troubleshooting
Sensor Not Detected
- Verify 4.7KΩ pull-up resistor is installed
- Check wiring connections (GND must be connected)
- Try different digital pin
Incorrect Readings (-127°C)
- Check sensor is properly wired
- Ensure adequate power supply
- Try shorter wires (especially in parasitic mode)
Unstable Values
- Add 0.1μF capacitor between VDD and GND
- Use proper pull-up resistor (4.7KΩ recommended)
- Implement software filtering
Related Posts
IC 74173 – 4-Bit D-Type Register with 3-State Outputs
IC 74173 - 4-Bit D-Type Register with 3-State Outputs
TTL Quad D Flip-Flop with Asynchronous Clear and Output Enable
...
DIY Metal Detector Kit
DIY Metal Detector Kit
DC 3V-5V Non-Contact Sensor Module with 60mm Detection Range
Introduction
The DIY Metal Detec...
CNC V3 Shield with 4 A4988 Drivers
CNC V3 Shield with 4 A4988 Drivers
Complete Arduino-compatible CNC controller for 3D printers and milling machines
...
CN3791 12V MPPT Solar Charger Module
CN3791 12V MPPT Solar Charger Module
Maximum Power Point Tracking Solar Charge Controller for Lead-Acid/Lithium Batteries
...
CJMCU-TRRS 3.5mm Jack AV Stereo Module
CJMCU-TRRS 3.5mm Jack AV Stereo Module
Compact breakout board for audio/video signal interfacing with TRRS connectors
...
TTP223 Capacitive Touch Sensor Module (Red)
TTP223 Capacitive Touch Sensor Module (Red)
Single-Key Touch Detection with Digital Output for Arduino and DIY Projects
...
Capacitive Soil Moisture Sensor
Capacitive Soil Moisture Sensor
Corrosion-Resistant Humidity Detection for Plants and Agricultural Applications
Intro...
VHM-314 Bluetooth Audio Receiver Board Module
VHM-314 Bluetooth Audio Receiver Board Module
High-fidelity stereo audio receiver with Bluetooth 5.0 and 3.5mm audio output
...
BD243 DIY Mini Tesla Coil Prototyping Kit
BD243 DIY Mini Tesla Coil Prototyping Kit
High-Voltage Wireless Power Demonstration - Build Your Own Spark Gap Tesla Coil
...
BF120-3AA Precision Strain Gauges (120Ω)
BF120-3AA Precision Strain Gauges (120Ω)
High-precision foil strain gauges for load cell applications with 120Ω resistance
...
Recent Comments