How to make arduino weather station

Posted by moudud 07/05/2019 0 Comment(s)

 

HOW TO MAKE ARDUINO WEATHER STATION


Circuit Diagram :


 

 

OLED Display & DHT-11 Sensor module connection with Arduino
 PinArduino pin
DHT-11VCC5V
GNDGND
Signal/OUTD2

OLED Display

VCC3.3V
GNDGND
SDAA4
SCLA5

 

 

 

 

 


Code

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_SSD1306.h>
#include <SimpleDHT.h>

 

#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);

// for DHT11, 
//      VCC: 5V or 3V
//      GND: GND
//      DATA: 2
int pinDHT11 = 2;
SimpleDHT11 dht11(pinDHT11);

void setup() {
   Serial.begin(19200);
   display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3C (for the 128x32)
   display.clearDisplay();
   display.display();

}

void loop() {
  // start working...
  Serial.println("____________________");
  Serial.println("Simple DHT11...");
  
  // read without samples.
  byte temperature = 0;
  byte humidity = 0;
  int err = SimpleDHTErrSuccess;
  if ((err = dht11.read(&temperature, &humidity, NULL)) != SimpleDHTErrSuccess) {
    //Serial.print("Read DHT11 failed, err="); Serial.println(err);
    delay(1000);
    return;
  }
  
  Serial.print("Sample OK: ");
  Serial.print((int)temperature); Serial.print(" *C, "); 
  Serial.print((int)humidity); Serial.println(" H");
  
  
  delay(1500);       // DHT11 sampling rate is 1HZ.

 

  display.setTextSize(1);
  display.setTextColor(WHITE, BLACK);
  display.setCursor(85, 5);
  display.println(temperature);
  temperature = temperature;

  // write the new one
  display.setTextSize(1);
  display.setTextColor(WHITE, BLACK);
  display.setCursor(85, 5);
  display.println(temperature);

  display.display();


    display.setTextSize(1);
  display.setTextColor(WHITE, BLACK);
  display.setCursor(85,20);
  display.println(humidity);
  humidity = humidity;

  // write the new one
  display.setTextSize(1);
  display.setTextColor(WHITE, BLACK);
  display.setCursor(85, 20);
  display.println(humidity);

  display.display();

  display.setTextSize(1);
  display.setTextColor(WHITE, BLACK);
  display.setCursor(10, 20);
  display.println("Humidity");
  display.setCursor(10,5 );
  display.println("Temperature");
  display.setCursor(100,5 );
  display.println("C");
  display.setCursor(100,20 );
  display.println("%");
}

 


 

SimpleDHT Library - https://github.com/winlinvip/SimpleDHT

Adafruit_SSD1306 Library - https://github.com/adafruit/Adafruit_SSD1306

 

 

Write a Comment