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:4429ab6153c1, committed 2011-04-23
- Comitter:
- ssozonoff
- Date:
- Sat Apr 23 19:11:56 2011 +0000
- Commit message:
- Basic testing of the SHT21 library
Changed in this revision
--- /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
--- /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);
+ }
+}
--- /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
SHT21 temperature and humidity sensor