testje
Revision 0:0a5a8dae0fa1, committed 2016-04-12
- Comitter:
- boddeke
- Date:
- Tue Apr 12 13:57:44 2016 +0000
- Child:
- 1:7baef237c57c
- Commit message:
- initial checkin
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libmDot.lib Tue Apr 12 13:57:44 2016 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/teams/MultiTech/code/libmDot/#0b4eb17d07ae
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Tue Apr 12 13:57:44 2016 +0000
@@ -0,0 +1,27 @@
+#include "mbed.h"
+
+// Read temperature from TH06
+
+// p6 PA_8 / XBEE_PWM0 / XBEE_RSSI / I2C_SCL D15
+// p7 PC_9 / XBEE_PWM1 / I2C_SDA D14
+I2C i2c(PC_9,PA_8);
+
+const int addr = 0x80;
+
+int main() {
+ char cmd[2];
+
+ while (1) {
+ cmd[0] = 0xf3;
+ i2c.write(addr, cmd, 1);
+
+ wait(0.5);
+
+ i2c.read(addr, cmd, 2);
+
+ float temp_code = (cmd[0]<<8)|cmd[1];
+ float temp = 175.72*temp_code/65535.0-46.85;
+
+ printf("Temp = %.2f\r\n", temp);
+ }
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Apr 12 13:57:44 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/4f6c30876dfa \ No newline at end of file