Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 0:fb4d631a5994, committed 2014-10-28
- Comitter:
- 201209650
- Date:
- Tue Oct 28 09:02:51 2014 +0000
- Commit message:
- bde
Changed in this revision
diff -r 000000000000 -r fb4d631a5994 RHT03.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/RHT03.lib Tue Oct 28 09:02:51 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/tristanjph/code/RHT03/#21ede1fe79b7
diff -r 000000000000 -r fb4d631a5994 main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Tue Oct 28 09:02:51 2014 +0000
@@ -0,0 +1,64 @@
+#include "mbed.h"
+#include "RHT03.h" //Include neede to use the RHT03 lib
+
+Serial pc(USBTX, USBRX);
+I2C i2c(p28,p27); //sda=p28. scl=p27
+
+Serial xBee(p9, p10); //xBee pins
+
+int done=0;
+float temp,hum;
+
+RHT03 humtemp(p21); //Initalise the RHT03 (change pin number to the pin its connected to)
+
+DigitalOut lysdiode(p14);
+
+void tickerFunction() {
+ //I2C CO2
+ const char cmd[4] = {0x22,0x00,0x08,0x2A};
+ i2c.write(0xD0, cmd, 4);
+ char data[4] = {0x00,0x00,0x00,0x00};
+ wait_ms(50);
+ i2c.read(0xD1, data, 4);
+ int CO2i2c = (int)data[1]*0x100 + (int)data[2];
+
+
+
+ //Print data
+ pc.printf("CO2: %d\n", CO2i2c);
+
+ //Hum & Temp
+ 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
+ }
+
+ done = 0;
+ temp = humtemp.getTemperatureC(); //Gets the current temperature in centigrade
+ hum = humtemp.getHumidity(); //Gets the current humidity in percentage
+
+ if (hum > 50 || temp > 23 || CO2i2c > 1000) {
+ lysdiode = 0;
+ } else {
+ lysdiode = 1;
+ }
+
+//Print data
+ pc.printf("Hum: %0.2f, Temp: %0.2f\n", hum, temp);
+ xBee.printf("xxxx;indeklima;%0.2f;%0.2f;%i\r\n", hum, temp, CO2i2c);
+
+}
+
+Ticker ticker;
+
+int main()
+{
+
+ pc.printf("Hello\n");
+
+ i2c.frequency(100000); //mBed default frequency = 100kHz = max frequency of CO2 sensor
+ ticker.attach(&tickerFunction, 5.0); //update every 1 sec
+
+ while (1) {
+ }
+}
diff -r 000000000000 -r fb4d631a5994 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Oct 28 09:02:51 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/552587b429a1 \ No newline at end of file