Jacobus de Jager
/
TMPx75_example
Example for TMPx75 Temperature Sensor Library
Revision 0:6850ea3a801c, committed 2018-12-12
- Comitter:
- jake123jake123
- Date:
- Wed Dec 12 22:01:16 2018 +0000
- Commit message:
- first commit
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TMPx75.lib Wed Dec 12 22:01:16 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/jake123jake123/code/TMPx75/#ba7de6d38992
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Dec 12 22:01:16 2018 +0000 @@ -0,0 +1,46 @@ +// 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); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Dec 12 22:01:16 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/3a7713b1edbc \ No newline at end of file