/*
Modified version of the Simple code of Milan Malesevic and Zoran Stupic 2011.
Merche Blasco
*/
- include <math.h>
int TempPin =A0;
double ThermisterC(int RawADC) {
double TempC; TempC = log(((10240000/RawADC) - 10000)); TempC = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * TempC * TempC ))* TempC ); TempC = TempC - 273.15; // Convert Kelvin to Celcius return TempC;
}
double ThermisterF(int RawADC) {
double TempF; TempF = log(((10240000/RawADC) - 10000)); TempF = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * TempF * TempF ))* TempF ); TempF = TempF - 273.15; // Convert Kelvin to Celcius TempF = (TempF * 9.0)/ 5.0 + 32.0; // Convert Celcius to Fahrenheit return TempF;
}
void setup() {
Serial.begin(115200);
}
void loop() {
Serial.print("Celsius ");
Serial.println(int(ThermisterC(analogRead(TempPin)))); // display Celsius
Serial.print("Farenheit ");
Serial.println(int(ThermisterF(analogRead(TempPin)))); // display Fahrenheit
delay(100);
}