TMP006 IR Temperature Sensor
.
Description
In this project Survy and I interfaced the mbed micro controller with the new TMP006 IR Temperature Sensor. You will only need the sensor, the mbed, and a few jumper wires to get it working. From https://www.sparkfun.com/products/11859:
Quote:
"The TMP006 Breakout can measure the temperature of an object without making contact with it. By using a thermopile to detect and absorb the infrared energy an object is emitting, the TMP006 Breakout can determine how hot or cold the object is.
The TMP006 Breakout has a wide temperature detection range of -40°C to 125°C and an optimal operating voltage of 3.3V to 5V (tolerant up to 7V max). This breakout works great with most micro controllers connecting via the I2C bus."
The sensor uses a thermopile to take in infrared radiating from the object and uses these changes to determine the object's temperature.
The Schematic
Since the TMP006 uses I2C communications, you can use two sets of pins on the mbed.
- p9 & p10
- p27 & p28
The TMP006 also has the ability to chain up to eight sensors. The ADDR0 and ADDR1 pins are used for this purpose. For this demo, we will only use one sensor, so these two pins will be grounded.
MBED | TMP006 |
---|---|
p9 | SDA |
p10 | SCL |
Vout | Vcc |
GND | GND |
GND | ADDR0 |
GND | ADDR1 |
The Code
The main.cpp code below is an easy demo to read the current temperature and display it on the console.
main.cpp
#include "mbed.h" #include "TMP006.h" #define Address 0x80 TMP006 sensor(p9, p10, Address); int main() { while(1) { printf("Temperature: %f \r \n", sensor.readObjTempC(Address)); wait(1.0); } }
Below are the libraries.
Import libraryTMP006_lib
These are the methods to interface the TMP006 sensor with the mbed controller.
Public Member Functions
Function | Description | |
---|---|---|
void | config(uint8_t addr, uint16_t samples) | Configures sensor, use before reading from it |
int16_t | readRawDieTemperature(uint8_t addr) | Read raw sensor temperature |
int16_t | readRawVoltage(uint8_t addr) | Read raw thermopile voltage |
double | readObjTempC(uint8_t addr) | Calculate object temperature (C) based on raw sensor temp and thermopile voltage |
double | readObjTempF(uint8_t addr) | Calculate object temperature (F) based on raw sensor temp and thermopile voltage |
double | readDieTempC(uint8_t addr) | Caculate sensor temperature (C) based on raw reading |
double | readDieTempF(uint8_t addr) | Caculate sensor temperature (F) based on raw reading |
Here is a quick video of the output of the sample program. link here if video does not show
Troubleshooting
- If you have trouble communicating with the sensor, try this: The I2C documentation originally said for us to use 0x40 as our I2C address. We later found out that the address needs to be shifted once to the left, making it 0x80.
2 comments on TMP006 IR Temperature Sensor:
Please log in to post comments.
i2c address of TMP006 (with adr1, adr2 shorted to gnd) should be 0x40. but that's the upper 7-bit of a byte, the last bit indicates read/write. the way mbed handles i2c address byte is confusing.
It takes 8-bit address byte, and automatically set the last bit as 0 or 1 depending on read/write. That's why TMP006 address 0x40 becomes 0x80.