Arduino Uno

somewhere on the ethernet shield

Corner
-->

Temperature sensor

Schematic

temperature schematics

Please note, that generally you do not connect the 3.3V VCC to the Aref pin, but doing so makes the reading better. I also want to take your attention to the fact that I use 3.3V instead of the 5V as VCC, as the 3.3V regulator has a better filtering. For more information about this, please continue reading here.

Photo

temperature schematics

Sample code

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// the reference voltage
double REF_VOLTAGE = 3.3;

// the pin where the temperature is to be mesured
int tempPin = 5;

void setup()
{
  // open te serial output with 115200 baud  
  Serial.begin(115200);
  // tell the Arduino that the reference voltage is
  // provided by an external source
  analogReference(EXTERNAL);
  // wait for the external source to be switched
  delay(100);
}

void loop()
{
  // read the tempetarue
  int tempReading = analogRead(tempPin);    
  // converting that reading to voltage
  float voltage = tempReading * REF_VOLTAGE / 1024.0;  
  // convert the voltage to a temperature
  float celsius = (voltage - 0.5) * 100 ;  
  // print it on the serial output
  Serial.println(celsius);
  // wait a second
  delay(1000);
}

Links

 More information about this circuit