Zbotic Logo Zbotic Logo
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

  • Shop
  • About Us
  • Contact Us
  • Reseller
  • Blogs
020 69134444
1800 209 0998
[email protected]
Help Desk
Facebook Twitter Instagram Linkedin YouTube
Zbotic Logo Zbotic Logo
0 0

View Wishlist Add all to cart

0 0
0 Shopping Cart
Shopping cart (0)
Subtotal: ₹0.00

View cartCheckout

All departments
  • 3D Print Service
  • 3D Printer
  • Batteries & Chargers
  • Development Boards
  • Drone Parts
  • EBike parts
  • Sensor Modules
  • Electronic Components
  • Electronic Modules
  • IoT and Wireless
  • Mechanical Parts and Workbench Tools
  • Motors & Drivers & Pumps & Actuators
  • DIY and Robot Kits
  • Show more
  • Home
  • Shop
  • Sale
  • 3D Print Service
  • PCB Service
  • B2B
  • Blogs
  • Contact Us
Return to previous page
Home Sensors & Modules

DS18B20 Multiple Sensors: One-Wire Bus with Arduino

DS18B20 Multiple Sensors: One-Wire Bus with Arduino

March 11, 2026 /Posted byJayesh Jain / 0

One of the most impressive features of the DS18B20 temperature sensor is its ability to share a single data wire with dozens of other DS18B20 sensors — all connected in parallel on a single Arduino pin. This 1-Wire bus protocol developed by Dallas Semiconductor (now Maxim Integrated) gives each sensor a unique 64-bit ROM address, allowing your Arduino to individually address and read each one independently. This tutorial covers everything you need to know to build a multi-point temperature monitoring system with multiple DS18B20 sensors on a single 1-Wire bus.

Table of Contents

  1. DS18B20 Overview: Why It Supports Multiple Sensors
  2. Hardware Wiring: Connecting Multiple DS18B20s to Arduino
  3. Library Setup: OneWire and DallasTemperature
  4. Scanning and Identifying Sensor Addresses
  5. Reading Specific Sensors by Address
  6. Simultaneous Temperature Conversion for Speed
  7. Parasitic Power Mode for Long-Distance Sensing
  8. Setting Measurement Resolution (9–12 bit)
  9. FAQ

DS18B20 Overview: Why It Supports Multiple Sensors

The DS18B20 is a digital thermometer with a measurement range of -55°C to +125°C and factory-calibrated accuracy of ±0.5°C across the -10°C to +85°C range — impressive for a sensor that costs less than ₹50. What makes it uniquely suited for multi-sensor systems is its 1-Wire communication protocol.

Every DS18B20 chip is programmed at the factory with a globally unique 64-bit address (also called ROM code or serial number). This 64-bit code consists of an 8-bit family code (0x28 for DS18B20), 48 bits of unique ID, and an 8-bit CRC for error detection. When you connect ten DS18B20 sensors to one Arduino pin, the 1-Wire library can enumerate all of them, get their unique IDs, and then selectively read each one — all over the same single wire.

This is in stark contrast to analog sensors like the LM35 or thermistors, where each sensor needs its own ADC pin. With DS18B20 on a 1-Wire bus, you could theoretically connect 100 sensors to a single digital pin (practical limits are around 10–20 due to bus capacitance). This makes DS18B20 the top choice for:

  • Multi-zone HVAC temperature monitoring
  • Aquarium and greenhouse multi-point sensing
  • Battery pack cell temperature monitoring
  • Industrial pipeline temperature profiling
  • Soil temperature at multiple depths for agricultural IoT
DS18B20 Programmable Resolution

DS18B20 Programmable Resolution Temperature Sensor IC

The classic TO-92 DS18B20 IC — connect multiple on a single Arduino pin for multi-zone temperature monitoring with unique 64-bit addressing.

View on Zbotic

Hardware Wiring: Connecting Multiple DS18B20s to Arduino

