Library for ADT7410 I2C temperature sensor. Use this instead of TMP102 when you need to measure temperatures lower than -40 degrees C. The device is guaranteed to work at -55 C but will actually read lower temps. See http://mbed.org/users/tkreyche/notebook/adt7140-i2c-temperature-sensor/ for more info.
Dependents: BLE_ADT7410_TMP102_Sample BLE_HTM_HRM1017 BLENano_SimpleTemplate_temp_170802 BLENano_SimpleTemplate_temp_170813 ... more
Diff: ADT7410.h
- Revision:
- 0:380ac1ac0101
- Child:
- 1:257d9e026cc4
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ADT7410.h Tue Feb 01 18:57:41 2011 +0000 @@ -0,0 +1,105 @@ +/* +Copyright (c) 2011 Tom Kreyche tkreyche@well.com + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +/** Servo control class, based on a PwmOut +* +* Example: +* @code + +#include "mbed.h" +#include "ADT7410.h" + +ADT7410 tempSens1(p28, p27, 0x90, 100000); + +int main() { + + // reset sensor to default values + tempSens1.reset(); + + // read the config register, should be default + printf("Config: 0x%x\n", tempSens1.getConfig()); + + // reduce sample rate to save power + tempSens1.setConfig(ONE_SPS_MODE); + + // check config register was set correctly + printf("Config: 0x%x\n", tempSens1.getConfig()); + + // get temperature every two seconds + while (1) { + + printf("Deg C %f\n", tempSens1.getTemp()); + wait(2); + } +} + +* @endcode +*/ + +#ifndef ADT7410_H +#define ADT7410_H + +#include "mbed.h" + +// sensor register addresses +// only a partial list, don't use them all +#define TEMP_REG_ADDR 0x00 +#define CONFIG_REG_ADDR 0x03 +#define RESET 0x2F + +// configuration register values +// only a partial list, don't use them all +#define ONE_SPS_MODE 0x40 + +//Library for the ADT7410 temperature sensor + +class ADT7410 +{ + +public: + + // Creates an instance of the class. + // Connect module at I2C address addr using I2C port pins sda and scl + ADT7410(PinName sda, PinName scl, char addr, int hz); + + //Destroys instance. + ~ADT7410(); + + //Reads the current temperature. + float getTemp(); + + //Set config register + void setConfig(char regVal); + + //Get config register + char getConfig(); + + //Send reset + void reset(); + +private: + I2C i2c; + char busAddr; + +}; + +#endif