I recently ordered some samples from TI, which included the TMP275 digital sensor. The sensor has some nice features which I quote from it’s datasheet:

The TMP275 is a 0.5°C accurate, Two-Wire, serial output temperature sensor available in an MSOP-8 or an SO-8 package. The TMP275 is capable of reading temperatures with a resolution of 0.0625°C. The TMP275 is SMBus-compatible and allows up to eight devices on one bus. It is ideal for extended temperature measurement in a variety of communication, computer, consumer, environmental, industrial, and instrumentation applications. The TMP275 is specified for operation over a temperature range of −40°C to +125°C.

The easiest way to get the temperature out of the TMP275 seemed to be I2C. So I started by designing a board which has all the components needed: the sensor, an atmega8 brain, and some other components needed for the display and for powering the board. The display is a 4 digit 7 segment display from kingbright product code CA56-12GWA. As for the display part of the board, I used PNP transistors on the common anodes and resistors on the segments to limit the current draw on the atmega’s pins. The transistors are not current limited so the display will alaways light-up the same no matter how many segments are turned on.

TMP275 digital thermometer board

For the supply part of the board, I choose to make it portable and power it from a 9V battery, so I needed to use a voltage regulator. The choice was the good old 7805 because it’s cheap and easy to find.

I2C is a pretty common protocol so various libraries can be found on the web. I chose Peter Fleury’s I2C library because it was very well documented. The only external components needed by the TMP275 are a bypass capacitor between VCC and GND and two pull-up resistors required on SDA and SCL lines.

All the I2C stuff is handled by the library, so I only had to write a couple of lines of code to get the temperature out of the sensor:

 i2c_start_wait(sensor+I2C_WRITE);	// set device address and write mode
 i2c_write(0x0);			// write pointer register 00000000 to select temp register
 i2c_rep_start(sensor+I2C_READ);	//set device address and read mode
 temp_high=i2c_readAck();		// Read high byte of temperature
 temp_low=i2c_readNak();		// Read low byte of temperature

After reading the temperature from the sensor I had to display it on the 4 digit display. For that I had to write a display macro, which figures out the numbers and how to display them, basically I used software multiplexing. I even tested it on negative temperatures by placing the sensor in my fridge :). The readout was correct because I checked with another thermometer.

These new type of digital sensors are great, because you don’t have to worry about analog to digital conversion, all the  ADC is done inside the sensor. I mainly started working with this sensor because I want to incorporate a temperature reading function into a future project. Now that this part is done, is time to move onto the next one, ultrasonic range finder, which I’m guessing wont be as easy as the temperature reading.

I tried to comment every line of my code, but if you feel you don’t understand something, just post a comment and I’ll reply.