Pages: [1]   Go Down
Author Topic: Is my brain or my TMP36 broken?  (Read 1308 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So I hook up my TMP36 sensor tonight and run the example code.
I am using the 5v and analog 0

703 - analog
3.43 - voltage output
293 - converted to degrees C

and
when I heat the sensor with my fingers, the temperature drops...

Code:
int temperaturePin = 0;
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
{
 Serial.println(analogRead(0));
 float temperature = getVoltage(temperaturePin);
 Serial.println(temperature);             //getting the voltage reading from the temperature sensor
 temperature = (temperature - 0.50) * 100.0;          //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 1024 digital range
                                        // to 0 to 5 volts (each 1 reading equals ~ 5 millivolts
}
Logged

0
Offline Offline
Shannon Member
****
Karma: 200
Posts: 11694
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That output voltage looks out of spec - check how you've wired up the sensor.
Logged

[ I won't respond to messages, use the forum please ]

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 72
Posts: 7171
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

293 seems awfully close to room temperature in kelvin scale. Just that if you don't recall from physics class, 293K=20DegC=room temperature. Are you sure the sensor is report DegC or K?
Logged


Singapore
Offline Offline
Newbie
*
Karma: 4
Posts: 25
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

 This should work:
Code:
float tempvoltage = analogRead(tempsensorpin) * 5.0;
  tempvoltage /= 1024.0;
  float temp = (tempvoltage - 0.5) * 100;
 

As long as you have a 5v arduino!

if you are still getting readings of 293+, then have a close look at your sensor, you probably have an LM335 instead of a 36GZ...  In that case, simply add the line:
Code:
temp = temp - 273.15
to the end of the above.

I happen to have both of these sensors in front of me
Logged

Singapore
Offline Offline
Newbie
*
Karma: 4
Posts: 25
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Wait a second, you should never see 700+ on the analog input from this sensor.  It should be down around .73- about 1.76 v If I am not mistaken- So 1.76/5 = .352 = only 360 on the scale... and that would only be if it was around 125 C in your workspace!

Check your connections-

Also, are you using a 3.3v arduino? because all of this would make sense then.
Logged

Jakarta
Offline Offline
Newbie
*
Karma: 0
Posts: 10
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I've try some sketches to work with LM35DZ, and I found this one works okay http://www.danielandrade.net/2008/07/05/temperature-sensor-arduino/ .
Logged

Pages: [1]   Go Up
Jump to: