Embedded for 11U68 DHT LCD Sensor Demo

Dependencies:   DHT TextLCD mbed

Fork of TextLCD_HelloWorld by Simon Ford

main.cpp

Committer:
Hapi_Tech
Date:
2015-07-21
Revision:
3:ad558d3aaa98
Parent:
2:ad0b044d0a10

File content as of revision 3:ad558d3aaa98:

/*TextLCD indicate RHT sensor
LCD::LinkMan TC1602E-25A 
RHT sensor::DHT11
Main board::Embedded for 11U68 HAPI-Tech-Solution,Inc
Shiled::Arduino Universal shiled P-06877
*/
#include "mbed.h"
#include "TextLCD.h"
#include "DHT.h"
DHT sensor(P1_25,SEN11301P); // Use the SEN11301P sensor
TextLCD lcd(P1_28, P2_3, P0_2, P0_9, P0_8, P1_29,TextLCD::LCD16x2); // rs, e, d4-d7

int main() {
    int err;
    lcd.locate(0,0);
    lcd.printf("DHT Test program\n");
    wait(1); // wait 1 second for device stable status
    while (1) {
        err = sensor.readData();
        if (err == 0) {
            lcd.locate(0,0);
            lcd.printf("Room Temp:%4.2f C\n",sensor.ReadTemperature(CELCIUS));
            lcd.locate(0,1);
            lcd.printf("Room RH%:%4.2f %\n",sensor.ReadHumidity());
            wait_ms(1500);
            lcd.cls();
            lcd.locate(0,0);
            lcd.printf("Dew point is %4.2f \n",sensor.CalcdewPoint(sensor.ReadTemperature(CELCIUS), sensor.ReadHumidity()));
            wait_ms(1500);
            lcd.cls();
        }else if (err != 0); 
            lcd.locate(0,0);
            lcd.printf("Err %i \n",err);
        wait(1);
    }
}