![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
capt
Diff: main.cpp
- Revision:
- 0:db7c4dcecc70
diff -r 000000000000 -r db7c4dcecc70 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Jan 26 01:17:07 2017 +0000 @@ -0,0 +1,35 @@ +#include "mbed.h" +#include "DHT11.h" + +DHT11 sensor(D4); + + + +//--------------- +int main() +{ + //serial config + Serial serial(PA_0,PA_1); /*PA_0=A0=TX PA_1=A0=RX*/ + serial.baud(9600); + serial.format(8,SerialBase::None,1); + serial.printf("\r\nDHT Test program"); + serial.printf("\r\n****************\r\n"); + //char tmp[30];//="AT$SS=00 12 FF 42 \r\n";//$SS + + + while(1){ + + int s,T,H; + s = sensor.readData(); + T=sensor.readTemperature(); + H=sensor.readHumidity(); + if (s != DHT11::OK) { + serial.printf("Error!\r\n"); + } + else { + serial.printf("AT$SS=%x%x\r\n", T,H); + } + + wait(60); +} +}