Camilo Ruiz
/
tmp112HelloWorld
TMP112 and TMP102 Interface Example
Revision 0:373d0c67a763, committed 2016-05-12
- Comitter:
- CamiloRuiz
- Date:
- Thu May 12 21:51:31 2016 +0000
- Commit message:
- Tmp112 and tmp102 interface example
Changed in this revision
diff -r 000000000000 -r 373d0c67a763 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu May 12 21:51:31 2016 +0000 @@ -0,0 +1,57 @@ +/* +Copyright (c) 2016 Camilo Ruiz + +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. +*/ + +//this should work with tmp102 too +//I do not use negative values on my application, this code has to be tweaked to support it +//I do not use extended mode, this code has to be tweaked to support it + +//greetings from Colombia :) + +//I used TinyBle platform from SeeedStudio + +#include "mbed.h" +#include "tiny_ble.h" +#include "TMP112.h" + +TMP112 TempSensor(p3, p4,0x90); + +DigitalOut power_out(POWER_OUT_EN); //power output TinyBle +Serial pc(UART_TX, UART_RX); + +int main() +{ + pc.baud(115200); + power_out=1; //enable power output TinyBle + wait(1.0); //give sensor some time to powerup + TempSensor.writeCFG(TMP112_12BITS| TMP112_CFG_1FAULT | TMP112_CFG_ALERT_LOW | TMP112_CFG_TM_COMP_MODE + | TMP112_CFG_ON | TMP112_CFG_CR_1Hz | TMP112_CFG_EM_OFF); + TempSensor.write_TM_Htemp(25.5); + TempSensor.write_TM_Ltemp(25.0); + while(1) { + pc.printf("temperature: %f \n", TempSensor.readTemperature()); + pc.printf("tresh High: %f \n", TempSensor.readTM_Htemp()); + pc.printf("tresh low: %f \n", TempSensor.readTM_Ltemp()); + pc.printf("Config: %X \n", TempSensor.readCFG()); + wait(1.0); + + } +} \ No newline at end of file
diff -r 000000000000 -r 373d0c67a763 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu May 12 21:51:31 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/7c328cabac7e \ No newline at end of file
diff -r 000000000000 -r 373d0c67a763 tiny_ble.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tiny_ble.h Thu May 12 21:51:31 2016 +0000 @@ -0,0 +1,22 @@ + +#ifndef __TINY_BLE_H__ +#define __TINY_BLE_H__ + +#define LED_GREEN p21 +#define LED_RED p22 +#define LED_BLUE p23 +#define BUTTON_PIN p17 +#define BATTERY_PIN p1 + +#define MPU6050_SDA p12 +#define MPU6050_SCL p13 +#define MPU6050_INTERRUPT p14 + +#define UART_TX p9 +#define UART_RX p11 +#define UART_CTS p8 +#define UART_RTS p10 + +#define POWER_OUT_EN p30 + +#endif // __TINY_BLE_H__
diff -r 000000000000 -r 373d0c67a763 tmp112.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tmp112.lib Thu May 12 21:51:31 2016 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/users/CamiloRuiz/code/tmp112/#2fbb524f0609