Library for the LM75A Temperature Sensor

Dependents:   LM75A_Test_Code MQTT_and_Temperature_Sensore_LM75 2021_Temp_y_Acelerom_V4enlace_serial

Committer:
edodm85
Date:
Wed Jun 27 21:20:27 2012 +0000
Revision:
0:94c821cb7f80
Child:
1:19dc98c810a5
Rev 3

Who changed what in which revision?

UserRevisionLine numberNew contents of line
edodm85 0:94c821cb7f80 1 /* Author: Edoardo De Marchi */
edodm85 0:94c821cb7f80 2 /* Copyright (C) 2012 mbed.org, MIT License
edodm85 0:94c821cb7f80 3 *
edodm85 0:94c821cb7f80 4 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
edodm85 0:94c821cb7f80 5 * and associated documentation files (the "Software"), to deal in the Software without restriction,
edodm85 0:94c821cb7f80 6 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
edodm85 0:94c821cb7f80 7 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
edodm85 0:94c821cb7f80 8 * furnished to do so, subject to the following conditions:
edodm85 0:94c821cb7f80 9 *
edodm85 0:94c821cb7f80 10 * The above copyright notice and this permission notice shall be included in all copies or
edodm85 0:94c821cb7f80 11 * substantial portions of the Software.
edodm85 0:94c821cb7f80 12 *
edodm85 0:94c821cb7f80 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
edodm85 0:94c821cb7f80 14 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
edodm85 0:94c821cb7f80 15 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
edodm85 0:94c821cb7f80 16 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
edodm85 0:94c821cb7f80 17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
edodm85 0:94c821cb7f80 18 */
edodm85 0:94c821cb7f80 19
edodm85 0:94c821cb7f80 20
edodm85 0:94c821cb7f80 21
edodm85 0:94c821cb7f80 22
edodm85 0:94c821cb7f80 23 #pragma once
edodm85 0:94c821cb7f80 24
edodm85 0:94c821cb7f80 25 #include "mbed.h"
edodm85 0:94c821cb7f80 26
edodm85 0:94c821cb7f80 27
edodm85 0:94c821cb7f80 28 #define TEMP_REG_ADDR 0x00 // Temperature address
edodm85 0:94c821cb7f80 29
edodm85 0:94c821cb7f80 30
edodm85 0:94c821cb7f80 31 /* Library for the LM75A temperature sensor.
edodm85 0:94c821cb7f80 32 The LM75A is an I2C digital temperature sensor in a small SOP-8 package,
edodm85 0:94c821cb7f80 33 with a 0.5C resolution and 2C accuracy
edodm85 0:94c821cb7f80 34 */
edodm85 0:94c821cb7f80 35
edodm85 0:94c821cb7f80 36 class LM75A{ // Creates an instance of the class
edodm85 0:94c821cb7f80 37 public:
edodm85 0:94c821cb7f80 38
edodm85 0:94c821cb7f80 39 /** Create an LM75A object connected to the specified I2C object and using the specified deviceAddress
edodm85 0:94c821cb7f80 40 *
edodm85 0:94c821cb7f80 41 * @param sda The I2C port data
edodm85 0:94c821cb7f80 42 * @param scl The I2C port clock
edodm85 0:94c821cb7f80 43 * @param addr The address of the MMA7660FC
edodm85 0:94c821cb7f80 44 */
edodm85 0:94c821cb7f80 45 LM75A(PinName sda, PinName scl, int addr);
edodm85 0:94c821cb7f80 46
edodm85 0:94c821cb7f80 47
edodm85 0:94c821cb7f80 48 /** Destroys an LM75A object
edodm85 0:94c821cb7f80 49 *
edodm85 0:94c821cb7f80 50 */
edodm85 0:94c821cb7f80 51 ~LM75A();
edodm85 0:94c821cb7f80 52
edodm85 0:94c821cb7f80 53 /** Reads the current temperature
edodm85 0:94c821cb7f80 54 *
edodm85 0:94c821cb7f80 55 * @param returns Return the Temperature value
edodm85 0:94c821cb7f80 56 */
edodm85 0:94c821cb7f80 57 float read_T();
edodm85 0:94c821cb7f80 58
edodm85 0:94c821cb7f80 59 /** Reads from specified LM75A register
edodm85 0:94c821cb7f80 60 *
edodm85 0:94c821cb7f80 61 * @param addr Pointer register
edodm85 0:94c821cb7f80 62 * @param returns Return the data from the register
edodm85 0:94c821cb7f80 63 */
edodm85 0:94c821cb7f80 64 char read_reg(char addr);
edodm85 0:94c821cb7f80 65
edodm85 0:94c821cb7f80 66 /** Writes to specified LM75A register
edodm85 0:94c821cb7f80 67 *
edodm85 0:94c821cb7f80 68 * @param addr Pointer register
edodm85 0:94c821cb7f80 69 * @param data Data to write
edodm85 0:94c821cb7f80 70 */
edodm85 0:94c821cb7f80 71 void write_reg(char addr, char data);
edodm85 0:94c821cb7f80 72
edodm85 0:94c821cb7f80 73
edodm85 0:94c821cb7f80 74 private:
edodm85 0:94c821cb7f80 75 I2C m_i2c;
edodm85 0:94c821cb7f80 76 int m_addr;
edodm85 0:94c821cb7f80 77 };
edodm85 0:94c821cb7f80 78