Library for taking datasheet corrected relative humidity measurements with HIH-4030 humidity sensor
Revision 0:114b50b41972, committed 2013-06-23
- Comitter:
- simonbarker
- Date:
- Sun Jun 23 11:53:24 2013 +0000
- Commit message:
- HIH-4030 library with comments
Changed in this revision
hih-4030.cpp | Show annotated file Show diff for this revision Revisions of this file |
hih-4030.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 114b50b41972 hih-4030.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hih-4030.cpp Sun Jun 23 11:53:24 2013 +0000 @@ -0,0 +1,33 @@ +#include "hih-4030.h" + +HIH4030::HIH4030(PinName vout):vout_(vout) { + +} + +/* + gives humidity as a ratio of VDD +*/ +float HIH4030::ratioHumidity(){ + //poll analogue in + return vout_.read(); +} + +/* + gives humidity as a percentage - numbers taken from datasheet +*/ + +float HIH4030::sensorRH(){ + //poll analogue in + sample = vout_.read()*5; //multiply by 5 as sample is a decimal of Vdd + return (sample-0.958)/0.0307; +} + +/* + gives humidity adjusted for temperature (in degrees C) - numbers taken from datasheet +*/ + +float HIH4030::trueSensorRH(float temperature){ + float rh = sensorRH(); + temperature = temperature*0.00216; + return rh/(1.0546 - temperature); +} \ No newline at end of file
diff -r 000000000000 -r 114b50b41972 hih-4030.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hih-4030.h Sun Jun 23 11:53:24 2013 +0000 @@ -0,0 +1,19 @@ +#ifndef HIH4030_h +#define HIH4030_h + +#include "mbed.h" + +class HIH4030{ + +public: + HIH4030(PinName vout); + float ratioHumidity(); + float sensorRH(); + float trueSensorRH(float temperature); + +private: + AnalogIn vout_; + float sample; + float temperature; +}; +#endif \ No newline at end of file