Simple Home Temperature sensor with TMP35/TMP36/TMP37 | LM35 Temperature Sensor using Arduino with Code

 

TMP36 and LM35  Temperature Sensor using Arduino with Code



TMP36  Temperature Sensor

TMP36 Temperature Sensor



Features of TMP36 Temperature Sensor

  1. Low voltage operation - 2.7 V to 5.5 V
  2. Calibrated directly in °C
  3. 10 mV/ °C scale factor( 20 mV/ °C on TMP37)
  4. ± 2 °C delicacy over temperature
  5. ±0.5 °C linearity
  6. Stable with large capacitive loads
  7. Specified −40 °C to 125 °C, operation to 150 °C
  8. lower than 50 μA inert current
  9. Shutdown current 0.5 μA maximum
  10. Low tone- heating
  11. Good for automotive operations

Applications of TMP 36 Temperature Sensor

  1. Environmental Control Systems
  2. Thermal Protection
  3. Industrial Process Control
  4. Fire Alarms
  5. Power System Monitors
  6. CPU Thermal Management


LM35 Temperature Sensor


LM35  Temperature Sensor 




Code Explanation


const int sensorPin = A0;     // analog input pin for sensor float voltage, temperature;     // variables to store voltage and temperature


In this section, we first declare a constant integer sensorPin and set its value to A0, which is the analog input pin on the Arduino Uno that we will use to read the output of the LMP36 sensor. We then declare two floating-point variables, voltage, and temperature, which will be used to store the voltage and temperature readings from the sensor.


void setup() {

  Serial.begin(9600); // initialize serial communication

}


In the setup() function, we use the Serial.begin() function to initialize the serial communication with the computer at a baud rate of 9600. This will allow us to print the sensor readings to the serial monitor.



void loop() {

  int sensorValue = analogRead(sensorPin); // read sensor value

  voltage = sensorValue * (5.0 / 1023.0); // convert sensor value to voltage (assuming 5V reference)

  temperature = (voltage - 0.5) * 100; // convert voltage to temperature in Celsius (assuming LMP36 calibration)

  

  Serial.print("Voltage: ");

  Serial.print(voltage, 2); // print voltage to 2 decimal places

  Serial.print("V, Temperature: ");

  Serial.print(temperature, 2); // print temperature to 2 decimal places

  Serial.println("C");

  

  delay(1000); // wait for 1 second before taking another reading

}


In the loop() function, we first use the analogRead() function to read the analog value from the LMP36 sensor connected to the sensorPin input. We then convert this sensor value to a voltage by multiplying it by a scaling factor of (5.0 / 1023.0), which assumes a 5V reference voltage on the Arduino. The resulting voltage value is stored in the voltage variable.


Next, we use the calibration formula (voltage - 0.5) * 100 to convert the voltage value to temperature in Celsius. 


This formula assumes that the LMP36 sensor has been calibrated to output a voltage of 0.5V at 0 degrees Celsius and that the voltage output changes linearly with temperature.


Then we use the Serial.print() and Serial.println() functions to print the voltage and temperature readings to the serial monitor, along with some text labels. The delay() function is used to pause the program for 1 sec before taking another reading, to avoid overloading the serial monitor with too much data.



Example code for interfacing an LMP36/LM35 sensor with an Arduino Uno to measure temperature and voltage across the sensor:

Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
const int sensorPin = A0; // analog input pin for sensor
float voltage, temperature; // variables to store voltage and temperature

void setup() {
  Serial.begin(9600); // initialize serial communication
}

void loop() {
  int sensorValue = analogRead(sensorPin); // read sensor value
  voltage = sensorValue * (5.0 / 1023.0); // convert sensor value to voltage (assuming 5V reference)
  temperature = (voltage - 0.5) * 100; // convert voltage to temperature in Celsius (assuming LMP36 calibration)
  
  Serial.print("Voltage: ");
  Serial.print(voltage, 2); // print voltage to 2 decimal places
  Serial.print("V, Temperature: ");
  Serial.print(temperature, 2); // print temperature to 2 decimal places
  Serial.println("C");
  
  delay(1000); // wait for 1 second before taking another reading
}

Output on Serial Monitor


Measuring temperature and Voltage using TMP36/LM35 Temperature Sensor



Example of code for interfacing an LMP36/LM35 temperature sensor with an Arduino Uno to measure temperature in Celsius and Fahrenheit :


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// 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("Fahrenheit: "); 
  Serial.print(temperatureF);
  Serial.print("\xC2\xB0"); // shows degree symbol
  Serial.println("F");

  delay(1000); // wait a second between readings
}

Output on Serial Monitor

Measuring temperature in Celsius and Fahrenheit using TMP36/LM35 Temperature Sensor


Frequently Asked Questions related to LM35 and TMP36 Temperature Sensor

What's the TMP36 specification?

The TMP36 is specified use range from −40 °C to 125 °C, provides a 750 mV affair at 25 °C, and operates to 125 °C from a single 2.7 V. The TMP36 is functionally compatible with the LM35. 


The TMP35/ TMP36/ TMP37 are low voltage, perfection centigrade temperature detectors. Sensor gives vides a voltage output that is linearly proportional to the Celsius temperature.


What's the difference between TMP36 and LM35?

Differences - The LM35 boasts a slightly advanced temperate range at-55 °C to 150 °C versus the-40 °C to 125 °C range of the TMP36. The LM35 is also more accurate with a temperature reading that's accurate to-0.5 °C compared to the-2 °C delicacy of the TMP36.


What are the advantages of TMP36?

The TMP36 temperature detector is an easy way to measure temperature using an Arduino. The detector can measure a fairly wide range of temperature from - 50 °C to 125 °C, is fairly precise(0.1 °C resolution), and is veritably low cost, making it a popular choice.


How does TMP36 temperature detector work?

Using the TMP36 is easy, simply connect the left leg to power(2.7-5.5 V) and the right leg to ground of arduino and also the middle leg will have an analog voltage that's directly commensurable( direct) to the temperature. The analog voltage is independent of the volatge given to sensor.


What's the delicacy of TMP36?

Some of the main specifications set up in the TMP36 datasheet include Input power 2.7 to 5.5V. Temperature range from -40 to 125 °C. Typical delicacy ± 1 °C at 25 °C, ± 2 °C from −40 to 125 °C


What are the disadvantages of TMP36?

The cons are sensor is not super accurate, affected by mPort heat if plugged in directly, can not use a super long extension string.


Which detector is called LM35?

LM35 Temperature Sensor series are precision integrated-circuit temperature sensors, whose output voltage is linearly proportional to the Centigrade temperature (Celsius).


What's the difference between TMP36 and dht11?

The most accessible might be the TMP 36, as it has an internal neutralize for lower temperature dimension, but has slightly lower temperature range from −40 °C to 125 °C. The DHT 11 has the lowest temperature range from 0 to 50 deg. C, and is the slowest reading device( 2 seconds).


What's the difference between thermistor and TMP36?

Temperature detector TMP36, DHT22, and 10K Thermistor.

Sensor delicacy in °C and delicacy in °F

TMP36 ±2.00 °C & ±3.6 °F

Thermistor ±0.45 °C & ±0.8 °F

DHT22 ±0.50 °C & ±0.9 °F


What's the disadvantage of LM35?

It doesn't bear any external trouncing, although the main debit of this detector is that it labors data in analog format, making it veritably prone to external noise and hindrance


Is LM35 a microcontroller?

NO. We've formerly used LM35 with numerous other microcontrollers to measure the temperature Digital Thermometer using LM35 and 8051 Microcontroller. Temperature dimension using LM35 and AVR Microcontroller.


Is LM35 unresistant or active?

As lm35 is an active device, so you have to connect it in a separate power line whereas LDR is a unresistant detector so it requires separate power.


What's the input voltage of LM35 Temperature Sensor? 

The input voltage to LM35 can be from 4 volts to 30 volts. It consumes about 60 microamperes of current.


What's the output voltage of LM35 when connected?

LM35 maximum voltage affair is 1500mV( At 150 degree centigrade). 1500mV is equal to1500/1000 = 1.5 volts.


Is TMP36 analog or digital sensor?

The TMP36 is a low voltage, perfection centigrade temperature detector manufactured by Analog bias.Its an analog Temparature sensor.


What's the range of TMP36 Temperature Sensor?

The TMP36 has a specified range from −40 °C to 125 °C, provides a 750 mV affair at 25 °C, and operates to 125 °C from a single2.7 V.


Why we use LM35 temperature detector?

The LM35 device has an advantage over direct temperature detectors calibrated in Kelvin, as the stoner isn't needed to abate a large constant voltage from the affair to gain accessible Centigrade scaling.


Is LM35 a moisture detector?

LM35 is an intertwined analog temperature detector whose electrical affair is commensurable to Degree Centigrade and not a moisture detector.


What does LM35 stand for?

LM35 is an intertwined analog temperature detector whose electrical affair is commensurable to Degree Centigrade. LM35 Detector doesn't bear any external estimation or trouncing to give typical rigor.


How to calculate temperature in TMP36? How to Measure Temperature?

Using the TMP36 is easy, simply connect the left leg to power(2.7-5.5 V) and the right leg to the ground of Arduino. also the middle pin will have an analog voltage that's directly commensurable to the temperature.


Is TMP36 a thermistor?

Unlike a thermistor, the TMP36 doesn't have a temperature sensitive resistor, rather this detector uses the property of diodes; as a diode changes temperature the voltage changes with it at a known rate. The detector measures the small change and labors an analog voltage between 0 and 1.75 VDC grounded on it.


What's the difference between TMP36 and DS18B20?

The TMP36 is veritably cheap, small and popular but relatively delicate to use and may be inaccurate. The DS18B20 is small, accurate, cheap, veritably easy to use and has a leakproof interpretation. The DTH22 also indicates moisture, is relatively priced and is easy to use but may be too slow.


Which detector is better TMP36 or LM35?

Differences. The LM35 boasts a slightly advanced temperate range at-55 °C to 150 °C versus the-40 °C to 125 °C range of the TMP36. The LM35 is also more accurate with a temperature reading that's accurate to-0.5 °C compared to the-2 °C delicacy of the TMP36.


Is LM35 leakproof?

The detector is completely functional in the air, but it isn't leakproof or waterproof.


Where is LM35 used?

LM35 is used to measure precise centigrade temperature. The affair of this detector changes describes the linearity. The voltages of this detector are linearly relative to the Celsius temperature. Voltage range of this detector is from -55 ° to 150 °C.


Is LM35 a diode?

The LM35 temperature detector uses the introductory principle of a diode to measure known temperature values.


What's LM35 in IOT? Working principle LM35 in IOT?

LM35 is the detector that senses the temperature of its terrain and grounded on it's value it generates an analog voltage. This analog voltage produced by the LM35 is also given as input to the A0 pin of Arduino microcontroller board . Datasheet LM35




Thank You!
Have a great Day!