1

member

Easy Basics: Project 055a DS18B20 one wire digital temperature sensor

of Acoptex.com in UNO

Basics: Project 055a

Project name: DS18B20 one wire digital temperature sensor

Tags: Arduino Uno, Arduino, one wire digital temperature sensor, DS18B20, Maxim, Dallas, Waterproof DS18B20 digital temperature sensor

Attachments: library1, library2 and onesensorsketch ; 1wireaddressfindersketch; severalsensorssketch

In this project, you needed these parts (Dear visitors. You can support our project buy clicking on the links of parts and buying them or donate us to keep this website alive. Thank you):

1.Arduino Uno R3 (you can also use the other version of Arduino)

2.  DS18B20 one wire digital temperature sensor waterproof or not 1pc

3.Arduino IDE ( you can download it from here  )

4.Jumper cables F-M, M-M

5.Resistor 1 pc (4.7KOhm (you can use similar values))

6.Breadboard half size or small size 1 pc

General

We will learn how to connect DS18B20 one wire digital temperature sensor to Arduino board and use it.

Understanding the DS18B20 one wire digital temperature sensor

The one wire Digital Temperature Sensor - DS18B20 from Maxim (formerly Dallas) is a great chip for measuring temperature and can be used in many data-logging and temperature control DIY projects. Usable with 3.0-5.0V systems.

The DS18B20 digital thermometer provides 9-bit to 12-bit Celsius temperature measurements and has an alarm function with nonvolatile user-programmable upper and lower trigger points. 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 ("parasite power"), eliminating the need for an external power supply.

Each DS18B20 has a unique 64-bit serial code, which allows multiple DS18B20s to function on the same 1-Wire bus. Thus, it is simple to use one microprocessor to control many DS18B20s distributed over a large area. Applications that can benefit from this feature include HVAC environmental controls, temperature monitoring systems inside buildings, equipment, or machinery, and process monitoring and control systems.

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

Applications/Uses:

  • Consumer Products
  • Industrial Systems
  • Thermally Sensitive Systems
  • Thermometers
  • Thermostatic Controls

The DS18B20 temperature sensor is also available as pre-wired and waterproofed. Handy for when you need to measure something far away, or in wet conditions.

DS18B20 Resolution

DS18B20 has four selectable resolutions that range from 9 to 12.   While it may seem nice to have a very detailed response or ‘precise’ measurement, there is a trade off.  Specifically, the higher the resolution, the more time its going to take to make the measurement.   See the table below.

Normal Power mode VS Parasite Power Mode

See the two ways of wiring your sensors for both methods of powering the sensors.

  • For larger networks of sensors (more than 5), using smaller resistors should be considered, for example 1.6 KOhm or even less.
  • The large amounts of sensors (more than 5) in the same network can cause issues (colliding data), and for that purpose an additional resistor of 100 - 120 Ohm should be added between the data line to the Arduino and the data pin of the sensor, for each sensor.

The DS18B20 Digital Temperature sensor allows you to set multiple in parallel. When doing this, the OneWire library will read all sensors.

You can find the DS18B20 datasheet here.

Signals and connections of the DS18B20 one wire digital temperature sensor

SIG (or S or DQ or out or DATA) - digital signal. Can be connected to a (digital) pin of your choice on the Arduino board

VCC (or VDD or +) - power supply. Can be connected to +5VDC or +3.3VDC pin of Arduino board.

GND (or -) - ground. Connected to Arduino board GND pin.

Wiring

A 4.7KOhm resistor is required as a pullup from the DATA to VCC line when using the sensor. 

The sensor can operate in two modes:

1. Normal Power mode: 3-wire connection required.

2. Parasitic Power Mode: 2-wire connection required, the data and ground. The sensor derives its power from the data line. The downside of parasite mode is that you should limit the number of sensors and the wires should not be too long! Plenty of strange results have been report when using Parasite mode. We cannot recommend Parasite mode for a reliable setup.

You can read the temperature of more than one sensor at the same time using just one digital Arduino pin. For that, you just need to connect together all the DQ pins to any digital Arduino pin.

Step by Step instruction

1.To get readings from one sensor

  1. Do wiring.
  2. Open Arduino IDE.
  3. Plug your Adruino Uno board into your PC and select the correct board and com port
  4. Verify and upload the onesensorsketch to your Adruino Uno
  5. Open the Serial Monitor at a baud rate of 9600.
  6. You will see the temperature in Celsius and Fahrenheit.

2.To get the address of your 1-Wire device

Since these sensors are digital, they do have a serial number (address), which can be used to identify each of them.

  1. Do wiring.
  2. Open Arduino IDE.
  3. Plug your Adruino Uno board into your PC and select the correct board and com port
  4. Verify and upload the 1wireaddressfindersketch to your Adruino Uno
  5. Open the Serial Monitor at a baud rate of 9600.
  6. Press the reset button on your Arduino and you should see the address of your 1-Wire device.

2.To get readings from several sensors

  1. Do wiring.
  2. Open Arduino IDE.
  3. Plug your Adruino Uno board into your PC and select the correct board and com port
  4. Verify and upload the severalsensorssketch to your Adruino Uno
  5. Open the Serial Monitor at a baud rate of 9600.
  6. You will see the temperature in Celsius and Fahrenheit. of each sensor.

Summary

We learnt how to connect DS18B20 one wire digital temperature sensor to Arduino board and use it.

Code

Serial.println(sensors.getTempCByIndex(0)); returns temperature in Celsius scale

Serial.println(sensors.getTempFByIndex(0)); returns temperature in Fahrenheit scale

Why "byIndex"? You can have more than one IC on the same bus. 0 refers to the first IC on the wire! Try to add a second sensor and include the following command in your code: Serial.println(sensors.getTempFByIndex(1));

Library

  • All libraries attached on the begining of the project description
  • Dallas Temperature Control library. Download, unzip  and add to libraries in our PC, for example C:\Users\toshiba\Documents\Arduino\libraries. This link you can find in Preferences of Adruino IDE program which installed in your PC. You can read more about it here.
  • One wire library. Download, unzip  and add to libraries in our PC, for example C:\Users\toshiba\Documents\Arduino\libraries. This link you can find in Preferences of Adruino IDE program which installed in your PC. You can read more about it here.

Sketch

  • See attachments on the begining of this project


Other projects of Acoptex.com

« Go back to category
Is this project fake? Report it!   
Recommend to a friend
Published at 09-01-2018
Viewed: 719 times