Library for the TI TMP102 I2C temperature sensor.

Dependents:   TextLCD_HelloWorld MMEx_Challenge PCF2119_16X2_LCD_test TMP102_Serial_Logger ... more

Committer:
donatien
Date:
Fri Jul 23 10:45:58 2010 +0000
Revision:
2:38cc3a283e6d
Parent:
1:67bed4966cdc
Child:
3:b469676e9a9e

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
donatien 0:d93532a1d699 1
donatien 0:d93532a1d699 2 /*
donatien 0:d93532a1d699 3 Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com)
donatien 0:d93532a1d699 4
donatien 0:d93532a1d699 5 Permission is hereby granted, free of charge, to any person obtaining a copy
donatien 0:d93532a1d699 6 of this software and associated documentation files (the "Software"), to deal
donatien 0:d93532a1d699 7 in the Software without restriction, including without limitation the rights
donatien 0:d93532a1d699 8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
donatien 0:d93532a1d699 9 copies of the Software, and to permit persons to whom the Software is
donatien 0:d93532a1d699 10 furnished to do so, subject to the following conditions:
donatien 0:d93532a1d699 11
donatien 0:d93532a1d699 12 The above copyright notice and this permission notice shall be included in
donatien 0:d93532a1d699 13 all copies or substantial portions of the Software.
donatien 0:d93532a1d699 14
donatien 0:d93532a1d699 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
donatien 0:d93532a1d699 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
donatien 0:d93532a1d699 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
donatien 0:d93532a1d699 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
donatien 0:d93532a1d699 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
donatien 0:d93532a1d699 20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
donatien 0:d93532a1d699 21 THE SOFTWARE.
donatien 0:d93532a1d699 22 */
donatien 0:d93532a1d699 23
donatien 1:67bed4966cdc 24 #ifndef TMP102_H
donatien 1:67bed4966cdc 25 #define TMP102_H
donatien 0:d93532a1d699 26
donatien 0:d93532a1d699 27 #include "mbed.h"
donatien 0:d93532a1d699 28
donatien 0:d93532a1d699 29 //!Library for the TI TMP102 temperature sensor.
donatien 0:d93532a1d699 30 /*!
donatien 0:d93532a1d699 31 The TMP102 is an I2C digital temperature sensor in a small SOT563 package, with a 0.0625C resolution and 0.5C accuracy.
donatien 0:d93532a1d699 32 */
donatien 0:d93532a1d699 33 class TMP102
donatien 0:d93532a1d699 34 {
donatien 0:d93532a1d699 35 public:
donatien 0:d93532a1d699 36 //!Creates an instance of the class.
donatien 0:d93532a1d699 37 /*!
donatien 0:d93532a1d699 38 Connect module at I2C address addr using I2C port pins sda and scl.
donatien 1:67bed4966cdc 39 TMP102
donatien 2:38cc3a283e6d 40 \param addr <table><tr><th>A0 pin connection</th><th>Address</th></tr><tr><td>GND</td><td>0x90</td></tr><tr><td>V+</td><td>0x92</td></tr><tr><td>SDA</td><td>0x94</td></tr><tr><td>SCL</td><td>0x96</td></tr></table>
donatien 0:d93532a1d699 41 */
donatien 0:d93532a1d699 42 TMP102(PinName sda, PinName scl, int addr);
donatien 0:d93532a1d699 43
donatien 0:d93532a1d699 44 /*!
donatien 0:d93532a1d699 45 Destroys instance.
donatien 0:d93532a1d699 46 */
donatien 0:d93532a1d699 47 ~TMP102();
donatien 0:d93532a1d699 48
donatien 0:d93532a1d699 49 //!Read the current temperature.
donatien 0:d93532a1d699 50 /*!
donatien 0:d93532a1d699 51 Reads the temperature register of the TMP102 and converts it to a useable value.
donatien 0:d93532a1d699 52 */
donatien 0:d93532a1d699 53 float read();
donatien 0:d93532a1d699 54
donatien 0:d93532a1d699 55 private:
donatien 0:d93532a1d699 56 I2C m_i2c;
donatien 0:d93532a1d699 57 int m_addr;
donatien 0:d93532a1d699 58
donatien 0:d93532a1d699 59 };
donatien 0:d93532a1d699 60
donatien 0:d93532a1d699 61 #endif