IoT Weather Monitoring System

by TECHATRONIC in Circuits > Arduino

12 Views, 0 Favorites, 0 Comments

IoT Weather Monitoring System

1624199761464-1536x1152.jpg

Hello Guys, Welcome to another very interesting and useful project tutorial based on NodeMCU and various other modules. In today's article the main components are NodeMCU, DHT11, I2C LCD, Rain Sensor and various other sensors and modules. Along with this, we'll also use BLYNK App to fetch the data through Wi-Fi. So in short, the project needed constant Wi-Fi connection to make effect.

The functioning of each sensor is different and plays a crucial role in working, so for this you can view its original post and get detailed information about each. In brief, DHT11 sensor collect the Data related to Temperature and Humidity from our nearby environment also the Rain sensor used to collect the rain data and push it over BLYNK server via Wi-Fi. To set up the App interface and other small and large explanation about each step can be viewed and read on the main website, as here it will take a lot of time.

There are also some warning related to the project, first the sensor DHT11 is good for small scale projects but for more advanced version and application. I'd advise you to use some better quality products to boost the effectivity of the project as a whole.

Material Required

1624199761489-1024x768.jpg

  • NodeMCU (EP8266 MOD)
  • DHT11
  • Rain Sensor
  • LDR Sensor
  • 16×2 LCD with I2C module
  • Breadboard
  • Jumper Wires
  • Blynk App with Wi-Fi connection

Circuit Diagram

Nodemcu_Weather_Station_n-1536x854.jpg

Code

0258.png
// TECHATRONIC.COM
// I2C LIBRARY
// https://github.com/fdebrabander/Arduino-LiquidCrystal-I2C-library
// BLYNK LIBRARY
// https://github.com/blynkkk/blynk-library
// ESP8266 LIBRARY
// https://github.com/ekstrand/ESP8266wifi
// Adafruit DHT sensor library:
// https://github.com/adafruit/DHT-sensor-library

 
#include <LiquidCrystal_I2C.h>
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <DHT.h>

LiquidCrystal_I2C lcd(0x3F, 16, 2); 
// IF IN LCD IS NOT PRINTED ANY THING THEN CHANGE THIS VALUE 0x3F TO 0x27
DHT dht(D3, DHT11); //(sensor pin,sensor type)
BlynkTimer timer;

char auth[] = " Your-auth-code"; //Enter the Auth code which was send by Blink
char ssid[] = "your-wifi-ssid";  //Enter your WIFI Name
char pass[] = "your-wifi-password";  //Enter your WIFI Password

void weather() {
  float h = dht.readHumidity();
  float t = dht.readTemperature();
  int r = analogRead(A0);
  bool l = digitalRead(D4);

  r = map(r, 0, 1023, 100, 0);
  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }

  Blynk.virtualWrite(V0, t);  //V0 is for Temperature
  Blynk.virtualWrite(V1, h);  //V1 is for Humidity
  Blynk.virtualWrite(V2, r);  //V2 is for Rainfall

  if (l == 0) {
    WidgetLED led1(V3);
    led1.on();
    lcd.setCursor(9, 1);
    lcd.print("L :");
    lcd.print("High");
    lcd.print(" ");
  } else if (l == 1) {
    WidgetLED led1(V3);
    led1.off();
    lcd.setCursor(9, 1);
    lcd.print("L :");
    lcd.print("Low");
    lcd.print(" ");
  }

  lcd.setCursor(0, 0);
  lcd.print("T :");
  lcd.print(t);

  lcd.setCursor(0, 1);
  lcd.print("H :");
  lcd.print(h);

  lcd.setCursor(9, 0);
  lcd.print("R :");
  lcd.print(r);
  lcd.print("  ");

}

void setup() {
  Serial.begin(9600); // See the connection status in Serial Monitor
  lcd.begin();
  lcd.backlight();
  Blynk.begin(auth, ssid, pass);
  dht.begin();
  // Setup a function to be called every second
  timer.setInterval(10L, weather);
}

void loop() {
  Blynk.run(); // Initiates Blynk
  timer.run(); // Initiates SimpleTimer
}
For explanation of each section and function of code also to view the steps of setting up BLYNK App interface visit original post of the article.