HIH-4030 fork to handle 3.3v input voltage

Fork of HIH-4030 by Simon Barker

Committer:
simonbarker
Date:
Sun Jun 23 11:53:24 2013 +0000
Revision:
0:114b50b41972
Child:
1:f0ae84350631
HIH-4030 library with comments

Who changed what in which revision?

UserRevisionLine numberNew contents of line
simonbarker 0:114b50b41972 1 #include "hih-4030.h"
simonbarker 0:114b50b41972 2
simonbarker 0:114b50b41972 3 HIH4030::HIH4030(PinName vout):vout_(vout) {
simonbarker 0:114b50b41972 4
simonbarker 0:114b50b41972 5 }
simonbarker 0:114b50b41972 6
simonbarker 0:114b50b41972 7 /*
simonbarker 0:114b50b41972 8 gives humidity as a ratio of VDD
simonbarker 0:114b50b41972 9 */
simonbarker 0:114b50b41972 10 float HIH4030::ratioHumidity(){
simonbarker 0:114b50b41972 11 //poll analogue in
simonbarker 0:114b50b41972 12 return vout_.read();
simonbarker 0:114b50b41972 13 }
simonbarker 0:114b50b41972 14
simonbarker 0:114b50b41972 15 /*
simonbarker 0:114b50b41972 16 gives humidity as a percentage - numbers taken from datasheet
simonbarker 0:114b50b41972 17 */
simonbarker 0:114b50b41972 18
simonbarker 0:114b50b41972 19 float HIH4030::sensorRH(){
simonbarker 0:114b50b41972 20 //poll analogue in
simonbarker 0:114b50b41972 21 sample = vout_.read()*5; //multiply by 5 as sample is a decimal of Vdd
simonbarker 0:114b50b41972 22 return (sample-0.958)/0.0307;
simonbarker 0:114b50b41972 23 }
simonbarker 0:114b50b41972 24
simonbarker 0:114b50b41972 25 /*
simonbarker 0:114b50b41972 26 gives humidity adjusted for temperature (in degrees C) - numbers taken from datasheet
simonbarker 0:114b50b41972 27 */
simonbarker 0:114b50b41972 28
simonbarker 0:114b50b41972 29 float HIH4030::trueSensorRH(float temperature){
simonbarker 0:114b50b41972 30 float rh = sensorRH();
simonbarker 0:114b50b41972 31 temperature = temperature*0.00216;
simonbarker 0:114b50b41972 32 return rh/(1.0546 - temperature);
simonbarker 0:114b50b41972 33 }