A simply library for the LM75B I2C temperature sensor

Dependents:   LM75B-HelloWorld app-board-Sprint-SMS-LM75B SprintUSBModemWebsocketTest-Temp app-board-Ethernet-Websocket ... more

Committer:
chris
Date:
Fri Oct 26 21:40:51 2012 +0000
Revision:
1:6a70c9303bbe
Parent:
0:1be38995591b
Removed header from .cpp file

Who changed what in which revision?

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