HIH-4030 fork to handle 3.3v input voltage
Fork of HIH-4030 by
Revision 1:f0ae84350631, committed 2013-08-11
- Comitter:
- ddollar
- Date:
- Sun Aug 11 19:58:52 2013 +0000
- Parent:
- 0:114b50b41972
- Commit message:
- tweak for 3.3v
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 |
--- a/hih-4030.cpp Sun Jun 23 11:53:24 2013 +0000 +++ b/hih-4030.cpp Sun Aug 11 19:58:52 2013 +0000 @@ -1,33 +1,13 @@ #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(); +HIH4030::HIH4030(PinName pin) { + m_analog_in = new AnalogIn(pin); } -/* - 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; + return (((m_analog_in->read() * 3.3) - 0.631) / 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); + return (sensorRH() / (1.0546 - (temperature * 0.00216))); } \ No newline at end of file
--- a/hih-4030.h Sun Jun 23 11:53:24 2013 +0000 +++ b/hih-4030.h Sun Aug 11 19:58:52 2013 +0000 @@ -6,13 +6,13 @@ class HIH4030{ public: - HIH4030(PinName vout); - float ratioHumidity(); + HIH4030(PinName analog_in); + float sensorRH(); float trueSensorRH(float temperature); private: - AnalogIn vout_; + AnalogIn *m_analog_in; float sample; float temperature; };