Temperature Monitoring System With DS18B20 And Arduino

Hey guys, welcome back to Techatronic. In this article, we are going to make a Temperature Monitoring System with a DS18B20 waterproof temperature sensor and Arduino. If you like this project you can check more cool projects on Arduino. This system is capable of displaying the real-time readings of the temperature. We use an Arduino UNO microcontroller and I2C module with the 16×2 LCD here. The DS18B20 is a temperature sensor that generates its output according to the temperature it senses. You can check the interfacing of the DS18B20 Temperature sensor with Arduino. Also, check out our E-book on Arduino which contains amazing projects with well-explained procedures.

Working of the Temperature Monitoring System

The LCD displays the real values captured by the sensor in degrees and also in Fahrenheit. As the temperature sensor which we use is waterproof you can dip it into the water to capture the temperature.  You can also read the IoT weather monitoring system which is also made by us. You can check the value of the measured temperature on the LCD screen as well as on the serial monitor. Use the image given below to locate the serial monitor on your Arduino IDE.

 

Components Required

  • Arduino UNO
  • DS18B20 Temperature sensor
  • USB cable for uploading the code
  • I2C LCD module
  • 16×2 LCD
  • Jumper wires
  • Breadboard
  • 10K-ohm resistor
  • 10K Potentiometer

Circuit Diagram for the Project

  • With an I2C module

  • Without an I2C module

Temperature Monitoring System circuit

There are two circuit diagrams given here, you can make the project with or without using an I2C module. We provide you both the circuits and code. You have to make the connections according to the circuit you want to make. Connect the 5-volt pin of the Arduino to the VCC of the I2C module and positive wire of the DS18B20 Temperature sensor. Attach the GND pin of the Arduino to the GND of the I2C module and the negative wire of the DS18B20 Temperature sensor. Join the SDA pin of the I2C module to the analog-4 pin of the Arduino. Connect the SCL pin of the I2C module to the analog-5 pin of the Arduino. If you don’t know how to use the I2C module with 16×2 LCD then check it out first. If you are not using the I2C module then make the connections between LCD and Arduino as shown in the diagram. Earlier we discussed the interfacing of 16×2 LCD with Arduino, so you can take a reference from it.

Code for the Project

Note: Please upload the given code to the Arduino as it is. You have to install <OneWire.h>, <DallasTemperature.h>, <LiquidCrystal.h>, <wire.h>, <liquidcrystal_i2c.h> libraries to your Arduino IDE before compiling the sketch.

  • Code for using the I2C module
 //TECHATRONIC.COM  
  // OneWire LIBRARY   
  // https://github.com/PaulStoffregen/OneWire   
  // DallasTemperature LIBRARY   
  // https://github.com/milesburton/Arduino-Temperature-Control-Library   
  // I2C LIBRARY  
  //https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library  
 #include <OneWire.h>  
 #include <DallasTemperature.h>  
 #include <Wire.h>   
 #include <LiquidCrystal_I2C.h>  
 LiquidCrystal_I2C lcd(0x27,16,2);   
 #define ONE_WIRE_BUS 5  
 OneWire oneWire(ONE_WIRE_BUS);  
 DallasTemperature sensors(&oneWire);  
  float Celcius=0;  
  float Fahrenheit=0;  
 void setup(void)  
 {  
  Serial.begin(9600);  
  sensors.begin();  
  lcd.init();             
  lcd.backlight();  
  lcd.print("Temp Monitoring");  
 }  
 void loop(void)  
 {   
  sensors.requestTemperatures();   
  Celcius=sensors.getTempCByIndex(0);  
  Fahrenheit=sensors.toFahrenheit(Celcius);  
  Serial.print(" C ");  
  Serial.print(Celcius);  
  Serial.print(" F ");  
  Serial.println(Fahrenheit);  
   lcd.setCursor(0, 1);  
   lcd.print(Celcius);  
   lcd.setCursor(6, 1);  
   lcd.print("C");  
   lcd.setCursor(9, 1);  
   lcd.print(Fahrenheit);  
   lcd.setCursor(15, 1);  
   lcd.print("F");  
  delay(1000);  
 }  
  • Code for without I2C module
 //TECHATRONIC.COM  
  // OneWire LIBRARY   
  // https://github.com/PaulStoffregen/OneWire   
  // DallasTemperature LIBRARY   
  // https://github.com/milesburton/Arduino-Temperature-Control-Library   
 #include <OneWire.h>  
 #include <DallasTemperature.h>  
 #include "LiquidCrystal.h"  
 LiquidCrystal lcd(5,6,7,8,9,10);  
 #define ONE_WIRE_BUS 5  
 OneWire oneWire(ONE_WIRE_BUS);  
 DallasTemperature sensors(&oneWire);  
  float Celcius=0;  
  float Fahrenheit=0;  
 void setup(void)  
 {  
  Serial.begin(9600);  
  sensors.begin();  
  lcd.begin(16,2);  
  lcd.print("Temp Monitoring");  
 }  
 void loop(void)  
 {   
  sensors.requestTemperatures();   
  Celcius=sensors.getTempCByIndex(0);  
  Fahrenheit=sensors.toFahrenheit(Celcius);  
  Serial.print(" C ");  
  Serial.print(Celcius);  
  Serial.print(" F ");  
  Serial.println(Fahrenheit);  
   lcd.setCursor(0, 1);  
   lcd.print(Celcius);  
   lcd.setCursor(6, 1);  
   lcd.print("C");  
   lcd.setCursor(9, 1);  
   lcd.print(Fahrenheit);  
   lcd.setCursor(15, 1);  
   lcd.print("F");  
  delay(1000);  
 }  

The Temperature Monitoring System Look Like

Temperature Monitoring System

We hope that you understand the project properly and please try to make it once. If you are facing any errors do inform us in the comments section below. Please read more Tutorials on Arduino and Raspberry Pi.

HAPPY LEARNING!

Leave a Comment