.

Dependencies:   DHT TextLCD mbed

Committer:
masavucic
Date:
Fri Mar 10 20:37:52 2017 +0000
Revision:
0:9f541bb6b622
two sensors

Who changed what in which revision?

UserRevisionLine numberNew contents of line
masavucic 0:9f541bb6b622 1 #include "mbed.h"
masavucic 0:9f541bb6b622 2 #include "TextLCD.h"
masavucic 0:9f541bb6b622 3 #include "DHT.h"
masavucic 0:9f541bb6b622 4
masavucic 0:9f541bb6b622 5 TextLCD lcd(p19, p20, p21, p22, p23, p24); // rs, e, d4-d7
masavucic 0:9f541bb6b622 6 DigitalOut alarmLedLeft(p25);
masavucic 0:9f541bb6b622 7 DigitalOut alarmLedRight(p26);
masavucic 0:9f541bb6b622 8 DHT sensorLeft(p27, DHT11);
masavucic 0:9f541bb6b622 9 DHT sensorRight(p28, DHT11);
masavucic 0:9f541bb6b622 10
masavucic 0:9f541bb6b622 11
masavucic 0:9f541bb6b622 12
masavucic 0:9f541bb6b622 13 int main() {
masavucic 0:9f541bb6b622 14 lcd.printf("Hello World!\n");
masavucic 0:9f541bb6b622 15 lcd.printf("Hello World!\n");
masavucic 0:9f541bb6b622 16 lcd.printf(" temp i vlaga");
masavucic 0:9f541bb6b622 17
masavucic 0:9f541bb6b622 18 float tempLeft =0.0;
masavucic 0:9f541bb6b622 19 float tempRight =0.0;
masavucic 0:9f541bb6b622 20 float leftHumidity =0.0;
masavucic 0:9f541bb6b622 21 float rightHumidity =0.0;
masavucic 0:9f541bb6b622 22
masavucic 0:9f541bb6b622 23 while (1)
masavucic 0:9f541bb6b622 24 {
masavucic 0:9f541bb6b622 25
masavucic 0:9f541bb6b622 26 wait(2);
masavucic 0:9f541bb6b622 27
masavucic 0:9f541bb6b622 28 lcd.cls();
masavucic 0:9f541bb6b622 29 int err0 = sensorLeft.readData();
masavucic 0:9f541bb6b622 30 tempLeft = sensorLeft.ReadTemperature(CELCIUS);
masavucic 0:9f541bb6b622 31 leftHumidity = sensorLeft.ReadHumidity();
masavucic 0:9f541bb6b622 32 lcd.cls();
masavucic 0:9f541bb6b622 33 lcd.locate(0, 0);
masavucic 0:9f541bb6b622 34 lcd.printf("Temp Left %3.1f\n", tempLeft);
masavucic 0:9f541bb6b622 35 lcd.locate(0, 1);
masavucic 0:9f541bb6b622 36 lcd.printf("Humidity %3.1f \n", leftHumidity);
masavucic 0:9f541bb6b622 37
masavucic 0:9f541bb6b622 38
masavucic 0:9f541bb6b622 39 wait(2);
masavucic 0:9f541bb6b622 40
masavucic 0:9f541bb6b622 41 int err1 = sensorRight.readData();
masavucic 0:9f541bb6b622 42 tempRight = sensorRight.ReadTemperature(CELCIUS);
masavucic 0:9f541bb6b622 43 rightHumidity = sensorRight.ReadHumidity();
masavucic 0:9f541bb6b622 44 lcd.cls();
masavucic 0:9f541bb6b622 45 lcd.locate(0, 0);
masavucic 0:9f541bb6b622 46 lcd.printf("Temp right %3.1f\n", tempRight);
masavucic 0:9f541bb6b622 47 lcd.locate(0, 1);
masavucic 0:9f541bb6b622 48 lcd.printf("Humidity %3.1f \n", rightHumidity);
masavucic 0:9f541bb6b622 49
masavucic 0:9f541bb6b622 50
masavucic 0:9f541bb6b622 51
masavucic 0:9f541bb6b622 52
masavucic 0:9f541bb6b622 53
masavucic 0:9f541bb6b622 54
masavucic 0:9f541bb6b622 55 if(tempLeft>35)
masavucic 0:9f541bb6b622 56 alarmLedLeft=true;
masavucic 0:9f541bb6b622 57 if(tempRight>35)
masavucic 0:9f541bb6b622 58 alarmLedRight =true;
masavucic 0:9f541bb6b622 59
masavucic 0:9f541bb6b622 60
masavucic 0:9f541bb6b622 61
masavucic 0:9f541bb6b622 62 }
masavucic 0:9f541bb6b622 63
masavucic 0:9f541bb6b622 64 }