Description
TMP102 - Temperature Sensor
Specs
- Accurate: -40 – 125 oC
- Operating: -55 – 150 oC
- 0.0625 oC Resolution
- 1.4 – 3.6 V Input
- 10 µA
- 260 oC/W
I2C bus Interface
Goals
The goal of the test is to read the temperature of the h1surrounding environment with the TMP102 component.
Results
This was our second temperature component tested on our breadboard. Watch the video to see the circuit and results of the test.
Source for the code is from Bildr.com, How's the weather? TMP102 + Arduino
The code:
//Arduino 1.0+ Only //Arduino 1.0+ Only ////////////////////////////////////////////////////////////////// //©2011 bildr //Released under the MIT License - Please reuse change and share //Simple code for the TMP102, simply prints temperature via serial ////////////////////////////////////////////////////////////////// #includeint tmp102Address = 0x48; void setup(){ Serial.begin(9600); Wire.begin(); } void loop(){ float celsius = getTemperature(); Serial.print("Celsius: "); Serial.println(celsius); float fahrenheit = (1.8 * celsius) + 32; Serial.print("Fahrenheit: "); Serial.println(fahrenheit); delay(200); //just here to slow down the output. You can remove this } float getTemperature(){ Wire.requestFrom(tmp102Address,2); byte MSB = Wire.read(); byte LSB = Wire.read(); //it's a 12bit int, using two's compliment for negative int TemperatureSum = ((MSB << 8) | LSB) >> 4; float celsius = TemperatureSum*0.0625; return celsius; }
No comments:
Post a Comment