0% found this document useful (0 votes)
8 views

Temperature Sensor

Uploaded by

niyab10039
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)
8 views

Temperature Sensor

Uploaded by

niyab10039
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/ 3

Experiment No: 2

Interfacing Arduino Board with Temperature Sensor

2.c.Temperature Sensor
Aim
To interface an Arduino board with a temperature sensor and perform the following:

To display the temperature level using a temperature detector.

Components Required
Arduino UNO, Temperature sensor, resistor 4.7K ohm, jumper wires.

Procedure
• Connect the Vcc terminal of the soil sensor to 5V. Connect the GND terminal of the
soil sensor to GND. Connect the A0 terminal of the soil sensor to A0.

• Connect the 4.7K ohm resistor between signal PIN and Vcc PIN.

• Type out the code.

• Connect components according to the circuit diagram.

• Go to Sketch in that Select > Include Library > Manage Libraries.

• Library Manager page will appear in that go to search and enter onewire. Select the
OneWire (Access 1-wire temperature sensors, memory and other chips) and install

• Again go to search and enter Dallas. Select Dallas Temperature(Arduino Library for
Dallas Temperature Ics supports DS18B20……) and install.

• Close the page.

• Click on the Serial Monitor of the Arduino IDE. The Temperature is displayed on the
screen.

Circuit Diagram

Fig:1 Temperature Sensor


Fig 2: Circuit Diagram
Arduino IDE source code:

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

// Data wire is conntec to the Arduino digital pin 4


#define ONE_WIRE_BUS 12

// Setup a oneWire instance to communicate with any OneWire devices


OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature sensor


DallasTemperature sensors(&oneWire);

void setup(void)
{
// Start serial communication for debugging purposes
Serial.begin(9600);
// Start up the library
sensors.begin();
}

void loop(void){
// Call sensors.requestTemperatures() to issue a global temperature and Requests to all
devices on the bus
sensors.requestTemperatures();

Serial.print("Celsius temperature: ");


// Why "byIndex"? You can have more than one IC on the same bus. 0 refers to the first IC
on the wire
Serial.println(sensors.getTempCByIndex(0));
//Serial.print(" - Fahrenheit temperature: ");
//Serial.println(sensors.getTempFByIndex(0));
delay(1000);
}
Fig 3:Library Manager for Installation of OneWire and Dallas

Fig 4: To display the Result go to Serial Monitor

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy