Introduction: Arduino Temperature Sensor

Ever wanted to read the temperature with your arduino? Heres a great way how using only 4 wires! With the TC74!!
The temperature is accurate to about ±2°C

Step 1: What You'll Need...

The things you need are:
- An Arduino (Im using Duemilanove)
- The TC47 (3.3V or 5V)
- Four(4) bits of wire
- A breadboard (Optional but helps a lot!)

Step 2: Wire It All Up!

Using the picture, connect:
NC to nothing
SDA to Arduino analog pin 4
GND to Arduino ground
SCLK to Arduino analog pin 5
VDD to either Arduino 5V or 3.3V (depending on which sensor you have)

Step 3: Can I Have Yo Number?

Now we need to find out the I2C address of you sensor (because you can connect up to 8 sensors using the same 2 analog pins).
Using the included table find your part number and corresponding binary address.
Got it? Good. Because now we need to convert the binary address (0s and 1s) into a hex value(sounds way more complicated then it really is).

Now take that address and put it into the [BINARY] field of this website and hit decode:
http://home2.paulschou.net/tools/xlate/

Were almost done, just copy what you see in the [HEX] field and add 0x in front of it.
For example if your output is 48 make it 0x48.

Step 4: Code, Code and More Code!

Now this code isnt mine, and im not quite sure where I got it.. so if anyone recognizes it give me a shout.
Anyways here it is. Just remember to replace the address in the code with the address of your sensor.
All you gotta do is upload this to your arduino, and open the serial monitor and you should be getting the temperature.


#include "Wire.h"
//wire library

#define address 0x48
//address of the temperature sensor

#define delayC 1000
//delay count in ms

#define baudrate 9600
//baudrate for communication

void setup()
{
Wire.begin();
Serial.begin(baudrate);
}

void loop()
{
Serial.print("temperature in Celsius: ");
//let's signal we're about to do something

int temperature;
//temperature in a byte

Wire.beginTransmission(address);
//start the transmission

Wire.send(0x00);

Wire.requestFrom(address, 1);
if (Wire.available()) {
temperature = Wire.receive();
Serial.println(temperature);
} else {
Serial.println("---");
}

Wire.endTransmission();
//end the transmission

delay(delayC);
}