I just discovered that the Dallas DS18B20 can be read from either digital or analog pins. I never thought analog was an option until I stumbled across an article searching for another issue. So now I'm wondering, if I have a dozen DS18B20's on about 20 feet of wire with a 4.7k resistor, what would be the better option for reading? Digital or Analog?

  • 2
    1) the Analog on an Arduino Uno means those pins are analog-capable (not all the GPIO pins are analog-capable), meaning that they can be configured to be an analog input instead of just as digital input/output. 2)DS18B20 is a digital sensor communicating using 1-wire protocol, it is a bus, meaning multiple DB18B20 can share the same bus.
    – hcheung
    Jul 18 at 13:37

2 Answers 2


To use multiple DS18B20 devices on the same bus

1/ First get the address of each DS18B20 device by attaching it alone to the Arduino, and calling the discoverOneWireDevices(); function. Write down the address. This is a set of 8 hexadecimal digits, eg 0x28, 0x13, 0x97, 0x9A, 0x0A, 0x00, 0x00, 0x6A

2/ Hard-code the address of each device, e.g. #define TEMP_SENSOR1 {0x28, 0x13, 0x97, 0x9A, 0x0A, 0x00, 0x00, 0x6A} before the call to the setup, and define the corresponding device address: DeviceAddress tempSensor1 = TEMP_SENSOR1;

3/ each time you launch a command to a DS18B20, specify to which you are speaking, eg temperature1 = sensors.getTempC(tempSensor1);


Analog is not an option as the 1-wire is a digital communication bus, however using an analog pin is on many processors to do this is possible. This is achieved on many of the processors because the analog pin can be configured and used for digital I/O. Arduinos such as the UNO can accomplish this because of the processor they use. Note not all microprocessors are designed use an analog pin for digital I/O.

There is an application note by AMD called "1-Wire Search Algorithm", https://www.analog.com/en/app-notes/1wire-search-algorithm.html. By using this process you can read all of the sensors independently without knowledge of there addresses. Using this method will not guarantee which sensor you are reading but the sequence will repeat and you can simply replace a sensor but the order will probably change. This allows you to change sensors etc when there are not many sensors involved. Here are some links to better explain this.



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.