Example code for Si7020 Digital humidity and temperature sensor.

Dependencies:   Si7020

Basic example code for using the Si7020.

Files at this revision

API Documentation at this revision

Comitter:
kgills
Date:
Fri Apr 17 15:55:06 2015 +0000
Commit message:
Creating example code for Si7020

Changed in this revision

Si7020.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
diff -r 000000000000 -r 5e155faa10f0 Si7020.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Si7020.lib	Fri Apr 17 15:55:06 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/kgills/code/Si7020/#9a1febb56203
diff -r 000000000000 -r 5e155faa10f0 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Apr 17 15:55:06 2015 +0000
@@ -0,0 +1,27 @@
+#include <stdio.h>
+#include "mbed.h"
+#include "Si7020.h"
+
+I2C i2c(I2C_SDA, I2C_SCL);
+Si7020 si(&i2c);
+
+int main()
+{
+    while(1) {
+
+        float humid;
+        if(si.getHumidity(&humid) != 0) {
+            printf("Error getting humidity\n");
+            humid = -1;
+        }
+
+        float temp;
+        if(si.getTemperature(&temp) != 0) {
+            printf("Error getting temperature");
+            temp = -1;
+        } 
+        printf("Humidity = %f%% Temperature = %fC\n", humid, temp);
+
+        wait(1);
+    }
+}
\ No newline at end of file