Introduction: Digital Thermometer With Arduino & DS18B20

Picture of Digital Thermometer With Arduino & DS18B20

Simply create a digital thermometer with can tell you the current room temperature on a LCD screen. This is a beginners project.

Apparatus that you need:
1. Arduino UNO R3
2. DS18B20 temperature sensor.
3. 16X2 LCD display.
4. Connecting wires.
5. Project board. 

Now lets make digital thermometer.....

This is a Atmega168 pinouts for arduino. Just skip this if you wat to make this thermometer with your arduino.

Step 1: Make Arduino on Breadboard.

Picture of Make Arduino on Breadboard.

Creating arduino on a breaboard is very easy. Now step by step wiring procedure is given below:
1. Pin 7  -> +5V
2. Pin8   -> GND
3. Pin9 -> Crystal -> 22pF capacitor -> GND
4. Pin10-> Crystal -> 22pF capacitor -> GND
5. pin 22 -> GND
6. Pin21 & Pin20 -> +5V
7. Pin1-> 10K registor to GND + Push button to +5V

Now you are ready.................

Step 2: Connecting LCD

Picture of Connecting LCD

Step 3: Connecting DS1307 Temperature Sensor

Picture of Connecting DS1307 Temperature Sensor

Step 4: Preparing the Circuit.

Picture of Preparing the Circuit.

Connect the LCD with the atmega or arduino according to the default LCD example on the arduino IDE.

Now connect DS1307 DATA bus to the DIGITAL PIN 7 (Atmega pin 13)

Step 5: Arduino CODE

#include <OneWireTempSensor.h>

#include <OneWire.h>
#include <LiquidCrystal.h>
int DS18S20_Pin = 7; //DS18S20 Signal pin on digital 7 by rahulmitra
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
//Temperature chip i/o
OneWire ds(DS18S20_Pin); // on digital pin 7 by rahulmitra

