Print Friendly, PDF & Email

Introduction:

The DS18B20 Digital temperature sensor provides 9 to 12-bit (configurable) temperature readings which indicate the temperature of the device. The DS18B20 communicates over a 1-Wire bus that by definition requires only one data line (and ground) for communication with a central microprocessor.In addition, the DS18B20 can derive power directly from the data line, eliminating the need for an external power supply.

Features:

  • Usable temperature range: -55 to 125°C.
  • 9 to 12 bit selectable resolution.
  • Uses 1-Wire interface- requires only one digital pin for communication.
  • Unique 64 bit ID burned into chip.
  • Multiple sensors can share one pin.
  • ±0.5°C Accuracy from -10°C to +85°C.
  • Temperature-limit alarm system.
  • Query time is less than 750ms.
  • Usable with 3.0V to 5.5V power/data.

Components Required:

  • Temperature Probe Sensor(DS18B20) – Buy
  • Arduino Uno – Buy
  • Jumper Wires – Buy
  • 4.7k Resistor

Usage:

This sensor is being widely used in various fields. This sensor has been included in many applications such as Thermostatic Controls,Industrial Systems, Consumer Products,Thermometers,Thermally Sensitive Systems.

Project For Reference:

Connections:

The Temperature sensor has 3 pins and it should be connected as follows:

  • Vcc – 5V.
  • Gnd – Gnd.
  • Data – D2.
  • Pull up resistor of value 4.7kohm between data and supply voltage.

Circuit Diagram:

 

Code:

Before going deep into the coding parts, let us download few libraries:

Download Dallas Temperature library- https://github.com/milesburton/Arduino-Temperature-Control-Library

Download One wire library- https://github.com/PaulStoffregen/OneWire

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

// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

void setup(void)
{
  Serial.begin(9600);
  Serial.println("Arduino Digital Temperature");
  sensors.begin();
}

void loop(void)
{ 
  sensors.requestTemperatures();  
  Serial.print("Temperature is: ");
  Serial.println(sensors.getTempCByIndex(0));
  delay(1000);
}

Output: