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);
}

You may also like...

4 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 ?

Leave a Reply

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