The DS18B20 in TO-92 package has three pins. Identify them by looking at the flat face of the package with the text facing you:

  • Left pin (GND): Ground
  • Middle pin (DQ): Data (1-Wire bus) — this is the single shared data line
  • Right pin (VDD): Power supply (3.0V to 5.5V)

Normal (Externally Powered) Mode — Recommended

For most applications, power each DS18B20 from Arduino’s 5V (or 3.3V) supply. Connect all sensors in parallel:

All DS18B20 Pins Connect To
VDD (all sensors) 5V (Arduino)
GND (all sensors) GND (Arduino)
DQ (all sensors) Arduino Pin 2 (shared bus)
Pull-up resistor 4.7kΩ between DQ bus and 5V

The 4.7kΩ pull-up resistor is mandatory. The 1-Wire bus is an open-drain bus — sensors pull it LOW to communicate, and the pull-up resistor pulls it HIGH when idle. Without this resistor, communication fails completely. Use a single pull-up for the entire bus (one resistor for all sensors).

Wiring Topology Tips

Star vs. Linear (daisy-chain) topology: Always use linear (daisy-chain) topology — run the bus wire from sensor to sensor in a line. Avoid star topology where multiple branches radiate out from a central point. Stars create signal reflections that corrupt 1-Wire communication, especially at longer distances. Each sensor shares the same 3-wire bus (VDD, GND, DQ) running serially from sensor to sensor.

Maximum bus length: With 4.7kΩ pull-up and normal wiring, reliable operation up to 100 meters is achievable. For very long cables or many sensors, reduce the pull-up resistor to 2.2kΩ to reduce rise time — but do not go below 1kΩ as it may damage sensors.

DS18B20 Module for D1 Mini

DS18B20 Module for D1 Mini Temperature Measurement Sensor Module

Pre-mounted DS18B20 with pull-up resistor built in — plug directly into your Wemos D1 Mini for 1-Wire temperature sensing without extra components.

View on Zbotic

Library Setup: OneWire and DallasTemperature

You need two libraries. Open Arduino IDE → Sketch → Include Library → Manage Libraries:

  1. Search “OneWire” by Paul Stoffregen — install the latest version
  2. Search “DallasTemperature” by Miles Burton — install the latest version

The OneWire library handles the low-level 1-Wire protocol timing (reset, presence detection, ROM commands, data read/write). The DallasTemperature library sits on top of OneWire and provides a high-level API specifically for DS18B20 and other Dallas temperature sensors — handling conversion commands, scratchpad reads, CRC verification, and unit conversion automatically.

Scanning and Identifying Sensor Addresses

Before you can address individual sensors, you need to discover their 64-bit addresses. Run this sketch to enumerate all sensors on the bus:

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

#define ONE_WIRE_BUS 2  // Arduino pin for the 1-Wire bus

OneWire          oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

void setup() {
  Serial.begin(115200);
  sensors.begin();
  
  int deviceCount = sensors.getDeviceCount();
  Serial.print("Found ");
  Serial.print(deviceCount);
  Serial.println(" DS18B20 sensor(s) on bus:");
  Serial.println();
  
  DeviceAddress addr;
  for (int i = 0; i < deviceCount; i++) {
    if (sensors.getAddress(addr, i)) {
      Serial.print("Sensor ");
      Serial.print(i);
      Serial.print("  Address: ");
      printAddress(addr);
      Serial.println();
    }
  }
}

void printAddress(DeviceAddress addr) {
  for (uint8_t i = 0; i < 8; i++) {
    if (addr[i] < 16) Serial.print("0");  // Leading zero
    Serial.print(addr[i], HEX);
    if (i < 7) Serial.print("-");
  }
}

void loop() {}

Connect your sensors one at a time and record each address printed in the Serial Monitor. Label your sensors physically (use a marker on the cable) with the address index or the last 4 hex digits of their address. This is essential for identifying which sensor is reading which physical location.

