Home  Product Technical Articles   How Does DS18B20 Temperature Sensor Work?

How Does DS18B20 Temperature Sensor Work?

Author: Iggy
Date: 27 Jan 2022
 17433
ds18b20 sensor

Ordering & Quality

Photo Mfr. Part # Company Description Package PDF Qty Pricing
(USD)
DS18B20 DS18B20 Company:Maxim Integrated Remark:Temperature Sensor Digital, Local -55°C ~ 125°C 12 b TO-92-3 Package:TO-226-3, TO-92-3 (TO-226AA)
DataSheet
In Stock:On Order
Buy
Price:
Call
Buy
DS18B20-GG8 DS18B20-GG8 Company:Maxim Integrated Remark:Programmable Resolution 1-Wire Digital Thermometer Package:TO-92
N/A
In Stock:On Order
Buy
Price:
Call
Buy
DS18B20U DS18B20U Company:Maxim Integrated Remark:SENSOR DIGITAL -55C-125C 8UMAX Package:8-TSSOP, 8-MSOP (0.118", 3.00mm Width)
DataSheet
In Stock:2478
Buy
Price:
1+: $4.25000
10+: $3.81700
25+: $3.60800
100+: $3.12710
500+: $2.66202
1000+: $2.57839
Buy
DS18B20Z DS18B20Z Company:Maxim Integrated Remark:Temperature Sensor Digital, Local -55°C ~ 125°C 12 b 8-SOIC Package:8-SOIC (0.154"", 3.90mm Width)
DataSheet
In Stock:On Order
Buy
Price:
Call
Buy

I Description

DS18B20 is a widely used digital temperature sensor, and its output is a digital signal. DS18B20 has the characteristics of small size, low hardware overhead, strong anti-interference ability and high precision. The DS18B20 digital temperature sensor is easy to wire and can be used in many occasions after being packaged. Such as pipe, thread, magnet adsorption, stainless steel package and so on.

This Arduino for beginners tutorial will teach you how to read the DS18B20 1-wire temperature sensor.

Catalog

I Description

II Introduction to DS18B20

2.1 DS18B20 Basic Information

2.2 DS18B20 Features

2.3 DS18B20 Structure

III Introduction to Components

3.1 Memory

3.2 64-bit Lithography ROM

3.3 Connection of External Power Supply

3.4 Configuration Register

3.5 Temperature Reading

IV DS18B20 Working Principle

V Conclusion

FAQ

Ordering & Quantity

II Introduction to DS18B20

2.1 DS18B20 Basic Information

DS18B20 is an improved intelligent temperature sensor newly launched by American DALLAS Semiconductor after DS1820.

Compared with the traditional thermistor, DS18B20 can directly read the measured temperature and can realize the 9-12-digit digital value reading mode through simple programming according to actual requirements. It can also complete 9-bit and 12-bit digital quantities in 93.75 ms and 750 ms, respectively. Moreover, the information read from the DS18B20 or the information written into the DS18B20 only needs one port line (single-wire interface) to read and write, and the temperature conversion power comes from the data bus. The bus itself can also supply power to the connected DS18B20 without the need for an additional power supply.

Therefore, the use of DS18B20 can make the system structure simpler and more reliable.

DS18B20 has greatly improved compared with DS1820 in terms of temperature measurement accuracy, conversion time, transmission distance, and resolution. It brings more convenient use and more satisfying effects to users.

2.2 DS18B20 Features

  • Unique 1-Wire® Interface Requires Only One Port Pin for Communication
  • Reduce Component Count with Integrated Temperature Sensor and EEPROM
    • Measures Temperatures from -55°C to +125°C (-67°F to +257°F)
    • ±0.5°C Accuracy from -10°C to +85°C
    • Programmable Resolution from 9 Bits to 12 Bits
    • No External Components Required
  • Parasitic Power Mode Requires Only 2 Pins for Operation (DQ and GND)
  • Simplifies Distributed Temperature-Sensing Applications with Multidrop Capability
    • Each Device Has a Unique 64-Bit Serial Code Stored in On-Board ROM
  • Flexible User-Definable Nonvolatile (NV) Alarm Settings with Alarm Search Command Identifies Devices with Temperatures Outside Programmed Limits
  • Available in 8-Pin SO (150 mils), 8-Pin µSOP, and 3-Pin TO-92 Packages

2.3 DS18B20 Structure

The external structure of DS18B20 is shown in the figure 1. Among them:

  • VDD is the power input terminal;
  • DQ is the digital signal input/output terminal;
  • GND is the power ground.

ds18b20 structure

Figure 1. DS18B20 External Structure

The internal structure of DS18B20 mainly includes 4 parts:

  • 64-bit lithography ROM;
  • Temperature sensor;
  • Non-volatile temperature alarm triggers TH and TL;
  • Configuration register.

ds18b20 structureFigure 2. DS18B20 External Structure

In the 64-bit ROM, the manufacturer has a 64-bit serial number burned by the manufacturer before the product leaves the factory. The serial number can be regarded as the address serial code of DS18B20, used to distinguish each DS18B20. So as to better realize the multi-point measurement of field temperature.

III Introduction to Components

3.1 Memory

The memory of DS18B20 includes high-speed scratchpad RAM and electrically erasable RAM.

The electrically erasable RAM also includes temperature triggers TH and TL, and a configuration register. The memory can completely determine the communication of the one-line port, and the number is written into the register with the command of writing the register. Then you can use the read register command to confirm these numbers. After confirmation, you can use the copy register command to transfer these numbers to the electrically erasable RAM. When the number in the register is modified, this process can ensure the integrity of the number.

The scratchpad RAM is composed of 8 bytes of memory. The ninth byte can be read with the read register command. This byte is to check the previous eight bytes.

3.2 64-bit Lithography ROM

For 64-bit lithography ROM:

  • The first 8 bits are the own code of DS18B20
  • The next 48 bits are consecutive digital codes
  • The last 8 bits are the CRC check of the first 56 bits.

The 64-bit lithography ROM also includes 5 ROM function commands: read ROM, match ROM, skip ROM, search ROM and alarm search.

3.3 Connection of External Power Supply

DS18B20 can use external power VDD or internal parasitic power. When the VDD port is connected to a voltage of 3.0V-5.5V, an external power supply is used. An internal parasitic power supply is used when the VDD port is grounded. In addition, whether it is an internal parasitic power supply or an external power supply, the I/O port line should be connected to a pull-up resistor of about 5KΩ.

3.4 Configuration Register

The configuration register is to configure different digits to determine the temperature and digital conversion.

It can be known that R1 and R0 are the determining bits of temperature. Different combinations of R1 and R0 can be configured as 9-digit, 10-digit, 11-digit, and 12-digit temperature display. In this way, the conversion time corresponding to different temperature conversion positions can be known. The resolutions of the four configurations are 0.5°C, 0.25°C, 0.125°C and 0.0625°C, respectively, and are configured to 12 bits at the factory.

3.5 Temperature Reading

DS18B20 is configured as 12 bits at the factory, and 16 bits are read when reading temperature.

The first 5 bits are sign bits. When the first 5 digits are 1, the temperature read is a negative number; when the current 5 digits are 0, the temperature read is a positive number.

  • The method of reading when the temperature is positive is: just convert the hexadecimal number to decimal.
  • When the temperature is negative, the reading method is: invert the hexadecimal number, then add 1 on this basis, and then convert to decimal.

  Example: 0550H = +85 degrees, FC90H = -55 degrees.

IV DS18B20 Working Principle

The read and write sequence and temperature measurement principle of DS18B20 are the same as DS1820. Only the number of digits of the temperature value obtained varies with the resolution. And the delay time during temperature conversion is reduced from 2s to 750ms.

The temperature measurement principle of DS18B20 is shown in Figure 3.

ds18b20 temperature measurement principle diagram

Figure 3. DS18B20 Temperature Measurement Principle Diagram

The oscillation frequency of the crystal oscillator with low temperature coefficient in the picture is little affected by temperature. It is used to generate a fixed frequency pulse signal and send it to the subtraction counter 1. The high temperature coefficient crystal oscillator changes its oscillation frequency significantly with temperature changes. At the same time, the generated signal is used as the pulse input of the subtraction counter 2. The figure also implies a counting gate. When the counting gate is opened, DS18B20 counts the clock pulses generated by the low temperature coefficient oscillator to complete the temperature measurement.

The opening time of the counting gate is determined by the high temperature coefficient oscillator. Before each measurement, first put the base corresponding to -55 ℃ into the subtraction counter 1 and the temperature register respectively. The subtraction counter 1 and the temperature register are preset to a base value corresponding to -55 ℃.

The subtraction counter 1 subtracts the pulse signal generated by the low temperature coefficient crystal oscillator. When the preset value of the subtraction counter 1 is reduced to 0, the value of the temperature register will increase by 1, the preset of the subtraction counter 1 will be reloaded, and the subtraction counter 1 will restart counting the pulse signals generated by the low temperature coefficient crystal oscillator.

This loop until the subtraction counter 2 counts to 0, stop the accumulation of the temperature register value. The value in the temperature register is the measured temperature at this time.

ds18b20

Figure 4. DS18B20

The slope accumulator is used to compensate and correct the nonlinearity in the temperature measurement process, and its output is used to correct the preset value of the subtraction counter. As long as the counting gate is not closed, repeat the above process until the temperature register value reaches the measured temperature value. This is the temperature measurement principle of DS18B20.

In addition, because the DS18B20 single-wire communication function is completed in time sharing, it has a strict concept of time slots. Therefore, the read and write timing is very important. Various operations of the system to DS18B20 must be carried out according to the agreement. The operating protocol is: initialize DS18B20 (send reset pulse) → send ROM function command → send memory operation command → process data. The timing diagram of various operations is the same as that of DS1820.

V Conclusion

In conclusion, this blog summarizes the following 3 aspects of DS1820: Features, structure and working principle.

DS1820 mainly changes its appearance according to different applications. The packaged DS18B20 can be used in various non-limiting temperature applications. Including cable trench temperature measurement, blast furnace water circulation temperature measurement, boiler temperature measurement, machine room temperature measurement, agricultural greenhouse temperature measurement, clean room temperature measurement, ammunition storage temperature measurement, etc.

In addition, DS1820 is abrasion-resistant and impact-resistant, small in size, easy to use, and diverse in packaging, suitable for digital temperature measurement and control of various narrow space equipment.


FAQ

  • What is DS18B20 temperature sensor?

The DS18B20 is a 1-wire programmable temperature sensor from maxim integrated. It is widely used to measure temperature in hard environments like in chemical solutions, mines or soil etc. The constriction of the sensor is rugged and also can be purchased with a waterproof option making the mounting process easy.

  • How does the DS18B20 work?

It works on the principle of direct conversion of temperature into a digital value. 

  • Is DS18B20 a thermistor?

A thermistor is a thermal resistor - a resistor that changes its resistance with temperature. ... Thermistors have some benefits over other kinds of temperature sensors such as analog output chips (LM35/TMP36 ) or digital temperature sensor chips (DS18B20) or thermocouples.

  • How accurate is DS18B20?

The DS18B20 reads with an accuracy of ±0.5°C from -10°C to +85°C and ±2°C accuracy from -55°C to +125°C.

  • What is ds1820?

The DS18B20 is one type of temperature sensor and it supplies 9-bit to 12-bit readings of temperature. ... The communication of this sensor can be done through a one-wire bus protocol which uses one data line to communicate with an inner microprocessor.

  • How do I connect my DS18B20 to my Raspberry Pi?

Once you've connected the DS18B20, power up your Pi and log in, then follow these steps to enable the One-Wire interface:
1.At the command prompt, enter sudo nano /boot/config.txt , then add this to the bottom of the file:
2.dtoverlay=w1-gpio.
3.Exit Nano, and reboot the Pi with sudo reboot.

  • What is the working principle of DS18B20?

The DS18B20 Digital Thermometer provides 9 to 12-bit (configurable) temperature readings which indicate the temperature of the device. It communicates over a 1-Wire bus that by definition requires only one data line (and ground) for communication with a central microprocessor. In addition it can derive power directly from the data line (“parasite power”), eliminating the need for an external power supply.
The core functionality of the DS18B20 is its direct-to-digital temperature sensor. The resolution of the temperature sensor is user-configurable to 9, 10, 11, or 12 bits, corresponding to increments of 0.5°C, 0.25°C, 0.125°C, and 0.0625°C, respectively. The default resolution at power-up is 12-bit.

  • Where to use DS18B20 Sensor?

The DS18B20 is a 1-wire programmable Temperature sensor from maxim integrated. It is widely used to measure temperature in hard environments like in chemical solutions, mines or soil etc. The constriction of the sensor is rugged and also can be purchased with a waterproof option making the mounting process easy. It can measure a wide range of temperature from -55°C to +125° with a decent accuracy of ±5°C. Each sensor has a unique address and requires only one pin of the MCU to transfer data so it a very good choice for measuring temperature at multiple points without compromising much of your digital pins on the microcontroller.

  • How connect DS18B20 to Arduino?

First plug the sensor on the breadboard the connect its pins to the Arduino using the jumpers in the following order: pin 1 to GND; pin 2 to any digital pin (pin 2 in our case); pin 3 to +5V or +3.3V, at the end put the pull-up resistor.

  • On an ATMega328P, why is a DS18B20 temperature sensor returning incorrect temperature values?

Several possibilities:
1. If it is just reading a little high, it might be caused by “self heating”. Add a heat sink and/or make measurements less frequently.
2. Especially if the values are really whacky, it might be code with errors or mis-wiring. Use a published sketch to check operation.
3. The DS18B20 might be defective. Try another.
4. It’s accurate to 0.5ºC.

Are you expecting it to be more accurate (like down to the LSB of the read value)?

Related Articles

ZEN056V230A16LS Polymer Enhanced Zener Diode Datasheet PDF Download

Irene 19 Apr 2022 584

Catalog General DescriptionBenefitsFeaturesTarget ApplicationsTypical Application Block DiagramPin ConfigurationBlock DiagramDefinition of TermsGeneral SpecificationsElectrical CharacteristicsMechani...

Continue reading »

BSS123 N-Channel Logic Level Enhancement Mode Field Effect Transistor Datasheet PDF Download

Irene 18 Mar 2022 1013

Catalog General DescriptionFeaturesMarking DiagramOrdering InformationAbsolute Maximum RatingsThermal CharacteristicsElectrical CharacteristicsTypical CharacteristicsPackage DimensionsBSS123 Datashee...

Continue reading »

MJE15032 Complementary Silicon Plastic Power Transistors Datasheet PDF Download

Irene 1 Apr 2022 578

Catalog FeaturesComplementaryMaximum RatingsThermal CharacteristicsMarking DiagramOrdering InformationElectrical CharacteristicsTypical CharacteristicsMJE15032 DatasheetMJE15032 FAQ   Designed...

Continue reading »

BFU590GX RF Bipolar Transistors: Pinout, Datasheet and Package

Victoria 13 Feb 2023 525

CatalogBFU590GX OverviewBFU590GX Features and BenefitsBFU590GX Pinning InformationBFU590GX ApplicationsBFU590GX Package OutlineBFU590GX SpecificationBFU590GX Ma...

Continue reading »

DM74LS75 Quad Latch: Logic Diagram, Ordering Code and Datasheet

Irene 12 Apr 2022 1502

Catalog Product OverviewLogic DiagramConnection DiagramOrdering CodeAbsolute Maximum RatingRecommended Operating ConditionsDatasheetProduct AttributesManufacturerUsing WarningFAQ Product OverviewDM7...

Continue reading »

1 comments

    • robu on 2022/9/13 15:37:58

    DS18B20 Temperature Sensor Module is a digital temperature sensor, .It can easily be connected to Arduino. It can be used in a variety of applications such as cold storage, granaries, storage tanks, telecommunications room, electric power rooms, cable troughs, and other temperature measurement and control areas.

Leave a Reply

Your email address will not be published.

 
 
   
 
Rating:

# 0 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z