Tuesday, January 11, 2011

Temperature Sensor on Arduino

The temperature sensor mini board from seeedstudio is also really easy to connect to the Arduino board. That's the beauty of those mini boards. However, it has one flaw though. The thermistor which is used on the board has not a very good datasheet. I wasn't able to come up with an exact formular to calculate the ADC readings to degrees celsius. I used a formular which I found on the web. Note that this formular is for linear thermistors and is meant for a certain circuit setup. So my readings are more or less approximations based on that formular. To shortly increase the value I breathed on the thermistor.

Here is the source:
int temperatureSensor = 1;
int temperatureADCReading;
float currentTemperatureInCelsius;

void setup() {
  Serial.begin(9600);
}

void loop() {
  temperatureADCReading = analogRead(temperatureSensor);
  currentTemperatureInCelsius = 25 + (temperatureADCReading - 512) / 11.3;

  Serial.print("Temperature ADC reading: ");
  Serial.println(temperatureADCReading);
  Serial.print("Temperature in C: ");
  Serial.println(currentTemperatureInCelsius);
  delay(2000);
}
This is the program printing out those readings:

No comments:

Post a Comment