We are Apogeeweb Semiconductor Electronic

WELCOME TO OUR BLOG

Home  Product Technical Articles   DS18B20 Circuit: Multifunctional Electronic Thermometer

DS18B20 Circuit: Multifunctional Electronic Thermometer

Author: Mia
Date: 22 Sep 2020
 534
ds18b20 temperature

I Description

In this blog, we will introduce a multifunctional electronic thermometer. This kind of thermometer can not only accurately and conveniently measure body temperature and food temperature, but also can be used to measure indoor and outdoor temperature, refrigerator temperature, etc. In addition, it also has multiple functions such as temperature measurement timing, temperature memory, sound prompt, backlight display, and automatic shutdown. Moreover, it has the characteristics of accurate measurement, simple operation, portability and low price. Therefore, it can be widely used in hospitals and homes as a general temperature measuring instrument.

 

In terms of its working principle, the thermometer uses the digital temperature sensor DS18B20 to detect temperature and transmits the digital temperature signal to the single-chip microcomputer. The temperature value and measurement time calculated and corrected by the single-chip microcomputer are displayed in real time by the liquid crystal display.

A tutorial on how to use the Dallas Maxim 1-Wire DS18B20 digital temperature sensor with the Arduino.

Catalog

I Description

II DS18B20 Introduction

III Hardware Circuit

3.1 Power Circuit

3.2 Digital Temperature Sensor and Calibration

3.3 MCU Circuit

3.4 LCD Display

3.5 Audio Circuit

IV Software Design

V Conclusion

FAQ

Ordering & Quantity

 

II DS18B20 Introduction

DS18B20 is a single-wire digital temperature sensor produced by DALLAS. It integrates temperature sensing, signal conversion, A/D conversion and heating functions into one chip, and belongs to a new generation of intelligent digital temperature sensors with microprocessors. DS18B20 has a total of 3 pins, (respectively digital signal input/output, ground, power supply), using TO-92 small-volume packaging.

DS18B20 Main Specifications:

  • The temperature measurement range is -55℃~+125℃;
  • Programmable to 9 to 12 bit A/D conversion accuracy;
  • The temperature measurement resolution can reach 0.0625℃, and the error is ±0.5℃;
  • The working power supply can be introduced at the remote end (3-wire working mode) or generated by parasitic power supply (2-wire working mode);
  • The measured temperature is serially output with a sign-extended 16-bit digital quantity;
  • Each sensor has a unique 64-bit serial number, which is stored in the ROM of the sensor;
  • The sensor also has two temperature upper and lower limit storage units.

III Hardware Circuit

The multifunctional electronic thermometer is mainly composed of the following parts:

  • Power circuit
  • Digital temperature sensor
  • Single chip computer
  • LCD Monitor
  • Audio circuit
  • ...

Its hardware circuit schematic diagram is shown as in Fig. 1.

ds18b20 hardware circuit

Figure 1. Hardware Circuit (right click to view big picture)

3.1 Power Circuit

U1 is the micro power consumption step-down DC/DC converter LT3470 introduced by Linear Technology. Here, U1 converts the 9V dry battery voltage into 5V DC voltage to power the entire circuit.

So, how to start and shut down automatically? We only need to press the start button S2. After starting, pin 1 (SHDN) of U1 gets a high level, pin 5 of U1 outputs a 5V stable DC voltage, and the thermometer starts to work at this time. Then, the 14-pin (P1.2) of the one-chip computer outputs a high level through D2 to keep the 1 pin of U1 high. When 6 minutes are up, the 14-pin of the single-chip microcomputer outputs a low level, and the 1 pin of U1 becomes a low level, and the circuit automatically powers down.

3.2 Digital Temperature Sensor and Calibration

The digital temperature sensor DS18B20 is used as a temperature measuring probe to collect temperature signals. And the digitized temperature signal is input through the 19-pin (P1.7) of the microcontroller. DS18B20 adopts 2-wire working mode, and the working power is generated by parasitic power.

For example, use this thermometer to measure the temperature of a baby. We can fix the temperature probe on a special bandage and tie it to the arm. So that the sensor is located under the armpit. In this way, it can be avoided that the temperature measuring probe is detached from the test site. Due to infant activities or crying when measuring the body temperature of the infant, and the measurement is convenient.

