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)
{
  
  Serial.begin(9600);
  sensors.begin();
}

void loop(void)
{ 
  sensors.requestTemperatures(); 
  Celcius=sensors.getTempCByIndex(0);
  Fahrenheit=sensors.toFahrenheit(Celcius);
  Serial.print(" C  ");
  Serial.print(Celcius);
  Serial.print(" F  ");
  Serial.println(Fahrenheit);
  delay(1000);
}
Share on facebook
Share on twitter
Share on linkedin
Share on pinterest
Share on whatsapp
Share on telegram
Share on reddit
Share on tumblr
Related Posts
About Author

31 thoughts on “How To Use DS18B20 Water Proof Temperature Sensor”

  1. 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

    1. Tim, why did you use a pull-up resistor? I’m using the same sensor as well, and it’s just outputting the same values. Is that why it is doing that?

    1. 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.

    1. 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,
      IoTBoys

  2. Hi, Im using this in an Arduino Mega 2560. I dont know if i have to put a pull-up resistor (and if i have to do, how and where i connect it), it uploads fine but the serial monitor always give -127 C. Can someone help me??

  3. Hello Sir,
    Can we use six sensors in Arduino for data logging ? Actually, I want to make a data logger with 6 channels.
    Please help.
    Thanking you in anticipation.

    Regards,

  4. Hello. I wanted to measure whether human skin is in contact with something for my project. I was thinking about using this sensor fpr measurement of skin temp. Can I do it with this device

  5. Sir im having the problem of sensor showing wrong value like 127 celicus i tried using different sensors but the problem still remained the same please help why is this error occuring.
    Thankyou

  6. Hi, I tried to follow the codes u provided above but it said “One_Wire_Bus” was not declared in this scope. what should I do?

Leave a Comment

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