problem Wiring two TMP36 on an Arduino UNO for cellar temperature regulation


I want to make a temperature regulator for my cellar and I use 2 sensor TMP36, one outside ( 6 meters of ethernet cable) and one into the cellar, the difference between the two temperature commands a 220Volts relay to switch on the ventilation from outside.

But I have a problem because when outside temperature is 20°C the result from my arduino is 18°C as in the mean time inside temperature is 18°C and Arduino is 21,87°C, so it seems to be inverted … but not because when I put my fingers onto the Inside sensor, the inside temperature rise from 21,87 to 28°C… so my wiring is ok.

Please Help Me! I cant find why those temperature are wrong… length of cable for external sensor ? bad wiring onto arduino board?
bad program?

attached is my wiring
!(http://cablage-arduino-2 capteurs tmp36.jpg)

hereafter is my program:

#define aref_voltage 3.3 // nous raccordons le 3.3V à ARef

float tempext = 0.0 ; //initialisation de la température extérieure
float tempint = 0.0 ; // initialisation de la température intérieure
float tension_ext = 0.0; // initialisation de la tension de sortie capteur a 0
float tension_int = 0.0; // initialisation de la tension de sortie capteur a 0

int valeurext ;
int valeurint ;

// Déclaration des pins utilisées

int sensorext = 2;
int sensorint = 0;

void setup ()
  pinMode(13,OUTPUT) ;// On initialise la sortie pour le ventilateur à 13
    Serial.begin(9600) ;
  analogReference(EXTERNAL);// On utilise aref avec une autre tension de ref que le 5V

void loop() {
  // On récupère la valeur des tensions en sortie des capteurs puis à l’aide de l’équation on trouve la température correspondante


  tension_ext = valeurext*aref_voltage;
  tension_ext /=1024.0;
  tension_int = valeurint*aref_voltage;
  tension_int /= 1024.0;


  if ((tempint>10 and tempint<14 and tempext<tempint) or (tempint<10 and tempext>tempint) or (tempint>14 and tempext<tempint)) digitalWrite(13,HIGH);

  else digitalWrite(13, LOW);

  // On edite les valeurs de temperature

  Serial.println ("valeur ext="); 
  Serial.println (valeurext);
  Serial.println ("tension ext="); 
  Serial.println (" volts");
  Serial.println ("temperature ext="); 
  Serial.print (tempext ); 
  Serial.println (" Deg C");
  Serial.println ("valeur int="); 
  Serial.println (valeurint);
  Serial.println ("tension int="); 
  Serial.println (" volts");
  Serial.println ("temperature int="); 
  Serial.print (tempint ); 
  Serial.println (" Deg C");

  //On attends 30 secondes avant de refaire une mesure
  delay(30000) ;

If your drawing is correct, you connected GND to pin 1 and Vcc to pin 3. It should be the other way aroung, e.g. Vcc to pin 1 and GND to pin3.

Here is a link to the data sheet

The connections look correct to me, and if they were reversed, they would be heating up and not giving temperatures near 20C.

Please see page 10 of the data sheet which talks about the need for .1uf by pass caps on the input to correct for radio frequency interference which can lead to dc offsets.

I do not see these capacitors in your wiring layout, so I would add them.

Have you tested both sensors on a bread board next to each other to confirm that they are indeed read the same when they are in the same environment?

Thank u for this advices, I will try the solution with 0.1 ?F bypass capacitor on the input.

You may also like to try a 47k resistor from Vout to GND on the TMP36. This device would seem to need a load resistor.

I know this is an old post, but I feel sorry for the much maligned TMP36, it seems to just need a load resistor to be a lot happier.