Lieven Hollevoet
/
Si7005_example
Example program for the Si7005 library.
Revision 0:ca4f984d7f18, committed 2013-04-10
- Comitter:
- LievenHollevoet
- Date:
- Wed Apr 10 08:47:12 2013 +0000
- Commit message:
- Example program for the Si7005 library
Changed in this revision
diff -r 000000000000 -r ca4f984d7f18 Si7005.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Si7005.lib Wed Apr 10 08:47:12 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/LievenHollevoet/code/Si7005/#6fbf67893ca2
diff -r 000000000000 -r ca4f984d7f18 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Apr 10 08:47:12 2013 +0000 @@ -0,0 +1,38 @@ +#include "mbed.h" +#include "Si7005.h" + +Si7005 rh(p28, p27); // sda, scl +DigitalOut rh_cs_n(p26); // Chip select signal +Serial uart(USBTX, USBRX); // tx, rx + +int main() { + while(1) { + // Enable RH sensor + rh_cs_n = 0; + // Let it startup! + wait(0.05); + + char id; + id = rh.readID(); + uart.printf("Sensor type: %02X\n", id); + + // Relative humidity measurement + rh.startMeasurement(SI7005_RH); + while (!rh.conversionDone()) { + wait(0.01); + } + int measurement = rh.readResult(SI7005_RH); + uart.printf("RH = %i procent\n", measurement); + + // Start temperature measurement + rh.startMeasurement(SI7005_T); + while (!rh.conversionDone()){ + wait (0.01); + } + measurement = rh.readResult(SI7005_T); + uart.printf("Temp = %i degrees C\n", measurement); + + // Disable the sensor + rh_cs_n = 1; + } +}
diff -r 000000000000 -r ca4f984d7f18 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Wed Apr 10 08:47:12 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/5e5da4a5990b \ No newline at end of file