DS18B20 Thermometer using Arduino & 4 Digits 7 Segment Display
Design DS18B20 Based Thermometer using Arduino & 4 Digits 7 Segment Display. Interface Arduino with DS18B20 Digital Waterproof Temperature Sensor in °C & °F
- Suitable forB.Tech/Diploma Arduino students
- Build time1-2 weeks
- LevelBeginner
- Available atAjvika Labs, Kakinada
About this project
DS18B20 Based Thermometer using Arduino & 4 Digits 7 Segment Display:
In this project, we will learn how to
design a DS18B20 Based Thermometer using Arduino & 4 Digits 7 Segment Display
. Simply we will
interface Arduino with DS18B20 Digital Waterproof Temperature Sensor
and display the temperature values in degree celsius on Common Cathode Display.
The DS18B20 temperature sensor is a 1-wire digital temperature sensor. This comes with a sealed package lets precisely measure temperatures in wet environments with a simple 1-Wire interface. It communicates on a common bus. It means it can connect several devices and read their values using just one digital pin of the Arduino.
Check some of the posts related to DS18B20 here:
Temperature Meter using DS18B20 OLED Display & Arduino
Digital Thermometer Using Arduino & DS18B20 Temperature Sensor
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.
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 the VCC line when using the sensor.
LM35 vs DS18B20:
A DS18B20 is factory calibrated to output the right temperature. An LM35 is factory calibrated for voltage (not temperature), and the Arduino has to convert this to temperature.
LM35 is an analog temperature sensor, so any distortion in input can rapidly affect the reading. But DS18B20 is a digital temperature sensor, so input doesn’t affect the output reading.
If the long wire is used for measuring the temperature at a certain distance, wire length can deviate the value in analog LM35 Sensor. But DS18B20 is a digital sensor, there is no effect in any output value.
LM35 can measure the temperature between −55°C to 150°C but DS18B20 can measure between −50°C to 125°C.
1 digital output pin of Arduino can be used to connect multiple DS18B20 but it doesn’t happen with LM35.
Components Required for Digital Thermometer:
Arduino UNO Board
DS18B20 Waterproof Temperature Sensor
Common Anode 7 Segment Display – 4
7HC595 IC (8 bit Shift Resistor)
4.7K Resistor
330 ohm Resistor – 8
Breadboard
Connecting Jumper Wires
Circuit Diagram & Connections:
Connect the VDD pin of DS18B20 to 5V and GND Pin to Ground. Connect its data pin to digital pin 2 of Arduino and also to 4.7K Resistor (Connect another end of 4.7K Resistor to 5V) as shown in the figure below.
Working of the Project:
The
DS18B20 Digital Thermometer
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. We have also used 74HC595 IC here. To learn more about 74HC595 IC, go through
74HC595 Arduino
tutorial.
Source Code/Program for Displaying Temperature in °Celsius:
To design
DS18B20 Based Thermometer using Arduino & 4 Digits 7 Segment Display
& to display temperature in degree Celsius you need two different library
Download 1 Wire Library
Download Dallas Temperature Library
Add these to the library file to Arduino IDE and then simply compile and upload the code.
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 2
OneWire
oneWire
(
ONE_WIRE_BUS
)
;
DallasTemperature
sensors
(
&
oneWire
)
;
DeviceAddress
insideThermometer
;
const
int
ledPin
=
;
// LED connected to digital pin 13
const
int
latchPin
=
;
// Pin connected to ST_CP of 74HC595
const
int
clockPin
=
;
// Pin connected to SH_CP of 74HC595
const
int
dataPin
=
;
// Pin connected to DS of 74HC595
const
int
digitPins
[
]
=
{
}
;
//pins to control the 4 common anode pins of display
const
byte
digit
[
]
=
//seven segment digit bits + blank + minus
{
B00111111
//0
B00000110
//1
B01011011
//2
B01001111
//3
B01100110
//4
B01101101
//5
B01111101
//6
B00000111
//7
B01111111
//8
B01101111
//9
B00000000
//Blank
B01000000
//-
}
;
int
digitBuffer
[
]
=
{
}
;
int
digitScan
=
;
int
soft_scaler
=
;
float
tempC
tempF
;
int
tmp
;
boolean
sign
=
false
;
void
setup
(
)
{
TCCR2A
=
;
TCCR2B
=
(
<<
CS21
)
;
TIMSK2
=
(
<<
TOIE2
)
;
TCNT2
=
;
pinMode
(
ledPin
OUTPUT
)
;
for
(
int
i
=
;
i
<
;
i
++
)
{
pinMode
(
digitPins
[
i
]
OUTPUT
)
;
}
pinMode
(
latchPin
OUTPUT
)
;
pinMode
(
clockPin
OUTPUT
)
;
pinMode
(
dataPin
OUTPUT
)
;
sensors
begin
(
)
;
sensors
getAddress
(
insideThermometer
)
;
}
ISR
(
TIMER2_OVF_vect
)
{
soft_scaler
++
;
if
(
soft_scaler
==
)
{
refreshDisplay
(
)
;
soft_scaler
=
;
}
}
;
void
refreshDisplay
(
)
{
for
(
byte
k
=
;
k
<
;
k
++
)
{
digitalWrite
(
digitPins
[
k
]
LOW
)
;
}
digitalWrite
(
latchPin
LOW
)
;
shiftOut
(
dataPin
clockPin
MSBFIRST
B11111111
)
;
digitalWrite
(
latchPin
HIGH
)
;
delayMicroseconds
(
)
;
digitalWrite
(
digitPins
[
digitScan
]
HIGH
)
;
digitalWrite
(
latchPin
LOW
)
;
if
(
digitScan
==
)
{
shiftOut
(
dataPin
clockPin
MSBFIRST
~
(
digit
[
digitBuffer
[
digitScan
]
]
B10000000
)
)
;
}
else
{
shiftOut
(
dataPin
clockPin
MSBFIRST
~
digit
[
digitBuffer
[
digitScan
]
]
)
;
}
digitalWrite
(
latchPin
HIGH
)
;
digitScan
++
;
if
(
digitScan
>
)
digitScan
=
;
}
void
loop
(
)
{
digitalWrite
(
ledPin
HIGH
)
;
sensors
requestTemperatures
(
)
;
tempC
=
sensors
getTempC
(
insideThermometer
)
;
tmp
=
int
(
tempC*
)
;
if
(
tempC
<
)
{
sign
=
true
;
tmp
=
abs
(
tmp
)
;
}
else
{
sign
=
false
;
}
if
(
int
(
tmp
)
/
1000
==
)
{
digitBuffer
[
]
=
;
if
(
sign
)
{
digitBuffer
[
]
=
;
}
}
else
{
digitBuffer
[
]
=
int
(
tmp
)
/
1000
;
}
if
(
int
(
tmp
)
/
1000
==
&&
(
int
(
tmp
)
%
1000
)
/
==
)
{
digitBuffer
[
]
=
;
if
(
sign
)
{
digitBuffer
[
]
=
;
digitBuffer
[
]
=
;
}
}
else
{
digitBuffer
[
]
=
(
int
(
tmp
)
%
1000
)
/
;
}
digitBuffer
[
]
=
(
int
(
tmp
)
%
)
/
;
digitBuffer
[
]
=
(
int
(
tmp
)
%
)
%
;
digitalWrite
(
ledPin
LOW
)
;
delay
(
)
;
}
Source Code/Program for Displaying Temperature in °Fahrenheit:
To design
DS18B20 Based Thermometer using Arduino & 4 Digits 7 Segment Display
& to display temperature in degree Fahrenheit you need two different library
Download 1 Wire Library
Download Dallas Temperature Library
Add these to the library file to Arduino IDE and then simply compile and upload the code.
In this project, we will learn how to
design a DS18B20 Based Thermometer using Arduino & 4 Digits 7 Segment Display
. Simply we will
interface Arduino with DS18B20 Digital Waterproof Temperature Sensor
and display the temperature values in degree celsius on Common Cathode Display.
The DS18B20 temperature sensor is a 1-wire digital temperature sensor. This comes with a sealed package lets precisely measure temperatures in wet environments with a simple 1-Wire interface. It communicates on a common bus. It means it can connect several devices and read their values using just one digital pin of the Arduino.
Check some of the posts related to DS18B20 here:
Temperature Meter using DS18B20 OLED Display & Arduino
Digital Thermometer Using Arduino & DS18B20 Temperature Sensor
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.
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 the VCC line when using the sensor.
LM35 vs DS18B20:
A DS18B20 is factory calibrated to output the right temperature. An LM35 is factory calibrated for voltage (not temperature), and the Arduino has to convert this to temperature.
LM35 is an analog temperature sensor, so any distortion in input can rapidly affect the reading. But DS18B20 is a digital temperature sensor, so input doesn’t affect the output reading.
If the long wire is used for measuring the temperature at a certain distance, wire length can deviate the value in analog LM35 Sensor. But DS18B20 is a digital sensor, there is no effect in any output value.
LM35 can measure the temperature between −55°C to 150°C but DS18B20 can measure between −50°C to 125°C.
1 digital output pin of Arduino can be used to connect multiple DS18B20 but it doesn’t happen with LM35.
Components Required for Digital Thermometer:
Arduino UNO Board
DS18B20 Waterproof Temperature Sensor
Common Anode 7 Segment Display – 4
7HC595 IC (8 bit Shift Resistor)
4.7K Resistor
330 ohm Resistor – 8
Breadboard
Connecting Jumper Wires
Circuit Diagram & Connections:
Connect the VDD pin of DS18B20 to 5V and GND Pin to Ground. Connect its data pin to digital pin 2 of Arduino and also to 4.7K Resistor (Connect another end of 4.7K Resistor to 5V) as shown in the figure below.
Working of the Project:
The
DS18B20 Digital Thermometer
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. We have also used 74HC595 IC here. To learn more about 74HC595 IC, go through
74HC595 Arduino
tutorial.
Source Code/Program for Displaying Temperature in °Celsius:
To design
DS18B20 Based Thermometer using Arduino & 4 Digits 7 Segment Display
& to display temperature in degree Celsius you need two different library
Download 1 Wire Library
Download Dallas Temperature Library
Add these to the library file to Arduino IDE and then simply compile and upload the code.
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS 2
OneWire
oneWire
(
ONE_WIRE_BUS
)
;
DallasTemperature
sensors
(
&
oneWire
)
;
DeviceAddress
insideThermometer
;
const
int
ledPin
=
;
// LED connected to digital pin 13
const
int
latchPin
=
;
// Pin connected to ST_CP of 74HC595
const
int
clockPin
=
;
// Pin connected to SH_CP of 74HC595
const
int
dataPin
=
;
// Pin connected to DS of 74HC595
const
int
digitPins
[
]
=
{
}
;
//pins to control the 4 common anode pins of display
const
byte
digit
[
]
=
//seven segment digit bits + blank + minus
{
B00111111
//0
B00000110
//1
B01011011
//2
B01001111
//3
B01100110
//4
B01101101
//5
B01111101
//6
B00000111
//7
B01111111
//8
B01101111
//9
B00000000
//Blank
B01000000
//-
}
;
int
digitBuffer
[
]
=
{
}
;
int
digitScan
=
;
int
soft_scaler
=
;
float
tempC
tempF
;
int
tmp
;
boolean
sign
=
false
;
void
setup
(
)
{
TCCR2A
=
;
TCCR2B
=
(
<<
CS21
)
;
TIMSK2
=
(
<<
TOIE2
)
;
TCNT2
=
;
pinMode
(
ledPin
OUTPUT
)
;
for
(
int
i
=
;
i
<
;
i
++
)
{
pinMode
(
digitPins
[
i
]
OUTPUT
)
;
}
pinMode
(
latchPin
OUTPUT
)
;
pinMode
(
clockPin
OUTPUT
)
;
pinMode
(
dataPin
OUTPUT
)
;
sensors
begin
(
)
;
sensors
getAddress
(
insideThermometer
)
;
}
ISR
(
TIMER2_OVF_vect
)
{
soft_scaler
++
;
if
(
soft_scaler
==
)
{
refreshDisplay
(
)
;
soft_scaler
=
;
}
}
;
void
refreshDisplay
(
)
{
for
(
byte
k
=
;
k
<
;
k
++
)
{
digitalWrite
(
digitPins
[
k
]
LOW
)
;
}
digitalWrite
(
latchPin
LOW
)
;
shiftOut
(
dataPin
clockPin
MSBFIRST
B11111111
)
;
digitalWrite
(
latchPin
HIGH
)
;
delayMicroseconds
(
)
;
digitalWrite
(
digitPins
[
digitScan
]
HIGH
)
;
digitalWrite
(
latchPin
LOW
)
;
if
(
digitScan
==
)
{
shiftOut
(
dataPin
clockPin
MSBFIRST
~
(
digit
[
digitBuffer
[
digitScan
]
]
B10000000
)
)
;
}
else
{
shiftOut
(
dataPin
clockPin
MSBFIRST
~
digit
[
digitBuffer
[
digitScan
]
]
)
;
}
digitalWrite
(
latchPin
HIGH
)
;
digitScan
++
;
if
(
digitScan
>
)
digitScan
=
;
}
void
loop
(
)
{
digitalWrite
(
ledPin
HIGH
)
;
sensors
requestTemperatures
(
)
;
tempC
=
sensors
getTempC
(
insideThermometer
)
;
tmp
=
int
(
tempC*
)
;
if
(
tempC
<
)
{
sign
=
true
;
tmp
=
abs
(
tmp
)
;
}
else
{
sign
=
false
;
}
if
(
int
(
tmp
)
/
1000
==
)
{
digitBuffer
[
]
=
;
if
(
sign
)
{
digitBuffer
[
]
=
;
}
}
else
{
digitBuffer
[
]
=
int
(
tmp
)
/
1000
;
}
if
(
int
(
tmp
)
/
1000
==
&&
(
int
(
tmp
)
%
1000
)
/
==
)
{
digitBuffer
[
]
=
;
if
(
sign
)
{
digitBuffer
[
]
=
;
digitBuffer
[
]
=
;
}
}
else
{
digitBuffer
[
]
=
(
int
(
tmp
)
%
1000
)
/
;
}
digitBuffer
[
]
=
(
int
(
tmp
)
%
)
/
;
digitBuffer
[
]
=
(
int
(
tmp
)
%
)
%
;
digitalWrite
(
ledPin
LOW
)
;
delay
(
)
;
}
Source Code/Program for Displaying Temperature in °Fahrenheit:
To design
DS18B20 Based Thermometer using Arduino & 4 Digits 7 Segment Display
& to display temperature in degree Fahrenheit you need two different library
Download 1 Wire Library
Download Dallas Temperature Library
Add these to the library file to Arduino IDE and then simply compile and upload the code.
Technologies used
Hardware components
- Arduino
- DS18B20
- OLED
- LM35
Software & tools
- Arduino IDE
What you get
- Working project / hardware kit, tested before delivery
- Complete source code with explanation
- Project demo and guidance for your viva
- Project report, PPT and IEEE paper support (on request)
Delivery & Payment
Delivery takes a minimum of two weeks from the date your inquiry is confirmed.
Payment is in two parts:
• 50% advance to start the project
• Remaining 50% before delivery
Note:
• Documentation and PPT are not included by default
• If you need documentation/PPT, it can be arranged for extra time and cost
We'll confirm the exact timeline and cost with you after reviewing your requirements.