温度センサのプログラム(PCに表示)

Dependencies:   mbed

Committer:
MIKUNAGATA
Date:
Sat Nov 16 06:14:54 2019 +0000
Revision:
0:4b059e3c0849
TEMP

Who changed what in which revision?

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