White wizard Temperature and Humidity sensor module. See this page : http://wizard.nestegg.jp/thsensor.html

Dependencies:   mbed

main.cpp

Committer:
halfpitch
Date:
2011-08-02
Revision:
0:13b6d85b6dbd

File content as of revision 0:13b6d85b6dbd:

//HIH-5031
//0% = 0.6V
//80% = 2.0V
//H% = (80-0)/(2-0.6)*(Vout-0.6V)

//MCP9700
//0C = 0.5V
//100C = 1.5V
//T = 100*(Vout-0.5V)

#include "mbed.h"

DigitalOut myled(LED1);
AnalogIn ad19(p19);
AnalogIn ad20(p20);

int main() {
    float   ADdata19,ADdata20,temp,humid;
    
    while(1) {
        ADdata19 = ad19.read()*3.3;
        ADdata20 = (ad20.read()*3.3);
        
        //temp = ((ADdata20*1000.0)-500.0)/10.0;//temp
        temp = 100*(ADdata20-0.5);//temp
        //humid = 43.24*(ADdata19-0.4);
        humid = (80.0/1.4)*(ADdata19-0.6);
        
        printf("p19 = %f V, p20 = %f V , H = %f , T = %f C \n", ADdata19,  ADdata20, humid, temp);
        myled = 1;
        wait(0.2);
        myled = 0;
        wait(0.2);
    }
}