JANAK13
Published © GPL3+

Private Real-time Weather Station

This project is used to monitor the weather conditions of your home in real-time on a web application.

AdvancedFull instructions provided5,142
Private Real-time Weather Station

Things used in this project

Hardware components

NodeMCU ESP8266 Breakout Board
NodeMCU ESP8266 Breakout Board
×1
DHT11 Temperature & Humidity Sensor (3 pins)
DHT11 Temperature & Humidity Sensor (3 pins)
×1
Resistor 100 ohm
Resistor 100 ohm
×1
LDR (light detecting resistor)
×1
Breadboard (generic)
Breadboard (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Arduino UNO
Arduino UNO
optional (you can use it to test your sensors)
×1

Software apps and online services

Firebase
Google Firebase
Arduino IDE
Arduino IDE
Github Atom
Atom is a text editor by GitHub. You can use any other text editor of your choice.

Story

Read more

Schematics

The Circuit

Make connections as per the Schematic.

Code

Weather station

C/C++
Upload this code onto nodeMCU
#include <DHT.h>        // including the library of DHT11 temperature and humidity sensor
#include <ESP8266WiFi.h>
#include <FirebaseArduino.h>
#define DHTTYPE DHT11   // DHT 11

// Set these to run example.
#define FIREBASE_HOST "YOUR DATABASE LINK"
#define FIREBASE_AUTH "SECRET CODE"
#define WIFI_SSID "YOUR SSID"
#define WIFI_PASSWORD "YOUR PASSWORD"
#define dht_dpin 0

DHT dht(dht_dpin, DHTTYPE); 
void setup()
{ 
  Serial.begin(9600);
  dht.begin();
  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
  Serial.print("connecting");
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  Serial.println();
  Serial.print("connected: ");
  Serial.println(WiFi.localIP());
  
  Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
}


void loop() {
  int n= 0;
    float light = analogRead(A0);  
    float hum = dht.readHumidity();
    float temp = dht.readTemperature();         
  delay(800);
  Serial.println(light);
  Serial.println(hum);
  Serial.println(temp);
  // set value
 
  Firebase.setFloat("light", light);
  // handle error
  if (Firebase.failed()) {
      Serial.print("setting /light failed:");
      Serial.println(Firebase.error());  
      return;
  }
  delay(100);
  Firebase.setFloat("moisture", hum);
  if (Firebase.failed()) {
      Serial.print("setting /hum failed:");
      Serial.println(Firebase.error());  
      return;
  }
  delay(100);
  Firebase.setFloat("temperature", temp);
  if (Firebase.failed()) {
      Serial.print("setting /temp failed:");
      Serial.println(Firebase.error());  
      return;
  }
  delay(100);
  //get values
  Serial.print("light: ");
  Serial.println(Firebase.getFloat("light"));
  Serial.print("humidity: ");
  Serial.println(Firebase.getFloat("moisture"));
  Serial.print("temperature: ");
  Serial.println(Firebase.getFloat("temperature"));
  delay(100);

  // append a new value to /logs
  String name = Firebase.pushInt("logs", n++);
  // handle error
  if (Firebase.failed()) {
      Serial.print("pushing /logs failed:");
      Serial.println(Firebase.error());  
      return;
  }
  Serial.print("pushed: /logs/");
  Serial.println(name);
  delay(1000);
}

  

Credits

JANAK13

JANAK13

6 projects • 44 followers

Comments