Sample output with 3 sensors:

Found 3 DS18B20 sensor(s) on bus:

Sensor 0  Address: 28-FF-3A-4C-A0-17-05-C1
Sensor 1  Address: 28-01-9D-5E-A0-17-05-88
Sensor 2  Address: 28-BB-12-1F-A0-17-05-3F

Reading Specific Sensors by Address

Once you have your sensor addresses, hardcode them into your project. This ensures consistent sensor identification even if the bus is power-cycled or a sensor is temporarily disconnected and reconnected:

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

#define ONE_WIRE_BUS 2

OneWire          oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

// === Hardcoded sensor addresses (from scan sketch above) ===
DeviceAddress sensor_room    = { 0x28, 0xFF, 0x3A, 0x4C, 0xA0, 0x17, 0x05, 0xC1 };
DeviceAddress sensor_outside = { 0x28, 0x01, 0x9D, 0x5E, 0xA0, 0x17, 0x05, 0x88 };
DeviceAddress sensor_water   = { 0x28, 0xBB, 0x12, 0x1F, 0xA0, 0x17, 0x05, 0x3F };

void setup() {
  Serial.begin(115200);
  sensors.begin();
  
  // Set 12-bit resolution for all sensors
  sensors.setResolution(sensor_room,    12);
  sensors.setResolution(sensor_outside, 12);
  sensors.setResolution(sensor_water,   12);
  
  Serial.println("DS18B20 multi-sensor system ready.");
}

void loop() {
  // Request temperature conversion from ALL sensors simultaneously
  sensors.requestTemperatures();
  
  // Read each sensor by its address
  float temp_room    = sensors.getTempC(sensor_room);
  float temp_outside = sensors.getTempC(sensor_outside);
  float temp_water   = sensors.getTempC(sensor_water);
  
  Serial.print("Room: ");    Serial.print(temp_room, 2);    Serial.print("°C  ");
  Serial.print("Outside: "); Serial.print(temp_outside, 2); Serial.print("°C  ");
  Serial.print("Water: ");   Serial.print(temp_water, 2);   Serial.println("°C");
  
  delay(2000);
}

Notice the key pattern: sensors.requestTemperatures() is called once — it sends a single CONVERT T command on the bus that triggers all sensors to simultaneously start their analog-to-digital conversion. Then you read each sensor individually with getTempC(address). This is far more efficient than requesting and reading each sensor individually.

Simultaneous Temperature Conversion for Speed

By default, the DallasTemperature library uses blocking mode: requestTemperatures() waits for the conversion to complete before returning. At 12-bit resolution, this means a blocking wait of up to 750ms per call — and since all sensors convert simultaneously, it is still only 750ms total regardless of sensor count. This is already very efficient for most applications.

For time-critical applications, use non-blocking (async) mode:

void setup() {
  sensors.begin();
  sensors.setWaitForConversion(false);  // Non-blocking mode
}

unsigned long lastRequest = 0;
bool conversionRequested  = false;

void loop() {
  if (!conversionRequested) {
    sensors.requestTemperatures();
    lastRequest          = millis();
    conversionRequested  = true;
  }
  
  // 750ms conversion time for 12-bit resolution
  if (conversionRequested && (millis() - lastRequest >= 750)) {
    float temp1 = sensors.getTempC(sensor_room);
    float temp2 = sensors.getTempC(sensor_outside);
    float temp3 = sensors.getTempC(sensor_water);
    
    // ... use temp1, temp2, temp3 ...
    Serial.print(temp1); Serial.print(" "); Serial.println(temp2);
    
    conversionRequested = false;  // Ready for next cycle
  }
  
  // Do other work here while conversion happens in background...
  doOtherWork();
}

void doOtherWork() {
  // Read other sensors, update display, etc.
}
DS18B20 Temperature Sensor Module

DS18B20 Temperature Sensor Module

