Codigo:
#include <math.h>
double Thermistor(int RawADC) {
double Temp;
Temp = log(10000.0*((1024.0/RawADC-1)));
Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
Temp = Temp - 273.15;
Temp = (Temp * 9.0)/ 5.0 + 32.0;
return Temp;
}
void setup() {
Serial.begin(9600);
}
void loop() {
int val;
double tempFahrenheith;
val=analogRead(2);
tempFahrenheith=Thermistor(val);
double tempCelcius = (tempFahrenheith - 32) * 5/9;
Serial.print("Temperature = ");
Serial.print(tempCelcius);
Serial.println(" C");
delay(1000);
}
No hay comentarios:
Publicar un comentario