     lasttime = millis();
     
     // Ler o valor dos sensores
-    float rawTemp1 = analogRead(PIN_LM35);
-    float rawTemp2 = analogRead(PIN_MTK01);
+    bufferLM35[k] = analogRead(PIN_LM35);
+    bufferMTK01[k] = analogRead(PIN_MTK01);
+
+    // Calcula a Temperatura
+    float temp1 = bufferLM35[k]*A_LM35;   // Temperatura de Referência ( Ambiente )
+    float temp2 = bufferMTK01[k]*A_MTK01; // Medida da Variação da Temperatura
+    bufferTemp[k] =  temp1 + temp2;       // Compensação por Software
 
     // Filtragem
-    bufferLM35[k] = rawTemp1;
-    bufferMTK01[k] = rawTemp2;
-    
     filterAverenge(bufferLM35,index,k);
     filterMovingAverenge(bufferLM35,k);
     filterMovingAverengeExp(bufferLM35,k);
+    filterKalman(bufferLM35,k);
 
     // Envia via Serial
     Serial.print(lasttime);
     Serial.print(' ');
-    Serial.print(rawTemp1);
+    Serial.print(bufferLM35[k]);
     Serial.print(' ');
-    Serial.print(rawTemp2);
+    Serial.print(bufferMTK01[k]);
     Serial.print(' ');
     Serial.print(bufferAvgFilter[k]);
     Serial.print(' ');
     Serial.print(bufferMvAvgFilter[k]);
     Serial.print(' ');
-    Serial.println(bufferMvAvgExpFilter[k]);
+    Serial.print(bufferMvAvgExpFilter[k]);
+    Serial.print(' ');
+    Serial.println(bufferKalmanFilter[k]);
 
     // Incrementa Contadores
     index = index+1;

float bufferAvgFilter[SIZE_BUFFER];
float bufferMvAvgFilter[SIZE_BUFFER];
float bufferMvAvgExpFilter[SIZE_BUFFER];

float pMvAvgExpFilter[4]; // Pesos Filtro Média Móvel Ponderada

// Setup ---------------------------------------------------------------------------------


#define PIN_LM35      A0
#define PIN_MTK01     A1

#define GAIN_LM35      6
#define GAIN_MTK01     101

#define A_LM35      100*(5/1024)
#define A_MTK01     410*(5/1024)

#define INTERVAL      200  //ms
#define SIZE_BUFFER   10
#define SIZE_BUFFER_F 10   // Parâmentro Filtro Média Móvel
#define ALPHA         0.8  // Parâmentro Filtro Média Móvel Ponderada

// Parâmetros Filtro de Kalman
#define KALMAN_A        1
#define KALMAN_B        0
#define KALMAN_CONTROL  0
#define KALMAN_R        0.5
#define KALMAN_C        1
#define KALMAN_Q        10
#define KALMAN_COV      10000

// Variáveis Globais  --------------------------------------------------------------------------

