How to Make a Weather Monitoring System with ESP32 Board

How to Make a Weather Monitoring System with ESP32 Board

Hello and welcome back. In this project, we will learn how to make a weather monitoring system with an ESP32 board. For that, I have used the LDR sensor, DHT11 sensor, Rain sensor, and BMP-180 sensor. Therefore, we can get the Temperature, Humidity, Pressure, Light, and Rainfall values. To make the system more user-friendly, I have utilized the Blynk mobile and web dashboards, giving you the freedom to choose which one you prefer.

(adsbygoogle = window.adsbygoogle || []).push({});

The LDR Sensor is used to measure the intensity of light in the environment, while the DHT11 Sensor is a digital temperature and humidity sensor that can measure temperature and humidity levels accurately. Also, if you want more accuracy values, please use the DHT22 sensor for that. Also, the Rain Sensor is used to detect the presence of water, enabling us to obtain rainfall data, and the BMP-180 Sensor is a barometric pressure sensor that can measure atmospheric pressure and temperature. But I have used only pressure values. By using all of these sensors together, we can gather a comprehensive set of weather data, which can be used for various applications such as agriculture, weather forecasting, and more. It depends on your requirements.

  • If you want to do this project with the ESP8266 board, Please use this link.

OK, let’s do this project step by step. The required components are given below.

Disclosure: These Amazon links are Affiliate links. As an Amazon Associate, I earn from qualifying purchases.

(adsbygoogle = window.adsbygoogle || []).push({});

Step 1

Firstly, identify these components.

Step 2

Secondly, connect the ESP32 board to the ESP32 adapter. But don’t worry, you can use two breadboards for that.

Step 3

Thirdly, place the sensors one by one on the breadboard.

(adsbygoogle = window.adsbygoogle || []).push({});

Step 4

Next, connect the sensors one by one to the ESP32 board. Use the circuit diagram below for that.

How to Make a Weather Monitoring System with ESP32 Board

Step 5

And then, connect the LCD screen to the ESP32 board.

(adsbygoogle = window.adsbygoogle || []).push({});

Step 6

Now, let’s create the Blynk web dashboard. For that, follow the instructions below.

  • First, go to the Blynk website and create a new account using your email. Then, log into your account and create a new template for this project. I have named it “Weather Monitoring System” and selected the hardware as ESP32.
  • Next, click the datastreams tab and create five data streams to get the sensor values. For that, use the information below.
  • Virtual PIN / Name –> Temperature / PIN –> V0 / MIN –> 0 / MAX –> 100
  • Virtual PIN / Name –> Humidity / PIN –> V1 / MIN –> 0 / MAX –> 100
  • Virtual PIN / Name –> Rainfall / PIN –> V2 / MIN –> 0 / MAX –> 100
  • Virtual PIN / Name –> Pressure / PIN –> V3 / MIN –> 300 / MAX –> 1100
  • Virtual PIN / Name –> Light value / PIN –> V4 / MIN –> 0 / MAX –> 1
  • Now, click the web dashboard tab. And then, create the web dashboard for this project. I used the four Gauage widgets and one LED widget.
  • And then, click the one-by-one gear wheel icons on the widgets and select the data stream we created earlier.
  • And then, click the save button. Next, click the search icon and create a device. For that, select the template we created earlier.

OK, the Blynk web dashboard is ready for you.

(adsbygoogle = window.adsbygoogle || []).push({});

Step 7

Now, let’s configure the program. For that, follow the instructions below.

  • First, connect the ESP32 board to the computer.
  • Next, copy and paste the following program into the Arduino IDE.
  • Code and Circuit diagram — Download
  • Blynk Library — Download
  • DHT11 Library — Download
  • BMP-180 Library — Download
  • I2C Library — Download
  • Sensor Master Library — Download

//Include the library files
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#include <DHT.h>
#include <SFE_BMP180.h>

