IoT Weather Station ⛅

Step 1: Materials
Hardware components:
  • ESP8266 Node MCU
  • DHT11 Sensor
  • BMP180 Sensor
  • Jumper Wires

Software needed:
  • Arduino IDE
  • Blynk

Step 2: Pin Out
  • - DHT11 --> GND
  • out DHT11 --> D4
  • + DHT11 --> +3V
  • BMP180 VIN --> +3V
  • BMP180 GND --> GND
  • BMP180 SCL --> D6
  • BMP180 SDA --> D7
IoT Weather Station Diagram



Step 3: Code

#include <Adafruit_Sensor.h> //In order to use DHT sensor we have to include this library first 

#define BLYNK_PRINT Serial  
//INCLUDE LIBRARIES
#include <DHT.h> //DHT library
#include <ESP8266WiFi.h> // ESP8266 WiFi library in order to use them
#include <BlynkSimpleEsp8266.h> //library for linking up Blynk with ESP8266
#include <Wire.h> //For using I2C connection of BMP180 in order to connect it to the board
#include <Adafruit_BMP085.h> //library for BMP180
Adafruit_BMP085 bmp; //Defining the object bmp
#define I2C_SCL 12 //Connect SCL pin of BMP180 to GPIO12(D6) of Nodemcu
#define I2C_SDA 13 //Connect SDA pin of BMP180 to GPIO13(D7) of Nodemcu

float dst,bt,bp,ba;
char btmp[20],bprs[20],balt[20];
bool bmp085_present=true;
char auth[] = "3q3wwqEVnMkkk0n3QOQnSDSGs5_BFjxZ"; //Authentication Key will be there in the Blynk App
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "Redmi"; //SSID of the WiFi hotspot available
char pass[] = "angelica@1228."; //Password of the WiFi
#define DHTPIN 2 //Connect the DHT11 sensor's data pin to GPIO2(D4) of Nodemcu    
#define DHTTYPE DHT11 //Mention the type of sensor we are using, Here it it DHT11, for DHT22 just replace DHT11 with DHT22
DHT dht(DHTPIN, DHTTYPE); //Defining the pin and the dhttype
BlynkTimer timer;
void sendSensor()
{
    
 
//______________________________Check the working of BMP180 sensor________________________________________
 
          if (!bmp.begin()) 
          {
              Serial.println("Could not find a valid BMP085 sensor, check wiring!");
              while (1) {}
          }
  
//______________________Getting the Humidity and temperature value from DHT11____________________________
  
          float h = dht.readHumidity();
          
          float t = dht.readTemperature(); // or dht.readTemperature(true) for Fahrenheit
//______________________________Check the working of DHT11 sensor________________________________________
  
          if (isnan(h) || isnan(t)) 
          {
              Serial.println("Failed to read from DHT sensor!");
              return;
          }
//______________________________Measuring the Dew Point______________________________________________________
          double gamma = log(h/100) + ((17.62*t) / (243.5+t));
          double dp = 243.5*gamma / (17.62-gamma);
//______________________Reading the value of Pressure, Temperature, Altitude from the BMP180__________________
  
          float bp = bmp.readPressure()/100; // Division by 100 makes it in millibars
          
          float ba = bmp.readAltitude();
 
          float bt = bmp.readTemperature();
  
  
 //_______________Printing the valus of the above read value on to the Virtual Pins in the Bluynk App_____________
 
          Blynk.virtualWrite(V5 , h); //humidity
          Blynk.virtualWrite(V6 , t); //temperature
          Blynk.virtualWrite(V10, bp); //barometer pressure
          Blynk.virtualWrite(V11, ba); //barometer altitude
          Blynk.virtualWrite(V12, bt); //barometer temperature
          Blynk.virtualWrite(V13, dp); //dew point
             
}
void setup()
{
  
          Serial.begin(9600); //Initializing the Serial Monitor with a Baud Rate of 9600
        
          Blynk.begin(auth, ssid, pass);
        
          dht.begin(); //Initializing the DHT sensor
          
          Wire.begin(I2C_SDA, I2C_SCL); //Initializing the I2C connection
          
          delay(10);
          
          timer.setInterval(1000L, sendSensor);
}
void loop()
{
  Blynk.run();
  timer.run();
}

Step 4: Setting Up Blynk

  1. Add 6 gauge on the widget.
  2. Set the pins according on what you put in the code.
  3. Paste the Auth token on the program which can be found when you click the nut icon.
  4. Connect your device in your phone through wi-fi.
  5. Select play. 
  6. You will see that it is running.

Post a Comment

0 Comments