How To Use DS18B20 Water Proof Temperature Sensor

In this article we are showing how to use DS18B20 one wire water proof temperature sensor.
With the help of DS18B20 one wire temperature sensor we can measure the temperature from -55℃ To 125℃ with accuracy of ±5 .

Components Required :-

  1. 1 x Arduino uno board
  2. 1 x USB cable
  3. 1 x DS18B20 Temperature Sensor
  4. 3 x Jumper wire (Male to Male)

Additional Library :-

  1. One Wire Library
  2. Dallas Temperature Sensor library

Installation Instruction is available here

Connection :-


Sketch/Source Code :-

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

#define ONE_WIRE_BUS 5

OneWire oneWire(ONE_WIRE_BUS);

DallasTemperature sensors(&oneWire);

 float Celcius=0;
 float Fahrenheit=0;
void setup(void)

void loop(void)
  Serial.print(" C  ");
  Serial.print(" F  ");

You may also like...

10 Responses

  1. Tim Smith says:

    Hi. Great tutorial, thanks. Quick note, I used the waterproof DS18B20 from Sparkfun instead of the Elenker shown above. This required a pull-up resistor in order to complete the project. Again, thanks… Tim

  2. Jack says:

    I don’t know why I cant get the right data ? Do we really need a pull-up resistor as Tim said ?

  3. Ravi says:

    can this sensor measure temperature of Soil?

    • IoT Boys IoT Boys says:

      No, DS18B20 Digital Thermometer provides 9 to 12-bit (configurable) temperature readings which indicate the temperature of the device. For soil temperature measurement you can use 109SS-L sensor.

  4. Elsa says:

    My serial monitor keeps giving C-127 while the water is boiling, is there something wrong in my code?

    • IoT Boys IoT Boys says:

      Hi Elsa,
      Definitely there is something wrong, so what I suggest to do check proper wiring once otherwise most probably your sensor is not working fine so check with other sensor.

      Best Regards,

Leave a Reply

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