HIH-4030 fork to handle 3.3v input voltage

Fork of HIH-4030 by Simon Barker

Revision:
1:f0ae84350631
Parent:
0:114b50b41972
--- 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