Board-mounted DS18B20 with pull-up resistor and indicator LED — easiest way to add a calibrated digital temperature probe to any Arduino project.

View on Zbotic

Parasitic Power Mode for Long-Distance Sensing

In parasitic power mode, the DS18B20 eliminates the VDD wire entirely — the sensor draws its power directly from the DQ data line (it stores charge in an internal capacitor during high periods). This means you only need TWO wires for very long sensor runs: GND and DQ. This is ideal for embedded probes in walls or underground pipelines.

To enable parasitic mode:

  1. Connect DS18B20 VDD pin to GND (not left floating)
  2. Connect DQ to your Arduino pin with 4.7kΩ pull-up to 5V
  3. During temperature conversion, the 1-Wire master must actively hold the bus HIGH (strong pull-up)
// For parasitic power — use requestTemperatures with parasite power flag
sensors.requestTemperatures();  // Library auto-detects parasitic mode
// Library will drive bus HIGH for 750ms during conversion automatically

Limitation: In parasitic mode, you cannot run multiple 1-Wire operations during conversion, and bus length is more restricted (lower current means more voltage drop over long cables). For most parasitic applications, keep total cable length under 20 meters.

Setting Measurement Resolution (9–12 bit)

The DS18B20 offers four resolution settings that trade off between conversion time and temperature precision:

Resolution Precision Conversion Time Best For
9-bit ±0.5°C (0.5°C steps) 93.75 ms Fast polling, HVAC triggers
10-bit 0.25°C steps 187.5 ms General use
11-bit 0.125°C steps 375 ms Lab measurements
12-bit 0.0625°C steps 750 ms Maximum precision

The resolution setting is stored in the sensor’s EEPROM — it persists across power cycles. Set it once in your setup() and it stays until you change it:

sensors.setResolution(9);   // All sensors, 9-bit (fastest)
sensors.setResolution(12);  // All sensors, 12-bit (most precise)
sensors.setResolution(sensorAddress, 11);  // Specific sensor only

Frequently Asked Questions

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

A: Theoretically up to 2^48 (millions) — limited by addressing. In practice, bus capacitance limits reliable operation to about 10–20 sensors on a typical 1-meter bus with standard pull-up values. For more sensors or longer cables, use an active 1-Wire bus master chip or multiple buses on separate Arduino pins.

Q: One of my sensors always reads -127°C or 85°C. What does this mean?

A: -127°C (exactly -127.00) means the sensor was not found or communication failed — check your pull-up resistor and wiring. 85°C is the power-on reset value of the sensor’s scratchpad register — it means the conversion has not completed yet when you read it. Increase your conversion wait time, especially if using non-blocking mode.

Q: Can I mix DS18B20 and DS18S20 sensors on the same bus?

A: Yes — they share the 1-Wire protocol. However, the DallasTemperature library handles their different scratchpad formats automatically. The DS18S20 has fixed 9-bit resolution (no programmable resolution), while DS18B20 has 9–12 bit selectable resolution. Both return temperatures via getTempC().

Q: My sensors work individually but fail when I connect them all together. Why?

A: The bus capacitance increases with each sensor added (each DS18B20 adds about 25pF, plus cable capacitance). Try reducing the pull-up resistor from 4.7kΩ to 2.2kΩ to shorten rise times. Also verify you are using linear (daisy-chain) topology, not star topology. Check for any loose connections — a single bad connection can corrupt the entire bus.

Q: Can I use DS18B20 sensors with ESP32 or ESP8266 instead of Arduino?

A: Yes — the OneWire and DallasTemperature libraries work on ESP32 and ESP8266 with the Arduino framework. Use any GPIO pin. However, note that ESP chips run at 3.3V — the DS18B20 works at 3.0–5.5V, so power it from 3.3V and use a 4.7kΩ pull-up to 3.3V. Do not use 5V with an ESP32 — the GPIO pins are NOT 5V tolerant.

LM35 Temperature Sensors

LM35 Temperature Sensors

Simple analog alternative when you need just one or two temperature readings without the 1-Wire protocol complexity — direct mV/°C output.

View on Zbotic

Conclusion

The ability to run multiple DS18B20 sensors on a single 1-Wire bus with Arduino is one of the most practical and elegant features in the maker world. With just one data pin, a single pull-up resistor, and two well-established libraries, you can build a professional multi-zone temperature monitoring system that rivals commercial solutions at a fraction of the cost.

The key takeaways: always use linear daisy-chain topology, include the mandatory 4.7kΩ pull-up, scan and record each sensor’s unique 64-bit address, and use requestTemperatures() once for simultaneous conversion across all sensors. Whether you are monitoring room temperatures, tank levels, battery packs, or industrial pipelines, DS18B20 on a 1-Wire bus is the most wire-efficient way to add distributed temperature sensing to your Arduino project.

Build your multi-sensor temperature network today! Zbotic.in stocks DS18B20 sensors in both TO-92 IC form and pre-mounted modules with built-in pull-up resistors. Fast delivery across India.

Shop Temperature Sensors at Zbotic

Tags: 1-Wire bus, arduino temperature sensor, Dallas temperature, DS18B20, multiple sensors
Share Post
  • Facebook
  • Linkedin
  • Whatsapp
Hydraulic vs Electric Actuator...
blog hydraulic vs electric actuator which is right for your build 596407
blog how to use ldr light sensor with arduino darkness detection 596410
How to Use LDR Light Sensor wi...

Related posts

Svg%3E
Read more

Encoder Module: Position and Speed Measurement with Arduino

April 1, 2026 0
A rotary encoder converts the angular position and rotation speed of a shaft into electrical signals that Arduino can count... Continue reading
Svg%3E
Read more

Infrared Obstacle Sensor: Line Follower and Object Detection

April 1, 2026 0
Infrared obstacle sensors are the building blocks of line-following robots, edge detection systems, and proximity triggers. These tiny modules emit... Continue reading
Svg%3E
Read more

Rain Sensor and Raindrop Detection Module: Arduino Guide

April 1, 2026 0
A rain sensor module detects the presence of water droplets on its surface, giving Arduino a simple signal to trigger... Continue reading
Svg%3E
Read more

LiDAR Sensor TFmini: Distance Measurement Beyond Ultrasonic

April 1, 2026 0
When ultrasonic sensors hit their limits — range too short, accuracy too coarse, outdoor sunlight causing interference — LiDAR sensors... Continue reading
Svg%3E
Read more

Pressure Sensor BMP280: Weather Station and Altitude Meter

April 1, 2026 0
The BMP280 barometric pressure sensor by Bosch measures atmospheric pressure with ±1 hPa accuracy and temperature with ±1°C precision. These... Continue reading

Add comment Cancel reply

Your email address will not be published. Required fields are marked

Facebook Twitter Instagram Pinterest Linkedin Youtube

Get the latest deals and more.

Download on Google Play Download on the App Store

Call us: 020 69134444 / 1800 209 0998

Monday - Saturday 09:30 AM - 06:00 PM
For Technical Supports Email: [email protected]
For Sales / Enquiries Email: [email protected]

  • My Account

    • Cart

    • Wishlist

    • Checkout

    • My Orders

    • Track Order

    • My Account

  • Information

    • FAQs

    • Blogs

    • Career

    • About Us

    • Contact Us

    • Payment Options

  • Policies

    • Privacy Policy

    • Terms & Conditions

    • GST Input Tax Credit

    • Shipping Return Policy

    • E-Waste Collection Points

    • Our Sitemap

© Zbotic.in is registered trademark of Moxie Supply Pvt Ltd – All Rights Reserved
Login
Use Phone Number
Use Email Address
Not a member yet? Register Now
Reset Password
Use Phone Number
Use Email Address
Register
Already a member? Login Now