Arduino Projects

Arduino DS18B20 digital Temperature Sensor Library, wiring & Programming

Description:

 

Arduino DS18B20- In this Tutorial, you will learn how to use Ds18b20 waterproof one-wire digital temperature sensor with Arduino and display the temperature in Celsius and Fahrenheit on a 16×2 LCD. So far I have covered different temperature sensors like

Dht11, which can monitor temperature and humidity

Bmp180 can monitor temperature, pressure and altitude and a K type thermocouple, which can measure temperatures up to 1000 Centigrade.  I will provide links at the end of this Article.


In today’s tutorial, we will cover

  1. Ds18b20 waterproof digital temperature sensor introduction
  2. Complete circuit diagram
  3. Programming and finally
  4. Testing

Let’s get started!!!!!

Amazon Links:

12v Adaptor:

Arduino Uno

Arduino Nano

DS18B20 one-wire digital temperature sensor:

16X2 LCD

Other Tools and Components:

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

DISCLAIMER:

Please Note: these are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!



About the DS18B20 Waterproof Temperature Sensor:

Arduino DS18B20

One-wire temperature sensors like the DS18B20 are devices that can measure temperature with a minimal amount of hardware and wiring.  These sensors use a digital protocol to send accurate temperature readings directly to your development board without the need for an analog to digital converter or other extra hardware. You can get one-wire sensors in different form factors like waterproof and high-temperature probes–these are perfect for sensing temperature in many different projects and applications.  And since these sensors use the one-wire protocol you can even have multiple of them connected to the same pin and read all their temperature values independently.


Arduino DS18B20

The DS18B20 Waterproof Temperature Sensor has three wires

  • The red wire is the VCC wire: the operating voltage is 3 to 5 volts. In my case, I will use 3.3 volts.
  • Yellow Wire is the Data wire: we usually connect a resistor between the data wire and VCC wire, I will explain this in the circuit diagram.
  • The black wire is the Ground wire. This wire is connected with the Nodemcu Esp8266 wifi module ground.

This temperature sensor is capable of measuring the temperature ranging from -55°C to 125°C

Arduino DS18B20 Circuit Diagram:

Arduino DS18B20

This schematic is designed in cadsoft eagle 9.1.0 version. If you want to learn how to make schematics and pcb then watch my tutorial.

Let’s start with the DS18b20 digital temperature sensor. As you can see a 330 ohm resistor is connected between the Vcc and data wires. You can also use a 4.7k resistor. The Vcc is connected with 3.3 volts. While the ground is connected with the Arduino’s ground.

As you can see ground from the Arduino is connected with pin number 1, 5 and pin number 16 of the LCD. 5v from the Arduino is connected with pin number 2 and pin number 15. The middle pin of the variable resistor or potentiometer is connected with pin number 3 of the LCD. while the other two pins are connected with the ground and 5v. Pin’s 4 to 7 of the Arduino are connected with pins D7 to D4 of the LCD.

Pin number 8 of the Arduino is connected with the enable pin of the LCD. Pin number 9 of the Arduino is connected with the RS pin of the LCD, watch my tutorial on 16×2 LCD if you want to learn the basics, like soldering, troubleshooting.

Libraries needed for the DS18B20:

Before you start the programming first off all, download the following libraries.

Arduino DS18B20 Library “onewire”

Download: onewire

Arduino DS18B20 Library “DallasTemperature”

Download: DallasTemperature

Arduino DS18B20 digital Temperature Sensor Programming:

#include <LiquidCrystal.h>
#include <OneWire.h>
#include <DallasTemperature.h>

#define ONE_WIRE_BUS 3 
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
 float Celcius=0;
 float Fahrenheit=0;
 
#define rs 9 
#define en 8 
#define d4 7 
#define d5 6  
#define d6 5 
#define d7 4

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup(void)
{
  
  Serial.begin(9600);
  sensors.begin();
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
 // Print a message to the LCD.
  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);
  delay(1000);
    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");
    
}

For the Program explanation watch video Tutorial given below. Don’t forget to subscribe my channel. Support my channel by liking and sharing the video.


Watch Video Tutorial:

Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button