Help - using two TMP36's simultaneously?

Hi everyone,

I have a quick question regarding the use of two TMP36 (Temperature sensor tutorial - Using the TMP36 / LM35). Probably lots of you out there know the answer to this, but I'm pretty new and am still learning how all this works...

I am trying to use two TMP36's and an arduino to get temperature info for each thermistor (each TMP36 will be in slighly different locations). I went ahead and tried to write a code (see attached) to see if I could gather temperature info by connecting the two TMP36's analog voltage output pins to different analog pins in the arduino (A0 and A1), using the following code below. The other pins were connected to the same ground and to the same 5v pin in the arduino (as shown in the tmp36 tutorial - Temperature sensor tutorial - Using the TMP36 / LM35).

The code:

//TMP36 Pin Variables
int sensorPin = 0; //the analog pin the TMP36's Vout (sense) pin is connected to
                        //the resolution is 10 mV / degree centigrade with a
                        //500 mV offset to allow for negative temperatures
 
 int sensorPin1 = 1;
 
 
/*
 * 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 computer
                       //to view the result open the serial monitor 
}
 
void loop()                     // run over and over again
{
 //getting the voltage reading from the temperature sensor
 int reading = analogRead(sensorPin);  
 delay(10);
 // converting that reading to voltage, for 3.3v arduino use 3.3
 float voltage = reading * 5.0;
 voltage /= 1024.0; 
 

 // now print out the temperature
 float 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");
 
 
 int reading1 = analogRead(sensorPin1);  
 delay(10);
  float voltage1 = reading1 * 5.0;
 voltage1 /= 1024.0; 
 
 
 float 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 Sensor1");
 
  
 delay(1000);                                     //waiting a second
}

When I run the code in the arduino, I get really odd values:

-50.00 degrees C Sensor1
-34.86 degrees C Sensor 0
-47.56 degrees C Sensor1
-49.51 degrees C Sensor 0
-50.00 degrees C Sensor1
-45.61 degrees C Sensor 0
-50.00 degrees C Sensor1
-49.51 degrees C Sensor 0
-50.00 degrees C Sensor1
-49.51 degrees C Sensor 0
-50.00 degrees C Sensor1
-50.00 degrees C Sensor 0
-50.00 degrees C Sensor1

Since it is spring right now, clearly these temperature results seem to be kind of off...

Does anyone know if I am doing anything wrong? Coding-wise? Connections-wise?

Any thoughts for this newbie would be greatly appreciated...

Thank you!!

It seems ADC is reading 0 for sensor 1, and close to 0 for sensor 2 - my guesses is that you have them wired up wrong..

How are they connected? Remember the pin 1 is Vcc, pin 2 is Vout and pin 3 is GND (with flat side facing you)

Hi capo12 and pecky,

I am having the same problem. Did you manage to sort it out?

Many Thanks.