Friday, April 3, 2015

TMP36 Temperature Sensor


I wish it were this easy to use all sensors.  I got this TMP36 with a SparkFun SIK Inventor's Kit in 2014.  That kit is well worth it if you are just getting started out.  There is a lot more information and direction on getting this going for an Arduino in the kit.  But we are using the MSP-EXP430F5529 :-)

The TMP36 is a low voltage, precision centigrade temperature
sensor that provides an analog signal that is linearly
proportional to the Celsius (centigrade) temperature.
Accuracy is ±1°C at +25°C and ±2°C over the −40°C to +125°C
temperature range. It provides for single-supply operation
from 2.7 V to 5.5 V maximum. The supply current runs below
50 μA.


Looking at the flat side of the TMP36 the pins are as follows:
Left    Vs   (+2.7 to 5.5V)
Center  Vout (analog output)
Right   GND


The datasheet calls for a 0.1 μF bypass capacitor on the input
(i.e. between Vs on the TMP36 and GND). It specifies a ceramic
type with short leads and located as close as possible to the
temperature sensor supply pin.


Circuit
TMP 36    MSP430F5529
------    ---------------------------------------------------
Vs        3.3V
Vs        0.1uF capacitor to GND
Vout      Pin 6 (P6.6) This must be an analog read pin
GND       GND


Frank Milburn 3 April 2015
*/


const int TMP36Pin = 6;            // pin sensor is connected to
const int analogRes = 4095; // A/D resolution


void setup()
{
  Serial.begin(9600);
  Serial.println("Starting temperature readings...");
}


void loop()
{
  // Get the output from the sensor and multiply it by
  // 3.3 / resolution to get the voltage

  float voltage = (analogRead(TMP36Pin) * 3.3 / analogRes);
 
  // TMP36 datasheet provides the conversion formula
  float degC = (voltage - 0.5) * 100.0;
 
  // and if fahrenheit is desired
  float degF = (degC * 1.8) + 32.0;

 
  // Now the serial output...
  Serial.println("___________________________________________");
  Serial.print("Voltage:         "); Serial.println(voltage,3);
  Serial.print("Temperature (C): "); Serial.println(degC,1);
  Serial.print("Temperature (F): "); Serial.println(degF,1);

  delay(1000);
}

No comments:

Post a Comment