I recently received a few free samples of this device from analog.com because I wanted to try to modify my old analog thermostat and make it digitally controlled. The device has 3 pins: Vs, out and GND, and it operates between 2.7 and 5.5V. Here's the datasheet:
http://www.analog.com/static/imported-files/data_sheets/TMP35_36_37.pdf
The 37 in particular reads in 20mV/°C, is designed for the 5°-100°C range and has a reading of 500mV at 25°C. Initially I simply plugged in 5V to the Vs, GND to the ground pin and the out pin to A0 on the Arduino, then I read the analog input, adjusted it to convert the 0-1023 analog reading to a mV value like this:
int reading = analogRead(A0);
float mv = (reading * 5.0) / 1024.0;
Then subtracted 500 and divided by 20 to get degrees C. This is where I'm not sure I'm doing it right. Basically, I don't believe what the sensor is saying the temperature is in my room. Right now it's saying it's 77.07° F (25.04° C). I know that it's hotter than that (it gets really hot in my room). Here's my current sketch. I'm using 3.3V aref and printing to an LCD.
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);
#define aref_voltage 3.3
int tempPin = 1;
int tempReading;
void setup(void) {
analogReference(EXTERNAL);
lcd.begin(16,2);
lcd.clear();
lcd.setCursor(0,0);
}
void loop(void) {
tempReading = analogRead(tempPin);
float voltage = tempReading * aref_voltage;
voltage /= 1024.0;
float temperatureC = (voltage - 0.5) * 200 ;
float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
lcd.clear();
lcd.print(temperatureC);
lcd.print(" C");
lcd.setCursor(0, 1);
lcd.print(temperatureF);
lcd.print(" F");
delay(1000);
}
The article I was reading to help me figure out how to set this thing up was using a TMP36, which is slightly different than the 37. From the datasheet:
The TMP36 is specified from ?40°C to +125°C, provides a 750 mV output at 25°C, and operates to 125°C from a single 2.7 V supply. [...] Both the TMP35 and TMP36 have an output scale factor of 10 mV/°C.
The TMP37 is intended for applications over the range of 5°C to 100°C and provides an output scale factor of 20 mV/°C. The TMP37 provides a 500 mV output at 25°C.
The difference I see is that the 36 reads 500mV at 0°C whereas the 37 reads 500mV at 25°C. My tiny tired brain can't work out what I'm supposed to do to account for this.
I'm hoping someone here who is less tired and has a bigger brain can help me figured the math out for this.