#define LDR 4
#define TH 5
#define Rain 36

//Create three variables for pressure
double T, P;
char status;

//Initialize the LCD display
LiquidCrystal_I2C lcd(0x27, 16, 2);

// Create an object for the BMP180 sensor
SFE_BMP180 bmp;

DHT dht(TH, DHT11);
BlynkTimer timer;

// Enter your Auth token
char auth[] = "*******";

//Enter your WIFI SSID and password
char ssid[] = "*******";
char pass[] = "*******";

void setup() {
  // Debug console
  Serial.begin(115200);
  Blynk.begin(auth, ssid, pass);
  bmp.begin();
  dht.begin();
  lcd.init();
  lcd.backlight();
  pinMode(LDR, INPUT);
  pinMode(Rain, INPUT);
  analogReadResolution(12);

  lcd.setCursor(0, 0);
  lcd.print("System");
  lcd.setCursor(4, 1);
  lcd.print("Loading..");
  delay(4000);
  lcd.clear();

}

//Get the DHT11 sensor values
void DHT11sensor() {
  float h = dht.readHumidity();
  float t = dht.readTemperature();

  if (isnan(h) || isnan(t)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }
  Blynk.virtualWrite(V0, t);
  Blynk.virtualWrite(V1, h);

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

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

}

//Get the rain sensor values
void rainSensor() {
  int Rvalue = analogRead(Rain);
  Rvalue = map(Rvalue, 0, 4095, 0, 100);
  Rvalue = (Rvalue - 100) * -1;
  Blynk.virtualWrite(V2, Rvalue);

  lcd.setCursor(0, 1);
  lcd.print("R:");
  lcd.print(Rvalue);
  lcd.print(" ");
  Serial.println(Rvalue);
}

//Get the pressure values
void pressure() {
  status =  bmp.startTemperature();
  if (status != 0) {
    delay(status);
    status = bmp.getTemperature(T);

    status = bmp.startPressure(3);// 0 to 3
    if (status != 0) {
      delay(status);
      status = bmp.getPressure(P, T);
      if (status != 0) {

      }
    }
  }

  Blynk.virtualWrite(V3, P);
  lcd.setCursor(8, 1);
  lcd.print("P:");
  lcd.print(P);
}

//Get the LDR sensor values
void LDRsensor() {
  bool value = digitalRead(LDR);
  if (value == 1) {
    WidgetLED LED(V4);
    LED.on();
  } else {
    WidgetLED LED(V4);
    LED.off();
  }

}

void loop() {
  DHT11sensor();
  rainSensor();
  pressure();
  LDRsensor();
  Blynk.run();//Run the Blynk library
}

  • Next, copy and paste the Blynk auth token into the program. And then, enter your WIFI SSID and password.
  • And then, select the board and port. After, click the upload button.
(adsbygoogle = window.adsbygoogle || []).push({});
  • In this case, press and hold the boot button when the following message is displayed on the shell.

Step 8

Now, let’s create the Blynk mobile web dashboard. For that, follow the instructions below.

  • First, download and install the Blynk app from the play store or app store.
  • Then, log in to your account and click on the template you created in the web dashboard.
  • Next, click the + icon on the right corner and add four Gauge widgets and one LED widget to the dashboard.
  • Now, customize these widgets as you like. After that, click the one-by-one widget and select the data streams we created on the web dashboard.

Ok, Blynk mobile dashboard is ready for you.

(adsbygoogle = window.adsbygoogle || []).push({});

Step 9

Now, remove the USB cable and Provide an external 5VDC power supply to your project.

Troubleshooting tips

  • Check that all of the connections,
  • Check that the code has been uploaded correctly to the ESP32 board.
  • Check your power source.

Now, you can test this project using your smartphone or computer.

Ok, enjoy this project. The full video guide is below. We hope to see you in our upcoming projects and tutorials.

How to Make a Weather Monitoring System with ESP32 Board

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *