Library for the LM75A Temperature Sensor
Dependents: LM75A_Test_Code MQTT_and_Temperature_Sensore_LM75 2021_Temp_y_Acelerom_V4enlace_serial
LM75A.h
00001 /* Author: Edoardo De Marchi */ 00002 /* Copyright (C) 2012 mbed.org, MIT License 00003 * 00004 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 00005 * and associated documentation files (the "Software"), to deal in the Software without restriction, 00006 * including without limitation the rights to use, copy, modify, merge, publish, distribute, 00007 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 00008 * furnished to do so, subject to the following conditions: 00009 * 00010 * The above copyright notice and this permission notice shall be included in all copies or 00011 * substantial portions of the Software. 00012 * 00013 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 00014 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00015 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 00016 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00017 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00018 */ 00019 00020 00021 00022 00023 #pragma once 00024 00025 #include "mbed.h" 00026 00027 00028 #define TEMP_REG_ADDR 0x00 // Temperature address 00029 00030 00031 /* Library for the LM75A temperature sensor. 00032 The LM75A is an I2C digital temperature sensor in a small SOP-8 package, 00033 with a 0.5C resolution and 2C accuracy 00034 */ 00035 00036 class LM75A{ // Creates an instance of the class 00037 public: 00038 00039 /** Create an LM75A object connected to the specified I2C object and using the specified deviceAddress 00040 * 00041 * @param sda The I2C port data 00042 * @param scl The I2C port clock 00043 * @param addr The address of the MMA7660FC 00044 */ 00045 LM75A(PinName sda, PinName scl, int addr); 00046 00047 00048 /** Destroys an LM75A object 00049 * 00050 */ 00051 ~LM75A(); 00052 00053 /** Reads the current temperature 00054 * 00055 * @param returns Return the Temperature value 00056 */ 00057 float read_T(); 00058 00059 /** Reads from specified LM75A register 00060 * 00061 * @param addr Pointer register 00062 * @param returns Return the data from the register 00063 */ 00064 char read_reg(char addr); 00065 00066 /** Writes to specified LM75A register 00067 * 00068 * @param addr Pointer register 00069 * @param data Data to write 00070 */ 00071 void write_reg(char addr, char data); 00072 00073 00074 private: 00075 I2C m_i2c; 00076 int m_addr; 00077 char reg_addr; 00078 }; 00079
Generated on Thu Jul 21 2022 08:21:58 by 1.7.2