090 PostLab4
090 PostLab4
IDE:
The LM35 is a low voltage, precision centigrade temperature sensor manufactured by Texas Instruments. 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 LM35 temperature sensor is fairly precise, never wears out, works under many environmental conditions
and requires no external components to work. In addition, the LM35 sensor does not require calibration and
provides a typical accuracy of ±0.5°C at room temperature and ±1°C over a full −55°C to +155°C temperature
range.
The sensor can be powered with a 4V to 30V power supply and consumes less than 60µA during active
temperature conversions, providing very low self-heating (less than 0.08°C in still air).
Marwadi University
Faculty of Engineering & Technology
Department of Information and Communication Technology
Subject: Foundation skills in
Aim: Interfacing force sensor with Arduino board
sensor interfacing (01CT1103)
Experiment No: 04 Date: 31 Aug Enrollment No: 132261
The only disadvantage of the LM35 sensor is that it requires a negative bias voltage to measure negative
temperature. The TMP36 by Analog Devices is fairly accurate (-40°C to 125°C) and has the advantage of being
able to measure negative temperatures without the need for negative bias voltage.
A better alternative to the LM35 is to use a digital temperature sensor like the DS18B20 which comes in the
same package. Digital temperature sensors have better noise immunity which is useful when the sensor is
placed at a distance or in an electrically noisy environment.
Working Principle
The LM35 uses a solid-state technique to measure the temperature. It makes use of the fact that the voltage drop
between the base and emitter (forward voltage – Vbe) of the Diode-connected transistor decreases at a known
rate as the temperature increases. By precisely amplifying this voltage change, it is easy to generate an analog
signal that is directly proportional to temperature.
For example, if the voltage out is 0.5V that means that the temperature is 0.5 * 100 = 50 °C
LM35 Sensor Pinout
Marwadi University
Faculty of Engineering & Technology
Department of Information and Communication Technology
Subject: Foundation skills in
Aim: Interfacing force sensor with Arduino board
sensor interfacing (01CT1103)
Experiment No: 04 Date: 31 Aug Enrollment No: 132261
+Vs is the power supply for the sensor which can be anywhere between 4V to 30V.
Vout pin produces an analog voltage that is directly proportional (linear) to the temperature. It should be
connected to an Analog (ADC) input.
This formula converts the number 0-1023 from the ADC into 0-5V. Then, to convert volts into temperature, use
this formula:
Temperature (°C) = Vout * 100
Code:
#define sensorPin A0
void setup() {
// Begin serial communication at 9600 baud rate
Serial.begin(9600);
Marwadi University
Faculty of Engineering & Technology
Department of Information and Communication Technology
Subject: Foundation skills in
Aim: Interfacing force sensor with Arduino board
sensor interfacing (01CT1103)
Experiment No: 04 Date: 31 Aug Enrollment No: 132261
}
void loop() {
// Get the voltage reading from the LM35
int reading = analogRead(sensorPin);
//Post-Lab4 Code-MU-ICT-SEM1-ICT-EK1-090
#include <LiquidCrystal.h>
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
#define sensorPin A0
void setup()
{
Serial.begin(9600);
lcd.begin(16, 2);
}
void loop()
{
int reading = analogRead(sensorPin); // Collects the voltage reading from TMP36
float voltage = reading * (5.0 / 1024.0); // Convert that reading into analog characters
float temperatureC = (voltage * 100)- 49.8; // Convert the voltage into the temperature in Celsius
lcd.setCursor(0,0);
lcd.print("Temp. (C) ");
lcd.print(temperatureC);
delay(1000);
}