temperature sensor application as a temperature based fan using the FRDM -K64F board

Dependencies:   DHT mbed

Fork of frdm_Grove_PIR_Example by NXP

Committer:
Akshayiupui
Date:
Sat May 07 01:27:48 2016 +0000
Revision:
1:5c2fc62b9c0a
Parent:
0:d444f103013a
Temperature sensor application as an temperature based fan control with the help of FRDM-K64F board.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
GregC 0:d444f103013a 1
Akshayiupui 1:5c2fc62b9c0a 2
GregC 0:d444f103013a 3 #include "mbed.h"
Akshayiupui 1:5c2fc62b9c0a 4 #include "DHT.h"
Akshayiupui 1:5c2fc62b9c0a 5
Akshayiupui 1:5c2fc62b9c0a 6 DHT sensor(D4, DHT11);
Akshayiupui 1:5c2fc62b9c0a 7 DigitalOut vcc(PTA1);
Akshayiupui 1:5c2fc62b9c0a 8 int main()
GregC 0:d444f103013a 9 {
Akshayiupui 1:5c2fc62b9c0a 10 int error = 0;
Akshayiupui 1:5c2fc62b9c0a 11 float h = 0.0f, c = 0.0f, dp = 0.0f, dpf = 0.0f;
Akshayiupui 1:5c2fc62b9c0a 12
GregC 0:d444f103013a 13 while(1) {
Akshayiupui 1:5c2fc62b9c0a 14 wait(2.0f);
Akshayiupui 1:5c2fc62b9c0a 15 error = sensor.readData();
Akshayiupui 1:5c2fc62b9c0a 16 if (0 == error) {
Akshayiupui 1:5c2fc62b9c0a 17 c = sensor.ReadTemperature(CELCIUS);
Akshayiupui 1:5c2fc62b9c0a 18 dp = sensor.CalcdewPoint(c, h);
Akshayiupui 1:5c2fc62b9c0a 19 dpf = sensor.CalcdewPointFast(c, h);
Akshayiupui 1:5c2fc62b9c0a 20 printf("Temperature in Celcius: %4.2f\n", c);
Akshayiupui 1:5c2fc62b9c0a 21 } else {
Akshayiupui 1:5c2fc62b9c0a 22 printf("Error: %d\n", error);
Akshayiupui 1:5c2fc62b9c0a 23 } while((int)c > 30){vcc=!vcc;}
Akshayiupui 1:5c2fc62b9c0a 24 while((int)c<30 ){vcc=0;}
GregC 0:d444f103013a 25 }
GregC 0:d444f103013a 26 }
Akshayiupui 1:5c2fc62b9c0a 27
Akshayiupui 1:5c2fc62b9c0a 28