0% found this document useful (0 votes)
9 views7 pages

Lab 11

Lab 11

Uploaded by

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

Lab 11

Lab 11

Uploaded by

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

Department of Computer Engineering

Microprocessors and Microcontroller Interfacing Lab

Course Instructor: Dated:

Lab Engineer: Sanan Ahmad

Semester

Lab 11 Interfacing TMP36 Temperature Sensor with Arduino

Total Marks Manual Marks Obtained


Name Roll No
(35) (15) Marks (50)

Checked on: _______________________________

Signature: __________________________________
11 Interfacing TMP36 Temperature Sensor with
Arduino
Lab conduct
1. You have to perform this experiment using Arduino and its Arduino IDE.
2. You are required to work in groups; everyone must attempt to understand the language syntax and
programming.
3. In case some aspect of the lab experiment is not understood, you are advised to seek help from the
instructor, lab engineer or the TA.
4. Every student has to submit individual lab manual in printed form. Use the provided Word document
to fill the manual and convert it to PDF before printing.

Lab details
One of the easiest and inexpensive ways to add temperature sensing in your Arduino project is to use
TMP36 Temperature Sensor. These sensors are fairly precise and needs no external components to work.
So, with just a few connections and some Arduino code you’ll be sensing temperature in no time.
TMP36 Temperature Sensor
The TMP36 is a low voltage, precision centigrade temperature sensor manufactured by Analog Devices.
It is a chip that provides a voltage output that is linearly proportional to the temperature in °C and is,
therefore, very easy to use with an Arduino.

The TMP36 temperature sensor is fairly precise, never wears out, works under many environmental
conditions and requires no external components to work. In addition, the TMP36 sensor does not require
calibration and provides a typical accuracy of ±1°C at +25°C and ±2°C over the −40°C to +125°C
temperature range. The sensor can be powered with a 2.7V to 5.5V power supply and consumes only
50µA.
Here are the complete specifications:
Power supply 2.7V to 5.5V
Current draw 50µA
Temperature range -40°C to 125°C
Accuracy ±2°C
Output scale factor 10mV/°C
Output range 0.1V (-40°C) to 1.75V
(125°C)
Output at 25°C 750mV

How to Measure Temperature


The TMP36 is easy to use, just connect the left pin to power (2.7-5.5V) and the right pin to ground
(assuming the flat side of the sensor is facing you). Then the middle pin will have an analog voltage that
is directly proportional (linear) to the temperature in °C. This can be easily seen in the output voltage vs
temperature characteristic. Note that the analog output voltage is independent of the power supply.

To convert the voltage to temperature, simply use the basic formula:


Temp (°C) = (Vout – 0.5) * 100
So for example, if the voltage out is 1V that means that the temperature is (1 – 0.5) * 100 = 50 °C
Testing the TMP36 Sensor
Testing the TMP36 is pretty easy, just connect the left pin to 2.7-5.5V power supply (Two AA batteries
work great) and the right pin to ground (assuming the flat side of the sensor is facing you). Now connect
your multimeter in DC voltage mode to ground and the middle pin. At the room temperature (25°C), the
voltage should be about 0.75V.
Try squeezing the plastic case of the sensor gently to see a rise in temperature.
Or try touching the sensor with an ice cube (in a plastic bag so your circuit doesn’t come into contact
with water) and watch the temperature drop.
TMP36 Sensor Pinout
The TMP36 comes in three different form factors, but the most common type is the 3-pin TO-92
package, which looks just like a transistor. Let’s take a look at its pinout.

+Vs is the power supply for the sensor which can be anywhere between 2.7V to 5.5V.
Vout pin produces an analog voltage that is directly proportional (linear) to the temperature. It should
be connected to an Analog (ADC) input.
GND is a ground pin.
Connecting the TMP36 Temperature Sensor to an Arduino
Below is the hookup for the experiments with the TMP36:

The sensor can be powered from 3.3 or 5V output. The positive voltage connects to ‘+Vs’ and ground
connects to ‘GND’. The middle pin ‘Vout’ is the analog signal output from the sensor and connects to
the A0 analog input of an Arduino. To measure air temperature, leave the sensor in the open air or attach
it to an object you want to measure the temperature of, such as a hit sink.
Reading the Analog Temperature Data
As you can see in the wiring diagram above, the output of the TMP36 is connected to one of the analog
inputs of the Arduino. The value of this analog input can be read with the analogRead() function.
However, the analogRead() function does not actually return the output voltage of the sensor. Instead, it
maps the input voltage between 0 and the ADC reference voltage (technically it is the operating voltage
i.e., 5V or 3.3V unless you change it) to 10-bit integer values ranging from 0 to 1023. To convert this
value back to the sensor’s output voltage, use this formula:

Vout = (reading from ADC) * (5 / 1024)


This formula converts the number 0-1023 from the ADC into 0-5V

If you’re using a 3.3V Arduino, you’ll want to use this:


Vout = (reading from ADC) * (3.3 / 1024)
This formula converts the number 0-1023 from the ADC into 0-3.3V

Then, to convert volts into temperature, use this formula:


Temperature (°C) = (Vout – 0.5) * 100

Task
1. Arduino Code – Simple Thermometer
The following sketch shows a quick way to read a TMP36 temperature sensor and can serve as the
basis for more practical experiments and projects. It simply reads the value from the TMP36 using
analog port A0 and prints the current temperature (in both °C and °F) on the serial monitor. Go ahead
and upload it to your Arduino.
Execute the code and screenshot the results.

// Define the analog pin, the TMP36's Vout pin is connected to


#define sensorPin A0
void setup() {
// Begin serial communication at 9600 baud rate
Serial.begin(9600);
}
void loop() {
// Get the voltage reading from the TMP36
int reading = analogRead(sensorPin);
// Convert that reading into voltage
// Replace 5.0 with 3.3, if you are using a 3.3V Arduino
float voltage = reading * (5.0 / 1024.0);
// Convert the voltage into the temperature in Celsius
float temperatureC = (voltage - 0.5) * 100;
// Print the temperature in Celsius
Serial.print("Temperature: ");
Serial.print(temperatureC);
Serial.print("\xC2\xB0"); // shows degree symbol
Serial.print("C | ");
// Print the temperature in Fahrenheit
float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
Serial.print(temperatureF);
Serial.print("\xC2\xB0"); // shows degree symbol
Serial.println("F");
delay(1000); // wait a second between readings
}

2. Problem Statement
Interface a temperature sensor with a microcontroller to measure and display the temperature on an
LCD screen and turn on and off the led when
 Led on: when temperature is above 50 degrees
 Led off: when temperature is below 25 degrees
You need to
1. Make the block diagram
2. Make the flow chart
3. Write the code
4. Execute the code and screenshot your results
Assessment rubric for Lab
Method for assessment:
Lab reports and instructor observation during lab session.
Outcome assessed:
a. Ability to conduct experiments, as well as to analyze and interpret data (P)
b. Ability to function on multi-disciplinary teams (A)
c. Ability to use the techniques, skills, and modern engineering tools necessary for engineering practice (P)

Signature: ______________________

You might also like