Basic test program for the SHT2x library

Dependencies:   mbed SHT2x

Files at this revision

API Documentation at this revision

Comitter:
ssozonoff
Date:
Sat Apr 23 19:11:56 2011 +0000
Commit message:
Basic testing of the SHT21 library

Changed in this revision

SHT2x.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 4429ab6153c1 SHT2x.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SHT2x.lib	Sat Apr 23 19:11:56 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/ssozonoff/code/SHT2x/#2464fed17980
diff -r 000000000000 -r 4429ab6153c1 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Apr 23 19:11:56 2011 +0000
@@ -0,0 +1,41 @@
+#include "mbed.h"
+#include "SHT2x.h"
+
+SHT2x sht21(p9, p10);
+
+DigitalOut myled(LED2);
+Serial pc(USBTX, USBRX);
+
+int rh, temp;
+int error;
+float relHumidity, temperature;
+int userRegister;
+
+int main() {
+    sht21.SHT2x_SoftReset();
+    
+    error |= sht21.SHT2x_ReadUserRegister(&userRegister);  //get actual user reg
+    userRegister = (userRegister & ~SHT2x_RES_MASK) | SHT2x_RES_12_14BIT;
+    error |= sht21.SHT2x_WriteUserRegister(&userRegister); //write changed user reg    
+    
+    while (1) {
+        myled = 1;
+        
+        pc.printf("program start\r\n");
+        error |= sht21.SHT2x_MeasureHM(HUMIDITY, &rh);
+        error |= sht21.SHT2x_MeasureHM(TEMP, &temp);
+        
+        if (error > 0)
+            pc.printf("error code %d \r\n", error);
+
+        relHumidity = sht21.SHT2x_CalcRH(rh);
+        temperature = sht21.SHT2x_CalcTemperatureC(temp);
+        
+        pc.printf("RH value -> %f \r\n", relHumidity);
+        pc.printf("Temp in C -> %f \r\n", temperature);
+        pc.printf("Dew point %f \r\n", sht21.SHT2x_GetDewpoint(relHumidity, temperature));
+
+        myled = 0;
+        wait(1);
+    }
+}
diff -r 000000000000 -r 4429ab6153c1 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Apr 23 19:11:56 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/63bcd7ba4912