Loading...
Pages: [1]   Go Down
Author Topic: TMP36 Temperature Sensor questions.  (Read 502 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey guys, i am brand new to all this but i bought a Inventors kit from robotshop.ca and i was following the guide for putting together temperature recording layout when i went to watch the temperature the numbers are this:
303.03
258.11
224.41
194.63
169.24
148.73
132.62
119.92
109.67
100.88
94.04
89.65
87.21
85.74
85.25
85.25
86.72
88.18
89.65
90.63


now i know for a fact that my temperature inside is currently sitting a 74.4f but this sensor doesn't dip below 80..... and it varies so much i have the feeling its broken or what i am looking at is not infact the temperature....  i just wanted to get some feedback as this is a critical area for me to learn (i plan on building a temperature sensor that controls a fan).

Heres the code it is running, again i am a complete noobie so i have no idea what to look for yet.


/*     ---------------------------------------------------------
 *     |  Arduino Experimentation Kit Example Code             |
 *     |  CIRC-10 .: Temperature smiley-small (TMP36 Temperature Sensor) |
 *     ---------------------------------------------------------
 *   
 *  A simple program to output the current temperature to the IDE's debug window
 *
 *  For more details on this circuit: http://tinyurl.com/c89tvd
 */

//TMP36 Pin Variables
int temperaturePin = 0; //the analog pin the TMP36's Vout (sense) pin is connected to
                        //the resolution is 10 mV / degree centigrade
                        //(500 mV offset) to make negative temperatures an option

/*
 * setup() - this function runs once when you turn your Arduino on
 * We initialize the serial connection with the computer
 */
void setup()
{
  Serial.begin(9600);  //Start the serial connection with the copmuter
                       //to view the result open the serial monitor
                       //last button beneath the file bar (looks like a box with an antenae)
}
 
void loop()                     // run over and over again
{
 float temperature = getVoltage(temperaturePin);  //getting the voltage reading from the temperature sensor
 temperature = (temperature - .5) * 100;          //converting from 10 mv per degree wit 500 mV offset
                                                  //to degrees ((volatge - 500mV) times 100)
 Serial.println(temperature);                     //printing the result
 delay(1000);                                     //waiting a second
}

/*
 * getVoltage() - returns the voltage on the analog input defined by
 * pin
 */
float getVoltage(int pin){
 return (analogRead(pin) * .004882814); //converting from a 0 to 1023 digital range
                                        // to 0 to 5 volts (each 1 reading equals ~ 5 millivolts
}
Logged

Netherlands
Offline Offline
Tesla Member
***
Karma: 87
Posts: 9368
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


you need to check if your source voltage is indeed 5.0V because the whole code is based upon that.

please use code tags  - it is the # button above the smileys
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

Pages: [1]   Go Up
Print
 
Jump to: