Library for TMPx75 Temperature Sensor
Revision 1:ba7de6d38992, committed 2018-12-12
- Comitter:
- jake123jake123
- Date:
- Wed Dec 12 21:53:42 2018 +0000
- Parent:
- 0:ba71558a5d0a
- Commit message:
- example code in .h
Changed in this revision
TMPx75.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r ba71558a5d0a -r ba7de6d38992 TMPx75.h --- a/TMPx75.h Wed Dec 12 21:48:42 2018 +0000 +++ b/TMPx75.h Wed Dec 12 21:53:42 2018 +0000 @@ -93,3 +93,52 @@ #endif +/* +// Example program for reading and writing to the TMPx75 temperature sensor +// Jacobus L de Jager 2018 + +#include "mbed.h" +#include "TMPx75.h" + +Serial pc(SERIAL_TX, SERIAL_RX, 115200); +I2C i2c(I2C_SDA,I2C_SCL); +TMPx75 tmp75(&i2c, 0x48); + +int main() +{ + printf("\nTMPx75 example\n"); + + while(1) + { + pc.printf("\nreading temperature\n"); + float temp = tmp75.read_temperature(); + printf("temp = %f\n", temp); + + pc.printf("writing config\n"); + tmp75.write_configuration(RESOLUTION_12_BITS); + + pc.printf("reading config\n"); + int config = tmp75.read_configuration(); + printf("config register = 0x%x\n", config); + + pc.printf("reading T LOW\n"); + float T_LOW = tmp75.read_T_LOW(); + printf("T LOW = %f\n", temp); + + pc.printf("reading T HIGH\n"); + float T_HIGH = tmp75.read_T_HIGH(); + printf("T HIGH = %f\n", temp); + + pc.printf("writing T LOW\n"); + tmp75.write_T_LOW(25); + + pc.printf("writing T HIGH\n"); + tmp75.write_T_HIGH(50); + + printf("done!\n"); + + wait(0.5); + } +} + +*/