Electronic – arduino – How many DS18B20 temperature sensors can I connect to one bus arduino


How many temperature sensors can I connect to one bus without losing accuracy.Can I use for example 50 sensors to one bus? Should I change the resistor when I connect too many sensors? Here is the manual http://datasheets.maximintegrated.com/en/ds/DS18B20.pdf

I use this schematic

//  This Arduino sketch reads DS18B20 "1-Wire" digital
//  temperature sensors.
//  Copyright (c) 2010 Mark McComb, hacktronics LLC
//  License: http://www.opensource.org/licenses/mit-license.php (Go crazy)
//  Tutorial:
//  http://www.hacktronics.com/Tutorials/arduino-1-wire-tutorial.html

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

// Data wire is plugged into pin 3 on the Arduino
#define ONE_WIRE_BUS 3

// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature. 
DallasTemperature sensors(&oneWire);

// Assign the unique addresses of your 1-Wire temp sensors.
// See the tutorial on how to obtain these addresses:
// http://www.hacktronics.com/Tutorials/arduino-1-wire-address-finder.html

DeviceAddress insideThermometer = { 0x28, 0x94, 0xE2, 0xDF, 0x02, 0x00, 0x00, 0xFE };
DeviceAddress outsideThermometer = { 0x28, 0x6B, 0xDF, 0xDF, 0x02, 0x00, 0x00, 0xC0 };
DeviceAddress dogHouseThermometer = { 0x28, 0x59, 0xBE, 0xDF, 0x02, 0x00, 0x00, 0x9F };

void setup(void)
  // start serial port
  // Start up the library
  // set the resolution to 10 bit (good enough?)
  sensors.setResolution(insideThermometer, 10);
  sensors.setResolution(outsideThermometer, 10);
  sensors.setResolution(dogHouseThermometer, 10);

void printTemperature(DeviceAddress deviceAddress)
  float tempC = sensors.getTempC(deviceAddress);
  if (tempC == -127.00) {
    Serial.print("Error getting temperature");
  } else {
    Serial.print("C: ");
    Serial.print(" F: ");

void loop(void)
  Serial.print("Getting temperatures...\n\r");

  Serial.print("Inside temperature is: ");
  Serial.print("Outside temperature is: ");
  Serial.print("Dog House temperature is: ");

Best Answer

First answer: As many as you like.

Second answer: There are limitations. For example, if the total length of the bus gets large (e.g. 50m), you will suffer from the capacity of the cable (making transitions slow) and reflections (distorting transitions). The port pin of your (unspecified) Arduino might not be able to drive a long cable with sufficient speed and quality. Note that just a stronger driver does not help here because it will cause stronger reflections. There are dedicated 1-wire master chips with a proper driving ciruit (e.g. DS2482).

Also, keep an eye on memory usage in your microcontroller. It seems you want to store the unique IDs of each sensor which will eat up a substantial amount of resources in the smaller Arduino variants. The total time needed to read out the temperature of all sensors does not seem to be a limiting factor, but this depends on the exact implementation of the protocol in your library.

To your second question: The resistor should stay as it is. It pulls up the bus if none of the connected sensors are sending a '0' and does not depend on the number of sensors connected. For long cables you might want to lower the value slightly or distribute several resistors along the cable (e.g. 3x 15k or 2x 10k).

In any case, for many sensors you should run (as shown) a dedicated power line and not rely on parasitic power mode.