Hello
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

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
valeurext=analogRead(sensorext);
//delay(1000);
valeurint=analogRead(sensorint);
tension_ext = valeurext*aref_voltage;
tension_ext /=1024.0;
tension_int = valeurint*aref_voltage;
tension_int /= 1024.0;
tempext=((tension_ext*1000)-500)/10;
tempint=((tension_int*1000)-500)/10;
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.print(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.print(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) ;
}