What is DS18B20 Sensor & How Does It Work?

Welcome, Developers & Engineers! Hey there! Glad to have you here. If you love experimenting with sensors and electronics, you’re in the right place. Today, we’ll explore one of the most popular digital temperature sensors — the DS18B20 Sensor. Learning its working, wiring, and applications will help you build accurate temperature monitoring projects, from weather stations to smart home systems. So, let’s dive in!
What is DS18B20 Sensor?

The DS18B20 is a digital temperature sensor manufactured by Maxim Integrated (formerly Dallas Semiconductor). It provides precise temperature measurements in Celsius and Fahrenheit, with a range from -55°C to +125°C and ±0.5°C accuracy over most of its range. The sensor uses a unique 1-Wire communication protocol, which allows multiple sensors to be connected on a single data line, making it perfect for complex projects.
Working Principles of DS18B20 Sensor
Digital Temperature Sensing
The DS18B20 uses an internal thermistor along with a high-precision ADC and calibration data stored in its onboard memory. It converts temperature changes into a 12-bit digital value, which can be read directly by a microcontroller. Unlike analog sensors, you get accurate readings without needing extra calibration or analog-to-digital conversion.
1-Wire Communication Protocol
The sensor communicates over a single data line plus ground. Using the 1-Wire protocol, you can connect multiple DS18B20 sensors on the same bus. Each sensor has a unique 64-bit serial code, so the microcontroller can identify and communicate with each sensor individually. This makes it ideal for projects that need multiple temperature points, such as greenhouse monitoring or server room temperature logging.
Hardware Overview of DS18B20 Sensor

The DS18B20 comes in several packages: waterproof stainless steel probe, TO-92 plastic, or surface-mount. All versions have three pins: VCC, GND, and DATA. The sensor can be powered using normal voltage (3V–5V) or even via parasitic power through the data line for minimal wiring setups.
DS18B20 Pinout

- VCC: Power supply (3V–5V)
- GND: Ground
- DATA: 1-Wire data line
Technical Specifications of DS18B20 Sensor
- Manufacturer: Maxim Integrated
- Temperature Range: −55°C to +125°C
- Accuracy: ±0.5°C from −10°C to +85°C
- Resolution: 9–12 bit programmable
- Supply Voltage: 3V–5.5V
- Current Consumption: 1 mA active, 750 µA during conversion, 1 µA standby
- Interface: 1-Wire digital protocol
- Unique ID: 64-bit serial code per sensor
- Waterproof Option: Yes (probe version)
Connecting DS18B20 Sensor with Arduino
What You Need
- Arduino Uno, Nano, or Mega
- DS18B20 Sensor (TO-92 or waterproof probe)
- 4.7 kΩ resistor
- Jumper Wires
- Breadboard (optional)
Wiring Diagram

- VCC → 5V (or 3.3V)
- GND → GND
- DATA → Digital pin 2 (with 4.7 kΩ pull-up resistor to VCC)
Arduino Code Example
Install the DallasTemperature and OneWire libraries from Arduino Library Manager before uploading.
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
void setup() {
Serial.begin(9600);
sensors.begin();
Serial.println("DS18B20 Sensor is ready!");
}
void loop() {
sensors.requestTemperatures();
float tempC = sensors.getTempCByIndex(0); // first sensor on the bus
Serial.print("Temperature: ");
Serial.print(tempC);
Serial.println(" °C");
delay(2000);
}
Open the Serial Monitor at 9600 baud. You’ll see the temperature readings update every 2 seconds. For multiple sensors, just call getTempCByIndex(n) with the appropriate index.
Applications of DS18B20 Sensor
- Home Automation: Monitor room or water temperature.
- Greenhouse Monitoring: Track multiple points in a greenhouse.
- Weather Stations: Measure ambient temperature accurately.
- Industrial Monitoring: Track machinery or process temperatures.
- Aquarium or Water Tank: Waterproof probe for water temperature monitoring.
- IoT Projects: Multiple DS18B20 sensors on a single 1-Wire bus.
- Educational Projects: Great for learning digital sensors and Arduino programming.
Tips for Accurate Readings
- Keep the sensor away from heat sources or direct sunlight.
- Use short wires to reduce signal interference.
- Ensure proper pull-up resistor (4.7 kΩ) is connected for 1-Wire communication.
- For waterproof probes, submerge only the sensor tip, not the connector.
Wrapping Up
So that’s everything you need to know about the DS18B20 Sensor — from how it works to practical Arduino implementation. With its precise temperature measurement, unique 1-Wire capability, and easy integration, the DS18B20 is perfect for weather stations, smart homes, aquariums, and IoT projects. We hope this guide helps you confidently use the DS18B20 in your projects. If you have any questions, drop them in the comments below — we’re here to help!




