Pages: [1]   Go Down
Author Topic: TMP36 weird temperature  (Read 634 times)
0 Members and 1 Guest are viewing this topic.
manchester
Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi All,

I am having an Arduino Uno connected with two TMP36 sensors. I have followed the tutorial from http://learn.adafruit.com/tmp36-temperature-sensor and I get very weird results which i show you below.

I have to say that I am using 3.3V not 5V cause I found after a little search that gives more accurate temperature.

Quote
0.49 volts sensor 0
-0.69 degrees C sensor 0
0.49 volts sensor 1
-1.02 degrees C sensor 1
0.49 volts sensor 0
-1.02 degrees C sensor 0
0.49 volts sensor 1
-1.34 degrees C sensor 1
0.49 volts sensor 0
-1.02 degrees C sensor 0
0.49 volts sensor 1
-1.34 degrees C sensor 1
0.49 volts sensor 0
-1.02 degrees C sensor 0
0.49 volts sensor 1
-1.02 degrees C sensor 1
0.49 volts sensor 0
-1.02 degrees C sensor 0
0.49 volts sensor 1
-1.34 degrees C sensor 1
0.49 volts sensor 0
-1.02 degrees C sensor 0
0.49 volts sensor 1
-1.02 degrees C sensor 1

My code is the following:
Code:

int sensorPin = 0;
int sensorReading ;
float temperatureC ;
float voltage ;
int sensorPin1 = 1;
int sensorReading1 = 0;
float temperatureC1 = 0;
float voltage1 = 0;

void setup(){
 
      Serial.begin(9600);
}


void loop(){

            sensorReading = analogRead(sensorPin);
            voltage = sensorReading * 3.3;// converting that reading to voltage for 3.3v
            voltage /= 1024.0;
            Serial.print(voltage); Serial.println(" volts sensor 0"); // print out the voltage       
            temperatureC = (voltage - 0.5) * 100;     //converting from 10 mv per degree wit 500 mV offset  (to degrees ((volatge - 500mV) times 100))     
            Serial.print(temperatureC); Serial.println(" degrees C sensor 0");// print out the temperature degrees C
            sensorReading1 = analogRead(sensorPin1);
           
            voltage1 = sensorReading1 * 3.3;// converting that reading to voltage for 3.3v
            voltage1 /= 1024.0;
            Serial.print(voltage1); Serial.println(" volts sensor 1"); // print out the voltage       
            temperatureC1 = (voltage1 - 0.5) * 100;     //converting from 10 mv per degree wit 500 mV offset  (to degrees ((volatge - 500mV) times 100))     
            Serial.print(temperatureC1); Serial.println(" degrees C sensor 1");// print out the temperature degrees C
           
            delay(1000);
}


Does anybody seen anything like that?
Is there any chance my sensors to be faulty?

Any help will be much appreciated!
Many Thanks!
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 614
Posts: 49386
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I have to say that I am using 3.3V not 5V cause I found after a little search that gives more accurate temperature.
Then those numbers you are seeing must be accurate.

The reason for using 5V is because the values read from the sensor are on a scale of 0 to 1023, where 0 corresponds to 0 volts, and 1023 corresponds to 5V.

You are using an incorrect mapping from reading to voltage when you use 3.3 on a 5V system.
Logged

manchester
Offline Offline
Newbie
*
Karma: 0
Posts: 22
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

Now am using 5V and it works great.

Thanks
Logged

Pages: [1]   Go Up
Jump to: