The DS18B20 temperature sensor is a powerful, digital sensor ideal for Arduino projects due to its accuracy, durability, and digital communication. One of its most powerful features is the ability to connect multiple DS18B20 sensors using just one data pin on the Arduino, thanks to the OneWire communication protocol.
In this blog post, you’ll learn how to wire, identify, and read temperature data from multiple DS18B20 sensors connected in parallel on a single Arduino input pin. This is especially useful in applications like multi-zone climate control, environmental monitoring, greenhouses, aquariums, and industrial systems. if you want to know more about DS18B20 Temperature Sensor then you can click here.

Why Use Multiple DS18B20 Temperature Sensors?
The DS18B20 sensor has a unique 64-bit serial address, allowing many of them to share the same data bus. This eliminates the need for multiple analog pins or complex wiring, making it incredibly efficient for multi-point temperature sensing.

Components Required Multiple DS18B20 Temperature Sensors :
- Arduino UNO (or any compatible board)
- Two or more DS18B20 sensors (TO-92 or waterproof version)
- 4.7kΩ resistor
- Breadboard
- Jumper wires
- Arduino IDE
- Optional: I2C LCD display for temperature output
Working Principle of Multiple DS18B20 Temperature Sensors
Each DS18B20 sensor responds to the Arduino only when its unique address is called. The OneWire protocol enables the master (Arduino) to search and list all connected devices, then read their temperatures one by one.
The communication flow:
- Arduino sends a reset pulse to all DS18B20 sensors.
- Sensors respond with their unique addresses.
- Arduino queries each sensor by address and receives temperature data.
- The data is read in Celsius or Fahrenheit using the DallasTemperature library.
Circuit Diagram of Multiple DS18B20 Sensors with Arduino:
All DS18B20 sensors are connected in parallel:
DS18B20 Pin | Function | Arduino |
---|---|---|
GND | Ground | GND |
VCC | Power (3.3–5V) | 5V |
DQ (Data) | Data Line | D2 (example) |

Arduino Code to Read Multiple DS18B20 Temperature Sensors:
You can dynamically scan and list the addresses of all DS18B20 sensors:
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is connected to digital pin 2
#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
// Array to hold device addresses
DeviceAddress sensor1, sensor2;
void setup() {
Serial.begin(9600);
sensors.begin();
// Get sensor addresses
if (!sensors.getAddress(sensor1, 0)) {
Serial.println("Sensor 1 not found.");
}
if (!sensors.getAddress(sensor2, 1)) {
Serial.println("Sensor 2 not found.");
}
// Set resolution to 12-bit
sensors.setResolution(sensor1, 12);
sensors.setResolution(sensor2, 12);
}
void loop() {
sensors.requestTemperatures();
Serial.print("Sensor 1: ");
Serial.print(sensors.getTempC(sensor1));
Serial.println(" °C");
Serial.print("Sensor 2: ");
Serial.print(sensors.getTempC(sensor2));
Serial.println(" °C");
delay(2000);
}
The code above scans for the first two sensors connected and uses their addresses to read individual temperatures.
How to Find and Display All DS18B20 Sensor Addresses:
You can dynamically scan and list the addresses of all DS18B20 sensors:
void setup() {
Serial.begin(9600);
sensors.begin();
Serial.print("Number of devices found: ");
Serial.println(sensors.getDeviceCount());
for (int i = 0; i < sensors.getDeviceCount(); i++) {
DeviceAddress tempDeviceAddress;
if (sensors.getAddress(tempDeviceAddress, i)) {
Serial.print("Sensor ");
Serial.print(i);
Serial.print(" Address: ");
printAddress(tempDeviceAddress);
Serial.println();
}
}
}
void printAddress(DeviceAddress deviceAddress) {
for (uint8_t i = 0; i < 8; i++) {
if (deviceAddress[i] < 16) Serial.print("0");
Serial.print(deviceAddress[i], HEX);
}
}
Applications of Multiple DS18B20 Sensors:
- Multi-room HVAC control
- Aquarium or hydroponics monitoring
- Industrial pipe or tank temperature checks
- Weather stations with multiple locations
- Thermal mapping projects
Precautions for DS18B20 Temperature Sensors:
- Use shielded cables if sensors are far apart to reduce noise.
- Avoid long parasitic mode connections unless necessary.
- Each sensor must be initialized with the correct address before reading.
- Use unique labeling in your code to keep sensor readings organized.
Conclusion:
Using multiple DS18B20 temperature sensors with Arduino is a smart, scalable solution for monitoring temperature at multiple points with minimal wiring. Thanks to the OneWire protocol, you can expand your temperature monitoring network with ease while maintaining reliable and accurate readings.
Whether you’re working on a weather station, smart greenhouse, or industrial automation project, this setup offers flexibility, simplicity, and high performance.
Need Help in Setup of Multiple DS18B20 Temperature Sensors with Arduino?
If you need any Help or Assistance for Setup of Multiple DS18B20 Temperature Sensors with Arduino, with Modifications or Customization then you can contact us through WhatsApp. We can deliver you this Project in the Following Ways.
Hello arduinotutors.com administrator, Thanks for the well-organized and comprehensive post!