Mar 122010

Finally got this DS18B20 working. Actually three of them. And in two modes. Parasite power mode and main mode.
A 4.7K ohm resistor is the key.

Starting with the main mode, three wires are needed, as this sensor has three pins.
Data sheet is here
Connection is almost simple.
Pin 1 to Arduino ground
Pin 2 to Arduino digital input
Pin 3 to Arduino 5V
And a 4.7K resistor between pin 2 and pin 3

Works with three wires, as seen on the following illustration.

DS18B20 main mode

Parasite mode eliminates one wire.
Pin 1 to Arduino ground
Pin 2 to Arduino digital input
Pin 3 to Arduino ground (same as pin 1)
And a 4.7K resistor from pin 2 to 5V

Maybe following illustration helps.
DS18B20 parasite mode

Of course multiple DS18B20-s or different one wire devices can connected together like so:

DS18B20 parasite mode

Here comes the beauty of using digital thermometers. One pin on Arduino can be used for multiple devices, working together over one wire. Much like ethernet actually. Each device has its own unique address.
Second, a two wire cable can be used. Those are usually much easier to find than three wire cables. Also digital 1-wire thermometers work on longer cables. A simple test is cable-length-for-lm35-and-ds18b20.

Some words of caution:
No pins on DS18B20 should be left unconnected. Sometimes it works this way, sometimes it does not.
If using one should avoid mixing main mode and parasite mode thermometers on the same pin. Sometimes it works, sometimes it does not.

Software? look no further than
Works well and has some nice examples too.

DS18B20 can also be installed outside. Some kind of protection is advisable.  I had one sensor outside, minimum temperature about -30° C, maximum about +35° C, protected like this. No problems so far.

Working with three DS18B20 thermometers for a year now – sometimes those thermometers do not get initialized correctly. Specially after power fluctuations. Hard reset helps in that case.


  6 Responses to “Arduino and DS18B20 – 1-wire digital thermometer”

  1. hey,

    for your 4.7kohm resistor, what was the wattage that you used? 1/6W? or will 1/4 or 1/2 work too? and what tolerance % was it too?


    • I used 1/4W resistors, but as far as I know, it does not really matter. Tolerance 5%. It should matter even less.

  2. Hi how you make the hard reset with this sensor?

  3. […] Arduino and DS18B20 – 1-wire digital thermometer (Ogalik OÜ) (Read this one first to see the wiring options) How to use the DS18S20 and DS18B20 temperature sensors with Arduino (Dedication to DIY and programming) Working with Dallas DS18S20 and DS18B20 temperature sensors (Tutorialpedia) Raspberry Pi 1- Wire Digital Thermometer Sensor (Raspberry Pi Spy) RaspberryPI DS1820 (Webshed) Raspberry Pi + DS18B20 Temperature Sensor + RRDtool (Tony Tosi) DS18B20 Temperature Sensor with Raspberry Pi (Chris Swan’s Weblog) Monitor your home temperature using your Raspberry Pi (PrivateEyePi Project) […]

  4. hi I have a star network with 5 wires. Each has a ds18b20 at the end except for one which connects into my webcontrol board.

    I have to use powered mode , ie 3-5 volts . Which is the most reliable way of the following?

    Do I need a 4.7k ohm resistor at the end of each line ?  , ie with the sensor

    Can I get away with only 1 resistor at the end of one of the star network wires ?

    Can I put the resistor instead in the middle of my star network ?

    Do I make an extra long wire with only a resistor at the end ?




  5. Достаточно одного подтягивающего резистора на стороне ведущего, при небольшой длине линии, иначе нужно использовать специальные аппаратные драйверы с активной подтяжкой линии. а вообще лучше почитайте документы фирмы изготовителя ) и многие вопросы сами по себе отпадут.

 Leave a Reply



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.