Description
The DS18B20 is a widely used 1-Wire waterproof digital temperature sensor that comes in the form of a Stainless-steel probe. it is manufactured by Dallas Semiconductor (acquired by Maxim Integrated). This sensor has the characteristics of small size, low hardware overhead, high precision, and strong anti-interference ability. This sensor is perfect for measuring temperature in wet conditions, beneath the ground, underwater, or something far away.Â
This Sensor can measure a wide temperature in the range of -55°C ( -67°F) to +125°C (+257°F) with +-5% accuracy. This Sensors used a one-wire bus protocol to communicate with a microcontroller, which means it uses a single digital pin of any microcontroller/microprocessor to transmit the temperature readings. The temperature sensor’s resolution ranges from 9 to 12 bits. however, the default resolution to power up the sensor is 12-bit (i.e., 0.0625°C precision).
Specifications
Parameter | Value |
Sensor Type | Programmable Digital Temperature Sensor |
Operating Voltage | 3.3V – 5V |
Operating Current | 1 A |
Measuring temperature range | -55ºC to +125ºC (-67°F to +257°F) |
Accuracy | ±0.5°C Accuracy from -10°C to +85°C |
Programmable Resolution | 9 to 12 bit (Selectable) |
Conversion Time | < 750ms |
Sensing Probes | Stainless Steel tube |
Sensor Probe Length/ Diameter | 45mm Long, 6mm Diameter |
Cable Length/ Diameter | 36 Inch / 91cm long, 4mm Diameter |
Technical Features
- Unique 1-Wire® Interface Requires Only One Digital Pin of microcontroller/microprocessor for Communication
- In Parasitic Power Mode, Requires Only 2 Pins for Operation (Data and GND pin).
- Multiple temperature sensors can share one pin of microcontroller/microprocessor
- No External Components are Required
- Temperature Sensor and EEPROM
- Unique 64-bit address enables multiplexing
- Programmable alarm options
- It is Available in 8-Pin SO (150 mils), 8-Pin µSOP, and 3-Pin TO-92 Packages
Application
- This sensor is widely used to calculate the temperature in a rigid environment like mines, chemical solutions, soil, etc.
- Measuring Liquid temperature
- it can be used in the thermostat controls system
- Used in industries as a temperature-measuring device
- It is very useful where the temperature has to be measured at multiple points
Pinout/Pin Diagram
Pin No. | Pin Name | Â Description |
1 | GND | This is the Ground pin of the sensor, it needs to connect to the GND terminal of the microcontroller. |
2 | VCC |
This is the Power Supply pin of the sensor, it needs to connect to the 3.3V or 5V terminal of the microcontroller/microprocessor. |
3 | DATA |
This is the Output pin. It Provides the output using one wire method that should be connected to a digital pin on the microcontroller/microprocessor. |
Â
Working Principle of DS18B20 Waterproof Temperature Sensor
The working principle of the DS18B20 Waterproof temperature sensor is similar to any other temperature sensor. The resolution of the sensor ranges from 9-bits to 12-bits. But 12-bit is used as the default resolution to power up this sensor. It measures temperature, as well as the conversion of Analog-to-Digital (A-to-D), which can be done with a convert-T command. The output temperature value can be stored within the 2-byte register in the sensor, and after that, this sensor returns to its inactive state.
The DS18B20 Temperature Sensor has three wires/pins (Vcc, ground, and data wires) for operation. But in parasite mode, only the ground and data lines are used to operate the sensor, the input voltage of the sensor is supplied through the data line.
Hardware Required
- Arduino Uno
- USB 2.0 cable type A/B
- DS18B20 Temperature Sensor
- Jumper Wires
- 9V power adapter for arduino
Wiring Diagram
Code
Note: You have to install Dallas Temperature Library
#include <OneWire.h>
#include <DallasTemperature.h>
const int SENSOR_PIN = 13; // Arduino pin connected to DS18B20 sensor's DQ pin
OneWire oneWire(SENSOR_PIN); // setup a oneWire instance
DallasTemperature tempSensor(&oneWire); // pass oneWire to DallasTemperature library
float tempCelsius; // temperature in Celsius
float tempFahrenheit; // temperature in Fahrenheit
void setup()
{
Serial.begin(9600); // initialize serial
tempSensor.begin(); // initialize the sensor
}
void loop()
{
tempSensor.requestTemperatures(); // send the command to get temperatures
tempCelsius = tempSensor.getTempCByIndex(0); // read temperature in Celsius
tempFahrenheit = tempCelsius * 9 / 5 + 32; // convert Celsius to Fahrenheit
Serial.print("Temperature: ");
Serial.print(tempCelsius); // print the temperature in Celsius
Serial.print("°C");
Serial.print(" ~ "); // separator between Celsius and Fahrenheit
Serial.print(tempFahrenheit); // print the temperature in Fahrenheit
Serial.println("°F");
delay(500);
}