/*
- created 2011-10-31 by Massimo Pacilio
- Use to send data to Processing sketch "MySQL_INSERT"
- This sketch is in the public domain
*/
#include <math.h>
const unsigned int SENSOR_PIN = A0;
const unsigned int BAUD_RATE = 9600;
//equation to obtain the value of the temperature from a thermistor
//http://arduino.cc/playground/ComponentLib/Thermistor2
//http://en.wikipedia.org/wiki/Thermistor#Steinhart-Hart_equation
double Thermister (int RawADC){
double Temp;
Temp = log(((10240000/RawADC) - 10000));
Temp = 1 / (0.001129148 + (0.000234125 + (0.0000000876741 * Temp * Temp ))* Temp );
Temp = Temp - 273.15; // Convert Kelvin to Celsius
return Temp;
}
void setup() {
Serial.begin(BAUD_RATE);
pinMode(SENSOR_PIN, INPUT);
}
void loop() {
//assign to variable 'temp' the value of the temperature calculated by thermistor
int temp = int(Thermister(analogRead(SENSOR_PIN)));
Serial.println(temp); // send the value to the serial port
delay(30000);
}