TMP102 is I2C based Temperature Sensor
TMP102.h@0:640bac35614f, 2016-01-25 (annotated)
- Committer:
- dwijaybane
- Date:
- Mon Jan 25 10:59:27 2016 +0000
- Revision:
- 0:640bac35614f
TMP102 I2C based Temperature Sensor Library Created
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dwijaybane | 0:640bac35614f | 1 | |
dwijaybane | 0:640bac35614f | 2 | /* Copyright (C) 2016,Edutech IoT Team, mbed.org, MIT License |
dwijaybane | 0:640bac35614f | 3 | * |
dwijaybane | 0:640bac35614f | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
dwijaybane | 0:640bac35614f | 5 | * and associated documentation files (the "Software"), to deal in the Software without restriction, |
dwijaybane | 0:640bac35614f | 6 | * including without limitation the rights to use, copy, modify, merge, publish, distribute, |
dwijaybane | 0:640bac35614f | 7 | * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is |
dwijaybane | 0:640bac35614f | 8 | * furnished to do so, subject to the following conditions: |
dwijaybane | 0:640bac35614f | 9 | * |
dwijaybane | 0:640bac35614f | 10 | * The above copyright notice and this permission notice shall be included in all copies or |
dwijaybane | 0:640bac35614f | 11 | * substantial portions of the Software. |
dwijaybane | 0:640bac35614f | 12 | * |
dwijaybane | 0:640bac35614f | 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
dwijaybane | 0:640bac35614f | 14 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
dwijaybane | 0:640bac35614f | 15 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
dwijaybane | 0:640bac35614f | 16 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
dwijaybane | 0:640bac35614f | 17 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
dwijaybane | 0:640bac35614f | 18 | */ |
dwijaybane | 0:640bac35614f | 19 | |
dwijaybane | 0:640bac35614f | 20 | #ifndef TMP102_H |
dwijaybane | 0:640bac35614f | 21 | #define TMP102_H |
dwijaybane | 0:640bac35614f | 22 | |
dwijaybane | 0:640bac35614f | 23 | #include "mbed.h" |
dwijaybane | 0:640bac35614f | 24 | |
dwijaybane | 0:640bac35614f | 25 | //!Library for the TI TMP102 temperature sensor. |
dwijaybane | 0:640bac35614f | 26 | /*! |
dwijaybane | 0:640bac35614f | 27 | The TMP102 is an I2C digital temperature sensor in a small SOT563 package, with a 0.0625C resolution and 0.5C accuracy. |
dwijaybane | 0:640bac35614f | 28 | */ |
dwijaybane | 0:640bac35614f | 29 | class TMP102 |
dwijaybane | 0:640bac35614f | 30 | { |
dwijaybane | 0:640bac35614f | 31 | public: |
dwijaybane | 0:640bac35614f | 32 | //!Creates an instance of the class. |
dwijaybane | 0:640bac35614f | 33 | /*! |
dwijaybane | 0:640bac35614f | 34 | Connect module at I2C address addr using I2C port pins sda and scl. |
dwijaybane | 0:640bac35614f | 35 | TMP102 |
dwijaybane | 0:640bac35614f | 36 | \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> |
dwijaybane | 0:640bac35614f | 37 | */ |
dwijaybane | 0:640bac35614f | 38 | TMP102(PinName sda, PinName scl, int addr); |
dwijaybane | 0:640bac35614f | 39 | |
dwijaybane | 0:640bac35614f | 40 | /*! |
dwijaybane | 0:640bac35614f | 41 | Destroys instance. |
dwijaybane | 0:640bac35614f | 42 | */ |
dwijaybane | 0:640bac35614f | 43 | ~TMP102(); |
dwijaybane | 0:640bac35614f | 44 | |
dwijaybane | 0:640bac35614f | 45 | //!Reads the current temperature. |
dwijaybane | 0:640bac35614f | 46 | /*! |
dwijaybane | 0:640bac35614f | 47 | Reads the temperature register of the TMP102 and converts it to a useable value. |
dwijaybane | 0:640bac35614f | 48 | */ |
dwijaybane | 0:640bac35614f | 49 | float read_12b(); |
dwijaybane | 0:640bac35614f | 50 | float read_13b(); |
dwijaybane | 0:640bac35614f | 51 | |
dwijaybane | 0:640bac35614f | 52 | private: |
dwijaybane | 0:640bac35614f | 53 | I2C m_i2c; |
dwijaybane | 0:640bac35614f | 54 | int m_addr; |
dwijaybane | 0:640bac35614f | 55 | |
dwijaybane | 0:640bac35614f | 56 | }; |
dwijaybane | 0:640bac35614f | 57 | |
dwijaybane | 0:640bac35614f | 58 | #endif |