test code for hdc1080 humidity sensor

Dependencies:   hdc1080 mbed

Fork of Nucleo-F303K8-SSD1306_OLED by Joseph Ellsworth

Files at this revision

API Documentation at this revision

Comitter:
joeata2wh
Date:
Wed Sep 14 02:36:12 2016 +0000
Parent:
4:53d68b18bd43
Child:
6:c5430cdc9861
Commit message:
working version

Changed in this revision

hdc1080.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
--- a/hdc1080.lib	Thu Jul 28 02:21:19 2016 +0000
+++ b/hdc1080.lib	Wed Sep 14 02:36:12 2016 +0000
@@ -1,1 +1,1 @@
-https://developer.mbed.org/users/joeata2wh/code/hdc1080/#36666c79a60f
+https://developer.mbed.org/users/joeata2wh/code/hdc1080/#dd3a07b44fe2
--- a/main.cpp	Thu Jul 28 02:21:19 2016 +0000
+++ b/main.cpp	Wed Sep 14 02:36:12 2016 +0000
@@ -1,14 +1,9 @@
 /* Example of Reading  TI HDC1080 sensor using STM F303K8 dev board
 
-  NOTE:  As of 7/27/2016 with my custom board from seed studio I have
-  been unsucesful getting a response from the sensor.  This may be due
-  to bad soldering so ordered a pre-made module to see if it works. 
-
   By Joseph Ellsworth CTO of A2WH
   Take a look at A2WH.com Producing Water from Air using Solar Energy
   March-2016 License: https://developer.mbed.org/handbook/MIT-Licence
   Please contact us http://a2wh.com for help with custom design projects.
-
  */
 
 #include "mbed.h"
@@ -17,24 +12,27 @@
 //Pin Defines for I2C Bus
 #define D_SDA                  PB_7 // specific for Nucleo-F303K8
 #define D_SCL                  PB_6 // specific for Nucleo-F303K8
-I2C i2c(D_SDA, D_SCL);
+I2C hdc_i2c(D_SDA, D_SCL);
 #include "hdc1080.h"
 
-
 // Host PC Communication channels
 Serial pc(USBTX, USBRX); // tx, rx
-char buff[100];
-
 DigitalOut myled(LED1);
 
-
 int main()
 {
     pc.baud(9600);
-    while(1) {
+    printf("\r\\nHDC1080 Test\r\n");
+    while(1) {        
+        myled = !myled;
         hdc_begin();
-        hdc_readManufactId();
-        hdc_readTemp();     
-        hdc_readHumid();  
+        uint16_t manId = hdc_readManufactId();
+        float tempC = hdc_readTemp();     
+        float humid = hdc_readHumid();  
+        unsigned long  serNum = hdc_readSerial();
+        printf("manId=x%x, tempC=%0.3f humid=%0.3f serfNum=%lu\r\n",
+          manId, tempC, humid, serNum);
+        wait(3.0f);
     }
 }
+