Hello World program for HYT temp & humidity sensor

Dependencies:   HYT mbed

Hello Word program for HYT temp & humidity sensor library. MCU perform polling and then sends data to PC via serial interface once a second.

/media/uploads/Ksenia/8.png

Connection

Remember to use pull-up resisrors to communicate with sensor by I2C

/media/uploads/Ksenia/freshpaint-20-2016.09.16-10.37.03.png

Files at this revision

API Documentation at this revision

Comitter:
Ksenia
Date:
Wed Sep 14 15:54:13 2016 +0000
Commit message:
Initial commit

Changed in this revision

HYT.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 cd8ba9e5f346 HYT.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HYT.lib	Wed Sep 14 15:54:13 2016 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/Ksenia/code/HYT/#cb02bfe8cf44
diff -r 000000000000 -r cd8ba9e5f346 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Sep 14 15:54:13 2016 +0000
@@ -0,0 +1,34 @@
+#include "mbed.h"
+#include "HYT.h"
+
+Serial              pc(USBTX, USBRX);
+Ticker              timeKeeping;
+// for SLSTK3400A board
+HYT                 SENSOR (PD6, PD7); // sda, scl
+// for WIZwiki-W7500P board
+//HYT               SENSOR (D14, D15); // sda, scl
+// for ATSAMD21-XPRO board
+//HYT               SENSOR (PA08, PA09); // sda, scl
+
+
+// HYT sensor polling cycle
+void dataUpdate(void)
+{
+    SENSOR.MRCommand();
+    wait_ms(100);
+    SENSOR.DFCommand();
+}
+
+void secondsCallback(void) {
+    pc.printf("Humidity level: %.1f\r\n%", SENSOR.humidity);
+    pc.printf("Temperature level: %.1f\r\n%", SENSOR.temperature);
+    pc.printf("-------------------------------\r\n%", SENSOR.temperature);
+}
+
+int main()
+{
+    timeKeeping.attach(&secondsCallback, 1.0f);
+    while(1) {
+        dataUpdate();
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r cd8ba9e5f346 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Sep 14 15:54:13 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/6c34061e7c34
\ No newline at end of file