Wolfgang
Published © GPL3+

Arduino Weather Station Temp, Pressure, Humidity, Windspeed

Simple weather station Arduino UNO: measures temperature, humidity, air pressure using BMP280, DHT11, windspeed 3D-printed anemometer.

BeginnerFull instructions provided3 hours276
Arduino Weather Station Temp, Pressure, Humidity, Windspeed

Things used in this project

Hardware components

MAKERFACTORY Arduino UNO compatible
MAKERFACTORY Arduino UNO compatible
×1
Base Shield V2
Seeed Base Shield V2
×1
Grove - Barometer Sensor (BMP280)
Seeed Grove - Barometer Sensor (BMP280)
×1
Seeed Grove DHT22
×1
Seeed LCD RGB
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

RF2000V2 3D-Printer

Story

Read more

Custom parts and enclosures

Anemometer

3D printed anemometer to measure wind speed.

Code

C Program for Arduino UNO weather station

C/C++
measures temperature and humidity from DHT22 sensor and air pressure from BMP280. needs interrupt control to get wind speed from light barrier via pulse input. trend graph on LCD RGB display with custom specific special characters
/* Wetterstation programmiert von Wolfgang Lex 26.04.2019
 * unter Verwendung von Beispielprogrammen 
 * BMP280
 * Copyright (c) 2016 seeed technology inc.
 * Website    : www.seeedstudio.com
 * Author     : Lambor, CHN
 * DHT Test: written by ladyada, public domain
 */
#include "DHT.h"
#include <Wire.h>
#include <rgb_lcd.h>
#include <Adafruit_BMP280.h>

#define DHTPIN 2     // DHT Pro an Stecksockel D2
#define DHTTYPE DHT22   // DHT 22  (AM2302)

#define BMP_SCK  (13)
#define BMP_MISO (12)
#define BMP_MOSI (11)
#define BMP_CS   (10)

DHT dht(DHTPIN, DHTTYPE);
rgb_lcd lcd;          // Kurzbezeichnung für LCD Display
Adafruit_BMP280 bmp; // Kurzbezeichnung für Luftdrucksensor BMP820

int colorR;
int colorG;
int colorB;
byte Gradzeichen[8]={  //Zeichen für Grad ° aus Pixeln definieren, da im Zeichensatz von LCD Display nicht vorhanden
  0b00111,
  0b00101,
  0b00111,
  0b00000,
  0b00000,
  0b00000,
  0b00000,
  0b00000
};

float Luftdruck,pps;
int counter,counteralt,Windgeschw;
int Sensor=3;
unsigned long Zeit,Zeitalt;   // Zeitwerte aus Funktion millis() Wertebereich bis 2^32(-1) (4.294.967.295)
boolean neupuls=false;

void setup()
{
  pinMode(Sensor,INPUT);
  attachInterrupt(1,Puls,RISING); //Interrupteingang 2 an Pin3
  
  Serial.begin(9600);
  if (!bmp.begin()) {
     Serial.println(F("Kein BMP280-Sensor gefunden, Verdrahtung prüfen!"));
     while (1);
    }

    /* Default settings from datasheet BMP280 */
    bmp.setSampling(Adafruit_BMP280::MODE_NORMAL,   /* Operating Mode. */
                  Adafruit_BMP280::SAMPLING_X2,     /* Temp. oversampling */
                  Adafruit_BMP280::SAMPLING_X16,    /* Pressure oversampling */
                  Adafruit_BMP280::FILTER_X16,      /* Filtering. */
                  Adafruit_BMP280::STANDBY_MS_500); /* Standby time. */


// Spalten und Zeilen für LCD-Display definieren
    lcd.begin(16, 2);
    lcd.createChar(0,Gradzeichen);
    
    colorR=0;   //Hintergrundbeleuchtung von LCD Display auf Grün einstellen
    colorG=255;   
    colorB=0;
    lcd.setRGB(colorR, colorG, colorB);
    lcd.setCursor(0,0);
    lcd.print("Wetterstation");
    delay(1000);
       
    dht.begin();
      
}

void loop() 
{
    
    if (counter>counteralt)
    {    
    pps=(counter-counteralt)*1000/(Zeit-Zeitalt);
    Windgeschw=pps*7;
    Serial.print(pps);
    Serial.print(" ");
    Serial.println(Windgeschw);
    counteralt=counter;
    Zeitalt=Zeit;
    }

    // Reading temperature or humidity takes about 250 milliseconds!
    // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
    float h = dht.readHumidity();
    float t = dht.readTemperature();

    Luftdruck=bmp.readPressure()/100;
    
    // check if returns are valid, if they are NaN (not a number) then something went wrong!
    if (isnan(t) || isnan(h)) 
    {
        Serial.println("Fehler beim Lesen des DHT-Sensors");
    } 
    else 
    {
        colorR=200; //Farbmix RGB einstellen hier weiß
        colorG=200;
        colorB=200;
        lcd.setRGB(colorR, colorG, colorB);
        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print(t);
        lcd.write((unsigned char)0);
        lcd.print( "C");
        lcd.setCursor(8, 0);
        lcd.print(h);
        lcd.print("%rF");
        lcd.setCursor(0, 1);
        lcd.print(Luftdruck);
        lcd.print("hPa");
        lcd.setCursor(10, 1);
        lcd.print(Windgeschw);
        lcd.print("km/h");
                
     }
   
     
}

void Puls()
{
    counter++;
    //neupuls=true;
    Zeit=millis();
       
}

Credits

Wolfgang

Wolfgang

1 project • 0 followers

Comments

Add projectSign up / Login