0% found this document useful (0 votes)
47 views5 pages

Project 12 TEMP SENSOR

This document describes how to use a DS18B20 digital temperature sensor to measure temperature. It includes the sensor specifications and how to connect it in a circuit with an Arduino. Sample code is provided to read temperature values from the sensor and display them on a LCD screen or serial monitor.

Uploaded by

Darwin Vargas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
47 views5 pages

Project 12 TEMP SENSOR

This document describes how to use a DS18B20 digital temperature sensor to measure temperature. It includes the sensor specifications and how to connect it in a circuit with an Arduino. Sample code is provided to read temperature values from the sensor and display them on a LCD screen or serial monitor.

Uploaded by

Darwin Vargas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

PROJECT 12: TEMPERATURE SENSOR

Want to create a DIY environmental monitor or weather station? You can use a small, low-cost
sensor like the TMP36 to make devices that track and respond to temperature. In this activity you
will also use the LCD screen to display sensor readings, a common use for LCDs in electronics
projects
Grab the following quantities of each part listed to build this circuit:
Page | 1

NEW COMPONENTS

DS18B20 DIGITAL TEMPERATURE SENSOR: This temperature sensor has three legs. One
connects to 5V, one to ground, and the voltage output from the third leg varies proportionally to
changes in temperature. By doing some simple math with this voltage, we can measure
temperature in degrees Celsius or Fahrenheit.

DS18B20 is 1-Wire digital temperature sensor from Maxim IC. Reports degrees in Celsius
with 9 to 12-bit precision, from -55 to 125 (+/-0.5). Each sensor has a unique 64-Bit Serial
number etched into it - allows for a huge number of sensors to be used on one data bus.
Features:
• Unique 1-Wire® interface requires only one port pin for communication
• Each device has a unique 64-bit serial code stored in an onboard ROM
• Multidrop capability simplifies distributed temperature sensing applications
• Requires no external components
• Can be powered from data line.
• Power supply range is 3.0V to 5.5V
PROJECT 12: TEMPERATURE SENSOR

• Measures temperatures from –55°C to +125°C (–67°F to +257°F)±0.5°C accuracy from –


10°C to +85°C
• Thermometer resolution is user-selectable from 9 to 12 bits
• Converts temperature to 12-bit digital word in 750ms (max.)
Page | 2
• User-definable nonvolatile (NV) alarm settings
• Alarm search command identifies and addresses devices whose temperature is outside of
programmed limits (temperature alarm condition)
• Applications include thermostatic controls, industrial systems, consumer products,
thermometers, or any thermally sensitive system

NEW CONCEPTS

ALGORITHMS: An algorithm is a process used in order to achieve a desired result. Often, the
information needed to create an algorithm lives in the part’s datasheet. This sketch uses a few
formulas to turn a voltage value into a temperature value, making them all part of the larger
temperature-retrieving algorithm. The first formula takes the voltage read on analog pin 0 and
multiplies it to get a voltage value from 0V–5V:

voltage = analogRead(A0) * 0.004882813;

The number we are multiplying by comes from dividing 5V by the number of samples the analog
pin can read (1024), so we get: 5 / 1024 = 0.004882813.

The second formula takes that 0–5V value and calculates degrees Celsius:

degreesC = (voltage - 0.5) * 100.0;

We are showing how to use DS18B20 one wire water proof temperature sensor. With the
help of DS18B20 one wire temperature sensor we can measure the temperature from -55℃
To 125℃ with accuracy of ±5 .
Additional Library:

• One Wire Library


• Dallas Temperature Sensor library
Installation instructions available
HOOKUP GUIDE
READY TO START HOOKING EVERYTHING UP? Check out the circuit diagram and
hookup table below to see how everything is connected.
PROJECT 12: TEMPERATURE SENSOR

Page | 3
PROJECT 12: TEMPERATURE SENSOR

Page | 4

SOURCE CODE:

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

#define ONE_WIRE_BUS 5

OneWire oneWire(ONE_WIRE_BUS);

DallasTemperature sensors(&oneWire);

float Celcius=0;
float Fahrenheit=0;
void setup(void)
{
PROJECT 12: TEMPERATURE SENSOR

Serial.begin(9600);
sensors.begin();
}

void loop(void)
{ Page | 5
sensors.requestTemperatures();
Celcius=sensors.getTempCByIndex(0);
Fahrenheit=sensors.toFahrenheit(Celcius);
Serial.print(" C ");
Serial.print(Celcius);
Serial.print(" F ");
Serial.println(Fahrenheit);
delay(1000);
}

SOURCECODE

#include <LiquidCrystal.h> //the liquid crystal library contains commands for printing to the display
LiquidCrystal lcd(13, 12, 11, 10, 9, 8); // tell the RedBoard what pins are connected to the display

float voltage = 0; //the voltage measured from the TMP36


float degreesC = 0; //the temperature in Celsius, calculated from the voltage
float degreesF = 0; //the temperature in Fahrenheit, calculated from the voltage

void setup() {

lcd.begin(16, 2); //tell the lcd library that we are using a display that is 16 characters wide and 2
characters high
lcd.clear(); //clear the display
}

void loop() {

voltage = analogRead(A0) * 0.004882813; //convert the analog reading, which varies from 0 to 1023, back to a
voltage value from 0-5 volts
degreesC = (voltage - 0.5) * 100.0; //convert the voltage to a temperature in degrees Celsius
degreesF = degreesC * (9.0 / 5.0) + 32.0; //convert the voltage to a temperature in degrees Fahrenheit

lcd.clear(); //clear the LCD

lcd.setCursor(0, 0); //set the cursor to the top left position


lcd.print("Degrees C: "); //print a label for the data
lcd.print(degreesC); //print the degrees Celsius

lcd.setCursor(0, 1); //set the cursor to the lower left position


lcd.print("Degrees F: "); //Print a label for the data
lcd.print(degreesF); //print the degrees Fahrenheit

delay(1000); //delay for 1 second between each reading (this makes the display less noisy)
}

You might also like