Interfacing Multiple DS18B20 Temperature Sensors to Arduino

Interfacing Multiple DS18B20 Temperature Sensors to Arduino (Last Updated On: February 22, 2019)

Interfacing Multiple DS18B20 Temperature Sensors to Arduino:

In this project we will learn about Interfacing Multiple DS18B20 Temperature Sensors to Arduino. Simply we will connect Multiple DS18B20 Temperature Sensors to Arduino and display the temperature values of all the sensors in degree celsius or Fahrenheit. Only one digital pin of Arduino is required to connect several temperature sensor. We can connect maximum of 1024 sensors using I2C Protocol. But here i have shown connecting 3 DS18B20 Temperature Sensors to Arduino.



The DS18B20 temperature sensor is a 1-wire digital temperature sensor. This comes with sealed package lets precisely measure temperatures in wet environments with a simple 1-Wire interface. It communicates on common bus. It means it can connect several devices and read their values using just one digital pin of the Arduino.


DS18B20 Waterproof Digital Temperature Sensor:

This is a pre-wired and waterproofed version of the DS18B20 sensor. Handy for when you need to measure something far away, or in wet conditions. The Sensor can measure the temperature between -55 to 125°C (-67°F to +257°F). The cable is jacketed in PVC.

Because it is digital, there is no any signal degradation even over long distances. These 1-wire digital temperature sensors are fairly precise, i.e ±0.5°C over much of the range. It can give up to 12 bits of precision from the onboard digital-to-analog converter. They work great with any microcontroller using a single digital pin.

Interfacing Multiple DS18B20 Temperature Sensors to Arduino

The only downside is they use the Dallas 1-Wire protocol, which is somewhat complex, and requires a bunch of code to parse out the communication. We toss in a 4.7k resistor, which is required as a pullup from the DATA to VCC line when using the sensor.


Components Required:

1. Arduino UNO Board
2. Multiple DS18B20 Waterproof Temperature Sensor (Buy Online from Amazon)
3. 16*2 LCD Display
4. 4.7K Resistor
5. Breadboard
6. Connecting Jumper Wires



Circuit Diagram & Connections:

Interfacing Multiple DS18B20 Temperature Sensors to Arduino

Connect pin 11,12,5,4,3,2 of Arduino to pin 4,6,11,12,13,14 of LCD.

Connect VDD pin of DS18B20 to 5V and GND Pin to Ground. Connect the data pin of all DS18B20 to digital pin 9 of Arduino and also to 4.7K Resistor (Connect other end of 4.7K Resistor to 5V) as shown in the figure below.


Hardware & Design:

By connecting all the sensors to one digital pin of Arduino we have simply designed Digital Thermometer for measuring multiple temperature. So the below picture tells how we have Interfaced Multiple DS18B20 Temperature Sensors to Arduino and how the temperature is being displayed.



Source Code/Program:

For interfacing Multiple DS18B20 Temperature Sensors to Arduino you need two different library
1. Download 1 Wire Library
2. Download Dallas Temperature Library



Working of Multiple DS18B20 Temperature Sensors with Arduino:

The DS18B20 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.

Each and every DS18B20 has particular device address in HEX format like { 0x28, 0x1D, 0x39, 0x31, 0x2, 0x0, 0x0, 0xF0 }. So the program is designed on the basis of reading temperature from particular device address. So first the Arduino scans the number of sensors. Let us assume 3 sensors are connected here. So it will just displays values of 3 different reading. If more sensors are connected, the reading will switch to multiple values. The value of temperature read by each sensors is displayed after interval of 2 seconds as Sensor Number 1 Temperature, Sensor Number 2 Temperature and upto the value of number of sensor connected.

To learn more about the code you can go through the video below. Or simply read the code as I have commented each and every thing about each line in code.



Video Tutorial & Explanation:

Recommended For You

10 Comments

  1. Wonderful project…. I have seen several months ago (don’t remember where..) a similar project but displaying the indoor and few seconds after the outdoor temperatures on a seven segment display since it is designated to be installed in a living room.
    Is it possible to modify the current project as described above ?

  2. I have built this circuit as a test. It works great. The one thing that I cannot figure out is how to make the LCD display Celcius and Fahrenheit at the same time. I was able to figure out the code to display both temps on the serial monitor and My serial monitor shows both temps. I am new to coding and cannot make the code work to show the same information on the LCD. Is there a “quick” explanation of the code to make the LCD Display both temps? Thank You in advance.

    1. Use this formula to convert F to C
      C= (F-32)/1.8

      Use lcd.print command to display the required temperature. Learn about lcd arduino interfacing code more from google.

      If u want to display both temperature at the same time.
      I recomend u to use 20×4 LCD.

      1. I have the 20 x 4 display, that is not an issue. I know the math for the conversion. It is the code to make it happen on this particular sketch. This is different code than the other sketches I have done that display both C and F. I will do some more research. Thanks for the reply!

        MWL

Ask A Question .......

Close