This post explains how you can read the temperature using a TMP36 Thermometer on the Arduino. The TMP36 thermometer is inexpensive (~£2.00) and can measure temperature from -40°C to 125°C.

TMP36
TMP36

As the image above shows, to wire the TMP36 you connect the pins as instructed above to your Arduino. Be careful you get the 5v and Gnd pin the correct way around or this component can get very hot! (Check the flat side left most pin is the 5v).

To calculate the temperature in Celsius you must use the following equation:

Temp in °C = [(mV Voltage output) – 500] / 10

So to do this in arduino, you need to convert your sensor reading to voltage. To do this you can use the following equation:

Voltage in mV = ( (Arduino Reading) * 5 ) / 1024

In summary, to read the temperature you need to set up an input analog pin, read from the pin and then do some simple conversion. Here is an example Arduino program that writes this value to the serial out every second:

 //Analog pin the TMP36 will be on.
int tempPin = 0;
void setup() {
//Set up serial connection.
Serial.begin(9600);
}
void loop() {
//Get the initial reading
int reading = analogRead(tempPin);
//Calculate the voltage in mV
float voltage = (reading * 5.0) / 1024;
//Calculate the temperature.
float temperatureC = (voltage - 0.5) * 100 ;
Serial.print(temperatureC);
Serial.println("°C");
// wait a second...
delay(1000);
}
Share Button

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *