How to interface Temperature Sensor with Arduino?
Last Updated :
05 Feb, 2023
In this article, we will be interfacing TMP36 Temperature Sensor with Arduino. TMP36 is a precision centigrade temperature sensor that can precisely calculate the surrounding temperature. Connecting it with Arduino Uno can display the temperature getting from the sensor.
Components required for connection:
1. TMP36 Temperature Sensor:
Analog Devices' TMP36 is a low-voltage, precision centigrade temperature sensor. Furthermore, the TMP36 sensor does not require calibration and has a typical accuracy of 1°C at +25°C and 2°C over the temperature range of 40°C to +125°C.
TMP36 sensor2. Arduino Uno.
It is an open-source electronics platform. The ATmega328P-based Arduino Uno is a microcontroller board. It consists of 14 digital input/output pins, 6 analog inputs, a USB connection, a power jack, an ICSP header, and a reset button.
Arduino Uno3. Breadboard.
A breadboard is a solderless device used to create temporary electronic prototypes and test circuit designs. The breadboard contains metal strips underneath it that link the holes on the top of the board.
Breadboard mini4. Jumper wires.
Jumper wires are simply wires with connector pins at each end that can be used to connect two points without soldering.
Jumper WiresWorking Principle:
The TMP36 measures temperature using a solid-state approach. It takes advantage of the fact that the voltage drop between the base and emitter (forward voltage - Vbe) of a diode-connected transistor falls at a predictable pace as the temperature rises. It is simple to construct an analog signal that is directly proportional to temperature by properly magnifying this voltage change.
Calculating the output voltage from the Analog temperature data:
We used the inbuilt analogRead() function to read the data from the A0 pin. After reading we then calculate Vout using the formula given below:
Vout = (reading from A0 pin) * (3.3 / 1024)
For Example: If the reading from the A0 pin is 248V then Vout will be ~800mV or ~0.8V.
How to measure temperature:
Simply connect the left pin to power (5V) and the right pin to the ground to use the TMP36. The analog voltage on the middle pin will thereafter be directly proportional (linear) to the temperature in °C.
Simply apply the following formula to convert voltage to temperature:
Temperature (°C) = (Vout – 0.5) * 100
For Example: If the output voltage is 0.8V then the temperature will be approx. to 30°C.
What is Tinkercad:
Tinkercad is a free 3D modeling program that is well-known for its simplicity. It is entirely web-based, so anyone with an internet connection can access it. Tinkercad ideas can be brought to life by using 3D printing, laser cutting, or building blocks. Many schools utilize it to teach projects that include 3D Design, Electronics, and Visual Code Blocks.
Steps to start working on Tinkercad:
- Make an account on tinkercad.com.
- Click on the 'new+' button in the right corner.
- click on Circuit.
- Now you drag and drop components and make connections using wires.
- After making the connection we have to write code in C/C++.
- After that, we have to click on Start Simulation.
- In the end, you can then click on the Stop Simulation button to end the simulation.
Connection of Arduino Uno with TMP36:
- The red wire is connected from 5V power from Arduino to TMP36's power(Vs+).
- The black wire is connected from TMP36's Vout to Arduino's A0(Analog) pin.
- Green wire is connected from the ground(GND) of Arduino to the ground of the TMP36 sensor.
- The yellow wire is connected from the 3.3V of Arduino to the reference voltage(AREF) pin in Arduino. It is used to improve the accuracy of the TMP36 sensor.
Circuit DiagramWorking Code for the above circuit:
C++
// The TMP36's Vout pin is connected to A0 of Arduino
#define analogPin A0
// Connect ARef to 3.3V
#define aref_voltage 3.3
void setup() {
// Begin serial communication at 9600 baud rate
Serial.begin(9600);
// Set the aref to something other than 5v
analogReference(EXTERNAL);
}
void loop() {
// The voltage output reading from the TMP36 sensor
int sensorRead = analogRead(analogPin);
// Convert that sensor reading into voltage
float voltageOut = sensorRead * (aref_voltage / 1024.0);
// The voltage is then converted to temperature in Celsius
float tempInC = (voltageOut - 0.5) * 100;
// Print the temperature in Celsius in serial monitor
Serial.print("Temperature: ");
Serial.print(tempInC);
Serial.print("\xB0"); // prints the degree symbol
Serial.print("C");
Serial.print("\n");
delay(2000); // time in milliseconds to wait for the next reading
}
Simulation:
After you start the simulation, you can change the surrounding temperature by clicking on the TMP36 sensor and using the sliding button present on the top of it to change the surrounding temperature.
The output will be shown in the serial monitor section given below the code section in Tinkercad as:
Simulation
Similar Reads
Arduino - Temperature Sensor Sensors are widely used for sensing different quantities and quantifying them. One such example of a sensor is the temperature sensor which uses Arduino for displaying this temperature. The main feature of this sensor is that it can display the detected temperature on a Celsius scale. In this articl
7 min read
How to interface I2C LCD display with Arduino ? In this article, we will learn how to interface LCD displays with Arduino Uno R3. Arduino is an open-source electronics platform. It consists ATmega328P 8-bit Microcontroller. It can be able to read inputs from different sensors & we can send instructions to the microcontroller in the Arduino. I
5 min read
Temperature Sensor - Types of Sensor Temperature sensor: Temperature sensor is a device, used to measure the temperature using an electrical signal. It requires a thermocouple or RTD(Resistance temperature Detector). It is the most common and most popular sensor.Temperature sensor, the change in the temperature correspond to change in
3 min read
How to Monitor CPU and GPU temperature in Linux This article will discuss How to Monitor CPU and GPU temperature in Linux. There are several ways to do this here in this article we will discuss a few of them. The utilization of currently running programs or applications has no bearing on the CPU or GPU temperature. Operating sensitive computer pa
4 min read
Force Sensitive Resistor ( FSR ) with Arduino In this article, we will learn about Force sensors and the measurement of force sensors using Arduino. Arduino is an open-source electronics platform. It consists ATmega328P 8-bit Microcontroller. It can be able to read inputs from different sensors & we can send instructions to the microcontrol
3 min read
Temperature, Humidity, Air Pressure, and Wind Air is the imperceptible vaporous substance encompassing the earth, which is additionally alluded to as the air. Living creatures wouldn't make due without air, as it furnishes us with the air we breathe and safeguards us from the unsafe impacts of space. Consequently, life on earth is conceivable i
7 min read