For another example, the temperature probe can also measure indoor and outdoor temperature, refrigerator temperature, etc. The special probe for measuring food temperature adopts non-toxic straw and non-toxic silica gel package, which is easy to clean.

Since DS18B20 is in the range of -10℃~85℃, its measurement error is ±0.5℃. In order to accurately measure body temperature, this blog uses a self-made constant temperature water bath system to determine the temperature curve of each sensor. We can calibrate the DS18B20 according to the temperature curve to make the measurement error within the range of 25℃~50℃ be ±0.1℃.

3.2.1 Constant Temperature Water Bath System

The constant temperature water bath system consists of the following three parts: an electric cooker with heat preservation, a cylindrical copper body with good heat conduction, and an automatic temperature controller.

We need to make 50 round holes with a diameter of 5mm and a height of 30mm on a cylindrical copper body with a diameter of 120mm and a height of 80mm. In this way, the temperature sensor can be fixed and the temperature of all the sensors in the copper body can be kept consistent. Put the cylindrical copper body into the electric cooker, and add distilled water to submerge the copper body.

3.2.2 DS18B20 Actual Temperature Curve Measurement

  1. Insert multiple encapsulated sensors to be tested (no more than 49) into the small holes of the copper body of the constant temperature water bath;
  2. Insert the high-precision digital thermometer into the small hole of the copper body to accurately measure the current temperature;
  3. The wires of all sensors are led out through the upper cover hole of the electric cooker and connected to the upper computer. Cover the electric cooker with heat preservation material;
  4. Turn on the power, change the temperature setting of the automatic thermostat, and control the temperature of the constant temperature water bath;
  5. Monitor the temperature value of the digital thermometer. Whenever the specified temperature value is reached, start the upper computer temperature measurement program and simultaneously measure the current temperature of all the sensors to be tested;
  6. From 25℃~60℃, measure 1 set of data every 5℃, and automatically generate the actual temperature curve of each sensor.

3.2.3 Correction of DS18B20

By analyzing the measured temperature curve of the sensor, we can find that within the range of 25℃~50℃, the error is -0.1℃~-0.3℃. In the design of this blog, the current temperature value of DS18B20 plus 0.2℃ is used as the actual measured temperature, so that the measurement error in the range of 25℃~50℃ is reduced to ±0.1℃.

3.3 MCU Circuit

The microcontroller (U2) is the core component of the thermometer. It has the following functions:

  • Temperature signal reading, processing calculation, correction
  • Temperature measurement timing
  • Temperature memory
  • Sound prompt,
  • Automatic shutdown
  • ...

  This design adopts AT89C2051 single-chip microcomputer produced by American ATMEL company. It is a built-in flash memory microcontroller that is fully compatible with the MCS-51 series, with only 20 pins. It is the most compact, smallest, and cheapest FlashROM microcontroller in the AT89C51 series. Provides the following standard functions:

  • An 8-bit CPU;
  • 2kB flash memory;
  • 128 bytes RAM;
  • Two 16-bit timers;
  • A complete 8-bit bidirectional I/O port;
  • 5 interrupt sources.

After starting the thermometer, the microcontroller starts an internal timer to record the temperature measurement time. It also reads the digital temperature signal sent by DS18B20, processes and corrects it to obtain the real-time temperature value. The temperature value and temperature measurement time are sent to the LCD display via serial communication via pin 1 (P3.0) and pin 2 (P3.1);

  • When the temperature measurement time reaches 5 minutes, the current temperature value is automatically registered, and pin 11 outputs a low level to control the audio circuit to give a sound prompt;
  • When the temperature measurement time reaches 6 minutes, the single-chip 14 pin outputs low level, and the thermometer is automatically powered off.

3.4 LCD Display

This blog uses a 3 and a half liquid crystal display (LCD) to display temperature and temperature measurement time. The display has the following characteristics:

  • Use glass encapsulation;
  • There are 5 pins in total;
  • Serial communication
  • With 3 and a half display area and ℃ unit display;
  • Function with backlight;
  • The power supply voltage range is 2V~5V.

This design uses the main display area to indicate the temperature, and the sub-display area to indicate the temperature measurement time.

3.5 Audio Circuit

The audio circuit consists of the following parts:

  • Transistor Q2 (9015) resistance R12;
  • Capacitance C12;
  • Buzzer B1;

