Outputs humidity to the serial terminal.

Dependencies:   mbed

Revision:
1:e59c75779477
Parent:
0:a8fcc4098c24
Child:
2:4edb77a5ab26
--- a/main.cpp	Tue Jun 23 18:40:14 2015 +0000
+++ b/main.cpp	Mon Jul 27 20:22:38 2015 +0000
@@ -18,8 +18,8 @@
 
 Constructor
 dataPin: the IO pin connected to the sensor's data pin (pin 15)
-supplyVoltage: the voltage supplying the humidity sensor (pins 1,3 - typ. 5.0)
-referenceVoltage: motor controller's reference voltage 
+supplyVoltage: the voltage supplying the humidity sensor (pins 1,3 - for the HIH5030 3.3 V typical)
+referenceVoltage: motor controller's reference voltage (3.3V for the LPC1768)
 */
 
 HIH4010::HIH4010(float dataPin, float supplyVoltage, float referenceVoltage){
@@ -80,17 +80,18 @@
 int main()
 {
     float ad[5];
-    float vdiv = (3.3 / 65536); //3.3 is the reference voltage (AnalogIn measures from 0V to 3.3V) and 4096 is the highest number that can be represented by a 12 bit unsigned
+    float supplyvoltage = 3.3;
+    float referencevoltage = 3.3;
+    float vdiv = (3.3 / 65536); //3.3 is the reference voltage (AnalogIn measures from 0V to 3.3V) and 65536 is the highest number that can be represented by a 16 bit unsigned
     while( 1 ){
-        ad[0] = (float)ain_UseA.read_u16() * vdiv;  //returns 12 bit value representing the current input voltage normalized 
+        ad[0] = (float)ain_UseA.read_u16() * vdiv;  //16-bit unsigned short representing the current input voltage, normalised to a 16-bit value 
         ad[1] = (float)ain_UseB.read_u16() * vdiv;
         ad[2] = (float)ain_UseC.read_u16() * vdiv;
         ad[3] = (float)ain_UseD.read_u16() * vdiv;
         ad[4] = (float)ain_UseE.read_u16() * vdiv;
-        pc.printf("%5.3f,%5.3f,%5.3f,%5.3f,%5.3f\r\n ", ad[0],ad[1],ad[2],ad[3],ad[4]);
-        HIH4010 humidity(ad[0], 3.3, 3.3);
-        //pc.printf("%5.3f\r\n" , humidity.vout());
-        pc.printf("%5.3f\r\n", humidity.getSensorRH());
+        //pc.printf("%5.3f,%5.3f,%5.3f,%5.3f,%5.3f\r\n ", ad[0],ad[1],ad[2],ad[3],ad[4]);
+        HIH4010 humidity(ad[0], supplyvoltage, referencevoltage);
+        pc.printf("%5.3f\r\nHumidity: ", humidity.getSensorRH());
     myled = 1;
     wait(2.0);
     myled = 0;