└── Weather monitoring system using IOT /Weather monitoring system using IOT: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #defineBLYNK_PRINTSerial 4 | 5 | #include 6 | 7 | #include 8 | 9 | #include 10 | 11 | LiquidCrystal_I2Clcd(0x3F,16,2); 12 | 13 | // IF IN LCD IS NOT PRINTED ANY THING THEN CHANGE THIS VALUE 0x3F TO 0x27 14 | 15 | DHTdht(D3,DHT11);//(sensorpin,sensortype) 16 | 17 | BlynkTimertimer; 18 | 19 | char auth[] = "RbYKCQOGKPpIL7xhMM-w4up342uvtoK0"; //Enter the Auth code which was 20 | 21 | sendbyBlink 22 | chassid[]="karur"; //Enter your WIFI Name 23 | 24 | charpass[]= "karur001"; //Enter your WIFI Password 25 | 26 | void weather() { 27 | 28 | float h = dht.readHumidity(); 29 | 30 | float t = dht.readTemperature(); 31 | 32 | int r = analogRead(A0); 33 | 34 | bool l = digitalRead(D4); 35 | 36 | r = map(r, 0, 1023, 100, 0); 37 | 38 | if (isnan(h) || isnan(t)) { 39 | 40 | Serial.println("Failed to read from DHT sensor!"); 41 | 42 | return; 43 | 44 | } 45 | 46 | Blynk.virtualWrite(V0, t); //V0 is for Temperature 47 | 48 | Blynk.virtualWrite(V1, h); //V1 is for Humidity 49 | 50 | Blynk.virtualWrite(V2, r); //V2 is for Rainfall 51 | 52 | if (l == 0) { 53 | 54 | WidgetLED led1(V3); 55 | 56 | led1.on(); 57 | 58 | lcd.setCursor(9, 1); 59 | 60 | lcd.print("L :"); 61 | 62 | lcd.print("High"); 63 | 64 | lcd.print(" "); 65 | 66 | } else if (l == 1) 67 | 68 | { 69 | 70 | WidgetLED led1(V3); 71 | 72 | led1.off(); 73 | lcd.setCursor(9, 1); 74 | 75 | lcd.print("L :"); 76 | 77 | lcd.print("Low"); 78 | 79 | lcd.print(" "); 80 | 81 | } 82 | 83 | lcd.setCursor(0, 0); 84 | 85 | lcd.print("T :"); 86 | 87 | lcd.print(t); 88 | 89 | lcd.setCursor(0, 1); 90 | 91 | lcd.print("H :"); 92 | 93 | lcd.print(h); 94 | 95 | lcd.setCursor(9, 0); 96 | 97 | lcd.print("R :"); 98 | 99 | lcd.print(r); 100 | 101 | lcd.print(" "); 102 | 103 | } 104 | 105 | void setup() { 106 | 107 | Serial.begin(9600); // See the connection status in Serial Monitor 108 | 109 | lcd.begin(); 110 | 111 | lcd.backlight(); 112 | 113 | Blynk.begin(auth, ssid, pass); 114 | 115 | dht.begin(); 116 | 117 | // Setup a function to be called every second 118 | 119 | timer.setInterval(10L, weather); 120 | 121 | } 122 | 123 | void loop() { 124 | Blynk.run(); // Initiates Blynk 125 | 126 | timer.run(); // Initiates SimpleTimer 127 | 128 | } 129 | --------------------------------------------------------------------------------