Arduino Temperature Sensor

34,141

48

3

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

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

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 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

//start the transmission

Wire.send(0x00);

if (Wire.available()) {
Serial.println(temperature);
} else {
Serial.println("---");
}

Wire.endTransmission();
//end the transmission

delay(delayC);
}

48 3.6K
5 1.9K
746 43K

3 Discussions

Cool!

I like how this sensor uses the I2C interface, this way you don't use up, somewhat precious adc pins. :)

Thanks lots of the info
I'm using mcp9800..... I am not getting any data out :( ... the code you posted is exactly the same, except I modified the address which is in this case 0x92 because I am using PIC I2C demo board, and it is embedded. Second, I accessed the Ambient temperatur regester, which can be accessed via 0x00 as you also posted .

Just a heads up use refer to TC74 as TC47 which may be confusing to readers. Otherwise great detailed guide!