A sample program showing how to read data from the RHT03

Dependencies:   RHT03 mbed

Files at this revision

API Documentation at this revision

Comitter:
tristanjph
Date:
Wed Aug 29 09:23:38 2012 +0000
Child:
1:567ee42e14cb
Commit message:
Initial commit

Changed in this revision

RHT03.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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RHT03.lib	Wed Aug 29 09:23:38 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/tristanjph/code/RHT03/#2bd5cffd60d0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Aug 29 09:23:38 2012 +0000
@@ -0,0 +1,20 @@
+#include "mbed.h"
+#include "RHT03.h" //Include neede to use the RHT03 lib
+
+int main()
+{
+    int done=0;
+    float temp,hum;
+
+    RHT03 humtemp(p24); //Initalise the RHT03 (change pin number to the pin its connected to)
+
+    while(!done) //Loop keeps running until RHT03 is read succesfully
+    {
+        wait(2); //Needed to make sure the sensor has time to initalise and so its not polled too quickly
+        if(humtemp.readData() == RHT_ERROR_NONE) done=1; //Request data from the RHT03
+    }
+    
+    temp = humtemp.getTemperatureC(); //Gets the current temperature in centigrade
+    hum = humtemp.getHumidity(); //Gets the current humidity in percentage
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Aug 29 09:23:38 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/10b9abbe79a6
\ No newline at end of file