Example for TMPx75 Temperature Sensor Library

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
jake123jake123
Date:
Wed Dec 12 22:01:16 2018 +0000
Commit message:
first commit

Changed in this revision

TMPx75.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 6850ea3a801c TMPx75.lib
--- /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
diff -r 000000000000 -r 6850ea3a801c main.cpp
--- /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);         
+    }
+}
diff -r 000000000000 -r 6850ea3a801c mbed.bld
--- /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