Digital Thermometer With Arduino & DS18B20

76,143

44

30

Introduction: 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.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: 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

Step 3: Connecting DS18B20 Temperature Sensor

Step 4: 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) {
Serial.begin(9600);
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("Rahul Mitra");
}

void loop(void) {
float temperature = getTemp();
Serial.println(temperature);
  lcd.setCursor(0, 1);
    lcd.print("Temp : ");
    lcd.print(temperature);
    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 ( !ds.search(addr)) {
//no more sensors on chain, reset search
ds.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.reset();
ds.select(addr);
ds.write(0x44,1); // start conversion, with parasite power on at the end

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


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

ds.reset_search();

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

Step 7: See LIVE

http://www.youtube.com/watch?v=7718FODdtio&list=UUY916I6z4Y3QQhzjHsIhR8w
Arduino Contest

Participated in the
Arduino Contest

1 Person Made This Project!

Recommendations

  • Backyard Contest

    Backyard Contest
  • Silly Hats Speed Challenge

    Silly Hats Speed Challenge
  • Arduino Contest 2020

    Arduino Contest 2020

30 Discussions

0
BillM189
BillM189

3 years ago

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.

0
abolfazlmirashrafi
abolfazlmirashrafi

3 years ago

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.

0
Rahul Mitra
Rahul Mitra

Reply 3 years ago

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.

0
amaretić1
amaretić1

4 years ago on Introduction

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?

0
Rahul Mitra
Rahul Mitra

Reply 4 years ago on Introduction

To patch the problem, just open displayshield4d.cpp and replace

#include "WProgram.h"

by this :

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

0
amaretić1
amaretić1

Reply 4 years ago on Introduction

hmm, how to open displayshield4d.cpp ?

im total noob :D

0
Rahul Mitra
Rahul Mitra

4 years ago on Step 5

http://www.mediafire.com/view/pyhtnvnovrdx2dq/code.ino

0
EnéasB
EnéasB

4 years ago on Step 5

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

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

0
Rahul Mitra
Rahul Mitra

Reply 4 years ago on Introduction

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

0
vernkle
vernkle

5 years ago on Introduction

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?

0
Rahul Mitra
Rahul Mitra

Reply 4 years ago on Introduction

******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);

Serial.println(temperature);
lcd.setCursor(0, 1);
lcd.print("Temp : ");
lcd.print(tempinf);

lcd.print(" *F");
delay(100);

-------------------------------------------------------------

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

0
Rahul Mitra
Rahul Mitra

Reply 5 years ago

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

0
MaharshiP
MaharshiP

5 years ago on Introduction

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.

0
Rahul Mitra
Rahul Mitra

Reply 5 years ago on Introduction

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...????

0
Rahul Mitra
Rahul Mitra

Reply 5 years ago on Introduction

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

0
RajaV
RajaV

5 years ago on Introduction

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

0
Rahul Mitra
Rahul Mitra

Reply 5 years ago on Introduction

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

0
rexa6969
rexa6969

5 years ago on Introduction

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