When the pin 11 of the single-chip microcomputer outputs low level, the transistor Q2 is saturated and turned on, and the buzzer generates an audible prompt.

IV Software Design

The program is written in 89C51 series C language and debugged on the single-chip simulation system. The program flow chart is shown in Figure 2.

block diagram of the main program

Figure 2. Block Diagram of Main Program

After power-on reset, initialize the DS18B20, input and output ports, timers, etc. Read the temperature value of the last measurement and storage from the lower temperature limit storage unit of DS18B20 and display it for 3 seconds. Start the internal timer T0 of the microcontroller to record the temperature measurement time.

Obtain the temperature value and correct the error. According to the communication protocol of DS18B20, the temperature signal is read from the sensor, the sign is distinguished, and the temperature value is obtained after calculation and processing. Then, add 0.2°C to the temperature value as the actual temperature, and correct the measurement error within the range of 25°C to 50°C to ±0.1°C.

Display of temperature. According to the communication protocol of the liquid crystal display, the temperature value and temperature measurement time are sent to the display for display. The main display area indicates the temperature, and the secondary display area indicates the temperature measurement time.

When the temperature measurement time reaches 5 minutes, the 11-pin of the single-chip microcomputer outputs a low-level control audio circuit to emit a prompt sound, and the current temperature is sent to the lower temperature storage unit of DS18B20 for registration, and sent to the secondary display area for display.

When the temperature measurement time reaches 6minutes, the 14-pin of the single-chip microcomputer outputs low level, and the thermometer automatically powers down.

V Conclusion

Compared with traditional thermometers, the DS18B20 Multi-function Electronic Thermometer designed in this blog has many advantages. The latter overcomes the difficulty of reading mercury thermometers and is easy to be broken and pollute the environment. At the same time, compared with simple electronic thermometers, multifunctional electronic thermometers also overcome the shortcomings of poor measurement accuracy. Because of its complete functions, stable performance, small size, light weight, low power consumption, and low price, it can be used as a general temperature measuring instrument and widely used in hospitals and homes.


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

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
Inquiry
Price:
Call
Inquiry
DS18B20-GG8 DS18B20-GG8 Company:Maxim Integrated Remark:Programmable Resolution 1-Wire Digital Thermometer Package:TO-92
N/A
In Stock:On Order
Inquiry
Price:
Call
Inquiry
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
Inquiry
Price:
1+: $4.25000
10+: $3.81700
25+: $3.60800
100+: $3.12710
500+: $2.66202
1000+: $2.57839
Inquiry
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
Inquiry
Price:
Call
Inquiry

Related Articles

AD603 Variable Gain Amplifier: Pinout, Datasheet, Circuit [FAQ]

Iggy 20 Nov 2020  6105

AD603 IntroductionThe AD603 is a low noise, voltage-controlled amplifier for use in RF and IF AGC systems. It provides accurate, pin-selectable gains of −11 dB to +31 dB with a bandwidth of 90 M...

Continue reading »

LM1875 Circuit: 22W Audio Amplifier

Mia 31 Jul 2020  697

I Description LM1875 is a power amplifier integrated block chip. Its superior performance and attractive tone have been accepted by many enthusiasts, and it was all the rage in the 1990s. LM1875 ado...

Continue reading »

CA3080 OTA : Pinout, Schematic Diagram, Application Circuit, Datasheet [FAQ]

Irene 16 Sep 2021  56

The CA3080 is an amplifier where the differential input voltage generates an output current.   Catalog Operational Transconductance Amplifier OverviewCAD  ModelCA3080 PinoutPin Confi...

Continue reading »

CR2430 3v Lithium Battery Overview [FAQ]

Mia 14 Apr 2021  704

CR2430 battery is non-rechargeable lithium 3.0 volts battery with a typical capacity of 270-300 mAh and physical dimensions of 24.5 x 3.0 mm.   This blog would cover CR2430's feature, specifica...

Continue reading »

LM324 Op Amp: A Basic Overview [Video]

Irene 7 Jan 2021  4097

LM324 is a operational amplifier (OP-AMP) that require a battery or single-polarity supply. This blog mainly introduce LM324 about its pinout, features, parameters, applications and other informatio...

Continue reading »

0 comment

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