benjo

Dependencies:   mbed

Fork of I2C_MCP9808_V2 by Advanced_Instrumentation_2019

Files at this revision

API Documentation at this revision

Comitter:
csoulen
Date:
Mon Nov 05 14:23:50 2018 +0000
Parent:
0:80fb3c4621be
Commit message:
ben

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Oct 23 19:39:34 2018 +0000
+++ b/main.cpp	Mon Nov 05 14:23:50 2018 +0000
@@ -15,7 +15,7 @@
 // Note MCP9808 also needs VCC (3.3 V) and GND
 
 float TempValue;
-float data[20];
+float data[20],data_f[20];
 char data_write[3], data_read[2];
 int ii, status;
 int main() {
@@ -54,10 +54,11 @@
             data_read[0] = data_read[0] & 0x1F;  // clear flag bits for temperature
             
             data[i] = (data_read[0] * 16) + (data_read[1] / 16.0); // combine two bytes
+            data_f[i] = (data[i]+40)*9/5-40;
             // Display the flags, if you wish
             // pc.printf("Flags are %i \n\r",status);
             // This displays to the user
-            pc.printf("%i Temperature is %3.1f\n\r",i,data[i]);
+            pc.printf("%i Temperature is %3.1f C and %3.1f F\n\r",i,data[i],data_f[i]);
             i=i+1;
             wait(1);
         }