void setup(void) {
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("Rahul Mitra");

void loop(void) {
float temperature = getTemp();
  lcd.setCursor(0, 1);
    lcd.print("Temp : ");
    lcd.print(" *C");
delay(100); //just here to slow down the output so it is easier to read


float getTemp(){
//returns the temperature from one DS18S20 in DEG Celsius

byte data[12];
byte addr[8];

if ( ! {
//no more sensors on chain, reset search
return -1000;

if ( OneWire::crc8( addr, 7) != addr[7]) {
Serial.println("CRC is not valid!");
return -1000;

if ( addr[0] != 0x10 && addr[0] != 0x28) {
Serial.print("Device is not recognized");
return -1000;

ds.write(0x44,1); // start conversion, with parasite power on at the end

byte present = ds.reset();;
ds.write(0xBE); // Read Scratchpad

for (int i = 0; i < 9; i++) { // we need 9 bytes
data[i] =;


byte MSB = data[1];
byte LSB = data[0];

float tempRead = ((MSB << 8) | LSB); //using two's compliment
float TemperatureSum = tempRead / 16;

return TemperatureSum;


Step 6: Finally You Have Done

Picture of Finally You Have Done

Step 7: See LIVE


BillM189 (author)2017-02-21

If you get an error trying to compile this code, remove the first line "#include <OneWireTempSensor.h>" because this isn't needed. #include <OneWire.h> does the very same thing.

abolfazlmirashrafi (author)2016-10-15

hi.thanks very lot for this project.
I have a question:
how can i save the log for a month which data save per hour a day.
i mean save the log hour to hour for 1 month.and so i can draw the graph of these logs.
please help me.thanks a lot master.

There are two ways to do that...
1. web server
2. SD Card.

To do this with Web server, you need a web server and Ethernet shield for the arduino. Arduino will send the data only and a server side script will process the data and post the data in MySQL data base with current time stamp. And the benefit of this method is you can monitor real time data in web browser also real time graph.

And to do this with SD card you need and micro sd card and card shield and a clock module. then you can find example code in Arduino IDE. Than edit it and save the file name as "xxxx.csv". and write the data with (,) separated method. It will save an MS excel file in the sd card. And remove the card and connect it to pc with card reader. and open it in excel. and process it in excel.

*** Sorry for bad english.

amaretić1 (author)2015-08-29

i have problems:

Arduino: 1.6.5 (Windows 7), Board: "Arduino/Genuino Uno"

In file included from sketch_aug29c.ino:1:0:

C:\Users\Maretic\Documents\Arduino\libraries\OneWireTempSensor/OneWireTempSensor.h:26:22: fatal error: WProgram.h: No such file or directory

#include <WProgram.h>


compilation terminated.

Error compiling.

This report would have more information with

"Show verbose output during compilation"

enabled in File > Preferences.

Can you help me?

Rahul Mitra (author)amaretić12015-08-30
To patch the problem, just open displayshield4d.cpp and replace

#include "WProgram.h"

by this :

#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#include "WProgram.h"

amaretić1 (author)Rahul Mitra2015-08-30

hmm, how to open displayshield4d.cpp ?

im total noob :D

Rahul Mitra (author)amaretić12015-08-31

download this two files. Replace it with Arduino/libraries/liquidCristal/src/

Let me know if this works or not...

Rahul Mitra (author)2015-08-14

EnéasB (author)2015-08-13

Hi, Do you have a *.ino version to send me? Thanks.

srijan.bhar.1995 (author)2015-06-22

please tell the EXACT TEMPERATURE SENSOR name... And please upload the circuit DIAGRAM of this project...

Circuit was given there .... Just connect the digital data pin to the PIN 7 of the arduino uno.................

vernkle (author)2014-06-21

Is there a way to display Fahrenheit on the screen? I know that you can multiply the Celsius by 1.8 then add 32 to convert it. Can I apply this in the code?

Rahul Mitra (author)vernkle2015-06-07

******This is not tested.. So please let me know whether it works or not.

>>>> change little bit in this portion----------


void loop(void) {

float temperature = getTemp();

float tempinf=(temperature*1.8+32);

lcd.setCursor(0, 1);
lcd.print("Temp : ");

lcd.print(" *F");


******This is not tested.. So please let me know whether it works or not.

Rahul Mitra (author)vernkle2014-07-01

Hmm you can.... Right now I can't test the code... I will try it then reply tomorrow. ..

HLModTech made it! (author)2015-03-16

Great code! Had been tinkering all morning. This solved it!

Rahul Mitra (author)HLModTech2015-03-19

You need to adjust your display brightness & Contrast to make it more clear.....

Rahul Mitra (author)HLModTech2015-03-18

Thanks MIKE....

MaharshiP (author)2015-03-18

Rahul, Very nice project. I would like to know something if you can.

I have TAIE digital temperature controller which I am using for temperature controlling in a specified range say 30 +/- 2 C. I want to connect it with arduino to give an alarm if it gets out of range and even send or call on a phone number. I know, for that I would required Arduino UNO, GSM module and a buzzer but don't know the arrangement. Pls. help if possible.

Rahul Mitra (author)MaharshiP2015-03-18

it would be very easy if you tell me about TAIE. Its new to me.... Does it have any output pin that could be connected to arduino...????

Rahul Mitra (author)MaharshiP2015-03-18

Thanks for comment.... Please give me some time, i will reply you as soon as possible.
Thanks again...

RajaV (author)2015-01-05

can you please let me know how to convert to Fahrenheit ? and where should i include the code ?.

Rahul Mitra (author)RajaV2015-03-17

I am sorry that i didnt noticed your comment... Have u solved your problem? If not then let me know.. I will help you.

rexa6969 (author)2014-11-04

Why it's show Temp : -1000. 00 on the screen? I'm using Arduino uno R3

Rahul Mitra (author)rexa69692014-11-25

I dont know why its not working, Try this set up....

we will use the 2 wire method. Simply connect both the GND and VDD pins to 0V (yes both). Then connect the DQ pin to pin 2 on the Arduino board (can be any Arduino digital pin)

A 4K7 ohm pullup resistor is required on the DQ pin to pull it up to 5V

benking1234 (author)Rahul Mitra2014-11-26

I had this error when i forgot to add the power to the sensor, Thanks for the tutorial

jmay21 (author)2014-02-22

Great Instructable, thanks! Would it be possible to connect the display using an LCM1 602 controller, and If so, which pins on the Arduino would I hook it up to?

Guxtdu (author)2013-09-30

Nice Work
can you help to add a Second DS18B20 Sensor ?

Rahul Mitra (author)Guxtdu2013-10-21

Yes... I can.........

Guxtdu (author)Rahul Mitra2013-10-21

hy i havae already soved teh problem with the second Sensor


WWC (author)2013-08-13

In order for me to learn everything that i can i would like to know how to get a temp reading out of an DS1307 Real Time Clock module. At one point you show an DS18B20 which is a temp sensor but it is not shown in the BOM. Looks like there might be 2 projects crossed with each other.

Rahul Mitra (author)WWC2013-09-12

Sorry thats my fault. This is DS18B20 temperature sensor.

Palmerfarmer (author)2013-09-11

Very new to this, how easy would it be to add 2 or more DS18B20's and get them to display?
i already have them connected on the same 'wire'

Rahul Mitra (author)Palmerfarmer2013-09-12

Actually i didn`t try that, Because i have only 1 DS18B20 .... But I think it`s not so hard..

About This Instructable




More by Rahul Mitra:Webcam As Night Vision CameraAnti-Theft Alarming SystemHomemade DVI-I to DVI-D converter
Add instructable to: