Temperature Sensor Example

Precision Temperature Sensor

In this project we demonstrate how to read temperature measures using your Arduino Board. 
This project makes use of Temperature Sensor (TMP36). 
This sensor outputs 10 millivolts per degree centigrade on the signal PIN. 
Measuring temperatures below freezing is possible thanks to a 500 mV offset (for example 25 degrees C = 750 mV, 0degrees C = 500mV). 
We'll use some math formulas to convert the digital value read from the sensor to degrees. 
The value converted is then shown in SerialMonitor.


  • Arduino board
  • Breadboard
  • Temperature Sensor (TMP36) (x1)
  • A bunch of wires


Temperature sensor example circuit 
Put the temperature sensor in the breadboard. Link the ground PIN to Ground and the +5 Volts PIN to Arduino 5V PIN. 
The Signal PIN is the center one; connect it to Analog PIN 0 of your Arduino board.


Temperature sensor  example schematic


The sketch code starts a Serial connection in order to read results using Serial Monitor. 
It reads the raw datas coming from sensor and it converts it to a digital range from 0 to 1024. 
Now it converts the result to a degree using a math formula. 
The temperature result will now be sent to the Serial Monitor, available for reading.

//Define the Temperature Sensor Pin
int sensorPin = 0;
void setup() {
//Start Serial connection to read results in Serial Monitor
void loop() {
//Get the sensor raw reading
//then convert it from a 0 to 1024 digital range
float temperature = analogRead(sensorPin) * .004882814;
//Convert the raw value to Celsius
temperature = (temperature - .5) * 100;
//Print the temperature value to Serial Monitor
//Read the temperature each second