Engravity-CDU / Mbed 2 deprecated CDUFinal

Dependencies:   4DGL mbed ConfigFile

Fork of 4DGLtest by Stephane ROCHON

Files at this revision

API Documentation at this revision

Comitter:
WillemBraat
Date:
Sun Jun 29 11:59:45 2014 +0000
Parent:
4:302c2ac97db9
Child:
6:904d00252480
Commit message:
Added Internal Temperature Sensor LM75B

Changed in this revision

temp.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/temp.cpp	Sun Jun 29 11:59:45 2014 +0000
@@ -0,0 +1,22 @@
+#include "mbed.h"
+ 
+// Read temperature from LM75BD
+ 
+I2C i2c(p28, p27);//use same pins as KBD
+ 
+const int addr = 0x90;
+ 
+int CDU_GetTemp() {
+    char cmd[2];
+
+        cmd[0] = 0x01;
+        cmd[1] = 0x00;
+        i2c.write(addr, cmd, 2);
+ 
+        cmd[0] = 0x00;
+        i2c.write(addr, cmd, 1);
+        i2c.read(addr, cmd, 2);
+        //convert to Degrees Celsius
+        float tmp = (float((cmd[0]<<8)|cmd[1]) / 256.0);
+        return (tmp );
+}