Arduino Hava İstasyonu

Merhaba arkadaşlar arduino ile hava istasyonu projesi yapıyoruz. Bu projemde uzakta bulunan istasyona mesaj atacağız ve istasyon gelen mesaja göre bize geri bildirim yapacak. Hava istasyonumuzda

1.Havanın Basınç değeri

2.Havanın sıcaklığı ve nemi

3.Rüzgarın şiddeti

4.Toprağın nem değeri

Bu bilgiler lcd ekranda gözükecek ve aynı zamanda sms olarak bize bildirilecek.

 

1.Arduino Uno

2.Gsm Modül

3.Bmp180 Basınç Sensörü

4.Dht11 Sıcaklık Sensörü

5.Toprak nem sensörü

6.16×2 Lcd ekran

7.10k pot

8.Rüzgar Sensörü  Kullanılmaktadır.

 

 

Rüzgar ve toprak sensörü Analog çıkış vermektedir.

 

 

 

 

GSM Modül Kullanımı:

 

Kütüphane ihtiyacı yok.

#include <SoftwareSerial.h>
SoftwareSerial gsm(2, 3);
String smsMetni = "";
char gelen;

#define LED_PIN 12
#define ISIK_PIN 11
#define BEKLE 3

void SMSgonder(String mesaj) {
  gsm.print("AT+CMGF=1\r");
  delay(100);
  gsm.println("AT+CMGS=\"+905444742644\"");// telefon numarasi degistir
  delay(100);
  gsm.println(mesaj);
  delay(100);
  gsm.println((char)26);
  delay(100);
  gsm.println();
  delay(100);
  gsm.println("AT+CMGD=1,4");
  delay(100);
  gsm.println("AT+CMGF=1");
  delay(100);
  gsm.println("AT+CNMI=1,2,0,0,0");
  delay(200);
  smsMetni = "";
}


void smscoz() {
  while (gsm.available()) {
    delay(BEKLE);
    gelen = gsm.read();
    if (gelen == '#') {
      if (gsm.available()) {
        delay(BEKLE);
        gelen = gsm.read();
        if (gelen == 'L') {
          if (gsm.available()) {
            delay(BEKLE);
            gelen = gsm.read();
            if (gelen == 'E') {
              if (gsm.available()) {
                delay(BEKLE);
                gelen = gsm.read();
                if (gelen == 'D') {
                  if (gsm.available()) {
                    delay(BEKLE);
                    gelen = gsm.read();
                    if (gelen == 'a') {
                      digitalWrite(LED_PIN, HIGH);
                      SMSgonder("LED acildi");
                    }
                    else if (gelen == 'k') {
                      digitalWrite(LED_PIN, LOW);
                      SMSgonder("LED kapatildi");
                    }
                  }
                }
              }
            }
          }
        }
        else if (gelen == 'I') {
          if (gsm.available()) {
            delay(BEKLE);
            gelen = gsm.read();
            if (gelen == 'S') {
              if (gsm.available()) {
                delay(BEKLE);
                gelen = gsm.read();
                if (gelen == 'I') {
                  if (gsm.available()) {
                    delay(BEKLE);
                    gelen = gsm.read();
                    if (gelen == 'K') {
                      if (gsm.available()) {
                        delay(BEKLE);
                        gelen = gsm.read();
                        if (gelen == 'a') {
                          digitalWrite(ISIK_PIN, LOW);
                          smsMetni = "Isik acildi";
                          SMSgonder(smsMetni);
                        }
                        else if (gelen == 'k') {
                          digitalWrite(ISIK_PIN, HIGH);
                          smsMetni = "Isik kapatildi";
                          SMSgonder(smsMetni);
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

void setup() {
  pinMode(LED_PIN, OUTPUT);
  pinMode(ISIK_PIN, OUTPUT);
  digitalWrite(ISIK_PIN, HIGH);
  pinMode(7, OUTPUT);
  digitalWrite(7, HIGH);
  delay(3000);
  digitalWrite(7, LOW);
  gsm.begin(9600);
  delay(2000);
  gsm.println("AT+CMGF=1");
  delay(100);
  gsm.println("AT+CNMI=1,2,0,0,0");
  delay(100);
  gsm.println("AT+CMGD=1,4");
  delay(1000);
  SMSgonder("Sistem Acildi");
  gsm.flush();
  delay(100);
}

void loop() {
  smscoz();
  delay(1);
}

 

 

 

 

DHT11 Kullanımı:

 

 

https://github.com/adidax/dht11 indirmemiz gerekmektedir.

#include <dht11.h> // dht11 kütüphanesini ekliyoruz.
#define DHT11PIN 4 // DHT11PIN olarak Dijital 2"yi belirliyoruz.
dht11 DHT11;
void setup()
{
  Serial.begin(9600); // Seri iletişimi başlatıyoruz.
}

void loop()
{
  // Bir satır boşluk bırakıyoruz serial monitörde.
  Serial.println();
  int chk = DHT11.read(DHT11PIN);
  Serial.print("Nem (%): ");
  Serial.println((float)DHT11.humidity, 2);

  Serial.print("Sicaklik (Celcius): ");
  Serial.println((float)DHT11.temperature, 2);

  Serial.print("Sicaklik (Fahrenheit): ");
  Serial.println(DHT11.fahrenheit(), 2);

  Serial.print("Sicaklik (Kelvin): ");
  Serial.println(DHT11.kelvin(), 2);

  Serial.print("Cig Olusma Noktasi: ");
  Serial.println(DHT11.dewPoint(), 2);

  delay(2000);

}

BMP180 kullanımı:

 

 

https://github.com/adafruit/Adafruit-BMP085-Library indirmemiz gerekmektedir.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include &quot;Wire.h&quot;
#include &quot;Adafruit_BMP085.h&quot; //Basınç Sensörü Kütüphanesi
Adafruit_BMP085 mySensor;
 
float Celsius; // Değişkenler Tanımlanıyor
float Fahrenheit;
float pressure;
 
void setup(){
Serial.begin(9600);
mySensor.begin();
}
 
void loop() {
Celsius = mySensor.readTemperature(); // Sıcaklık Okuyor
Fahrenheit = Celsius*1.8 + 32.; // Fahrenheit ile Celsius Dönüşümü Yapılıyor
pressure=mySensor.readPressure(); //Basınç Okunuyor
 
Serial.print("Sicaklik:"); //Sonuçlar yazdırılıyor
Serial.print(Fahrenheit);
Serial.println(" Derecesi ");
Serial.print("Basinc: ");
Serial.print(pressure);
Serial.println("Pa.");
Serial.println("");
delay(1000);
}

 

 

 

 

#include <SoftwareSerial.h>
#include <Wire.h>
#include <Adafruit_BMP085.h>
Adafruit_BMP085 bmp ;
#include <dht11.h>
#include <LiquidCrystal.h>
SoftwareSerial gsm(2, 3);
int i;
char gelen;
String smsMetni = "";
#define BEKLE 3
unsigned int alinan_ref = 0;
int say = 0;
int okunan_max_deger = 70;
int bar_uzunluk      =   16;
int sutun_hesap      = okunan_max_deger / bar_uzunluk;
int satir_hesap      = ((sutun_hesap / 5) * 10);

byte graph [5][8] = {
  // new LCD chars:   |,   ||,   |||, ||||, |||||
  {0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00},  // 1 dikey çizgi
  {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00},  // 2 dikey çizgi
  {0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x00},  // 3 dikey çizgi
  {0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x00},  // 4 dikey çizgi
  {0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00}   // 5 dikey çizgi
};




//               (Rs, E, D4, D5, D6 ,D7)
LiquidCrystal lcd(13 , 10, 9 , 8 , 6 , 5);
dht11 DHT11;
int r = 0;
double ruz = 0;
int toprak = 0;
int referans = 0;
//int isi = 0;
int sicaklik = 0;

int nem = 0;
double bas = 0;




void SMSgonder(String mesaj) {
  gsm.print("AT+CMGF=1\r");
  delay(100);
  gsm.println("AT+CMGS=\"+905512345678\"");// telefon numarasi degistir
  delay(100);
  gsm.println(mesaj);
  delay(100);
  gsm.println((char)26);
  delay(100);
  gsm.println();
  delay(100);
  gsm.println("AT+CMGD=1,4");
  delay(100);
  gsm.println("AT+CMGF=1");
  delay(100);
  gsm.println("AT+CNMI=1,2,0,0,0");
  delay(200);
  smsMetni = "";
}


void smscoz() {

      while (gsm.available()) {
        delay(BEKLE);
        gelen = gsm.read();
      //-----------------------------------
    
        if (gelen == '#') {
          if (gsm.available()) {
            delay(BEKLE);
    
    lcd.setCursor (0, 1);
                        lcd.print(gelen);
            gelen = gsm.read();
            if (gelen == 'R') {
    lcd.setCursor (1, 1);
                        lcd.print(gelen);
              if (gsm.available()) {
                delay(BEKLE);
    
                gelen = gsm.read();
                if (gelen == 'E') {
    lcd.setCursor (2, 1);
                                lcd.print(gelen);
                  if (gsm.available()) {
                    delay(BEKLE);
                    gelen = gsm.read();
                    if (gelen == 'S') {
    lcd.setCursor (3, 1);
                                        lcd.print(gelen);
                      if (gsm.available()) {
                        delay(BEKLE);
    
                        gelen = gsm.read();
                        if (gelen == 'U') {
    lcd.setCursor (4, 1);
                                                lcd.print(gelen);
                          if (gsm.available()) {
                            delay(BEKLE);
                            gelen = gsm.read();
                            if (gelen == 'L') {
    lcd.setCursor (5, 1);
                                       lcd.print(gelen);

                              if (gsm.available()) {
                                delay(BEKLE);
    
    lcd.setCursor (0, 0);
    lcd.println("Resul >>> Rapor ");
    lcd.setCursor (6, 1);
                                       lcd.print("         ");
    
                                gsm.print("AT+CMGF=1\r");
                                delay(100);
                                gsm.println("AT+CMGS=\"+905512345678\"");// telefon numarasi degistir
                                
                                delay(100);
                                gsm.println("Merhaba Resul Sizin icin Sistem Sonuclari");
                                delay(100);
                                gsm.print("RUZGAR......"); gsm.print(ruz); gsm.println(" m/s");
                                delay(100);
                                gsm.print("Toprak......"); gsm.print(toprak); gsm.println(" %");
                                delay(100);
                                gsm.print("BASINC......"); gsm.print(bas); gsm.println(" hPa");
                                delay(100);
                                gsm.print("ISI........."); gsm.print(sicaklik); gsm.println(" C");
                                delay(100);
                                gsm.print("Nem........."); gsm.print(nem); gsm.println(" %");
                                gsm.println((char)26);
                                delay(100);
                                gsm.println();
                                delay(100);
                                gsm.println("AT+CMGD=1,4");
                                delay(100);
                                gsm.println("AT+CMGF=1");
                                delay(100);
                                gsm.println("AT+CNMI=1,2,0,0,0");
                                delay(200);
                                smsMetni = "";
                              }  }}}}}}}}}}}
  
 else if (gelen == '*') {
          if (gsm.available()) {
            delay(BEKLE);
    
    lcd.setCursor (0, 1);
                        lcd.print(gelen);
            gelen = gsm.read();
            if (gelen == 'H') {
    lcd.setCursor (1, 1);
                        lcd.print(gelen);
              if (gsm.available()) {
                delay(BEKLE);
    
                gelen = gsm.read();
                if (gelen == 'O') {
    lcd.setCursor (2, 1);
                                lcd.print(gelen);
                  if (gsm.available()) {
                    delay(BEKLE);
                    gelen = gsm.read();
                    if (gelen == 'C') {
    lcd.setCursor (3, 1);
                                        lcd.print(gelen);
                      if (gsm.available()) {
                        delay(BEKLE);
    
                        gelen = gsm.read();
                        if (gelen == 'A') {
    lcd.setCursor (4, 1);
                                                lcd.print(gelen);
                          if (gsm.available()) {
                            delay(BEKLE);
                            gelen = gsm.read();
                            if (gelen == 'M') {
    lcd.setCursor (5, 1);
                                       lcd.print(gelen);


          if (gsm.available()) {
                                delay(BEKLE);
    
    lcd.setCursor (0, 0);
    lcd.println("Hocam >>>> Rapor");
    lcd.setCursor (7, 1);
                                       lcd.print("         ");
    
             gsm.print("AT+CMGF=1\r");
             delay(100);
             gsm.println("AT+CMGS=\"+905587654321\"");// telefon numarasi degistir
             delay(100);
             gsm.println("Merhaba Hocam Sizin icin Sistem Sonuclari");
             delay(100);
             gsm.print("RUZGAR......"); gsm.print(ruz); gsm.println(" m/s");
             delay(100);
             gsm.print("Toprak......"); gsm.print(toprak); gsm.println(" %");
             delay(100);
             gsm.print("BASINC......"); gsm.print(bas); gsm.println(" hPa");
             delay(100);
             gsm.print("ISI........."); gsm.print(sicaklik); gsm.println(" C");
             delay(100);
             gsm.print("Nem........."); gsm.print(nem); gsm.println(" %");
             gsm.println((char)26);
            delay(100);
            gsm.println();
            delay(100);
            gsm.println("AT+CMGD=1,4");
            delay(100);
            gsm.println("AT+CMGF=1");
            delay(100);
            gsm.println("AT+CNMI=1,2,0,0,0");
            delay(200);
            smsMetni = "";
                              } } } }}}}}}}}}}}

  void setup()
  {

    Serial.begin(9600);
    //Wire.begin (4, 5);
    if (!bmp.begin())
    {
      Serial.println("Could not find BMP180 or BMP085 sensor at 0x77");
      while (1) {}
    }

    DHT11.attach(4);

    Serial.begin(9600);
    Serial.println("DHT11 TEST PROGRAM ");
    Serial.print("LIBRARY VERSION: ");
    Serial.println(DHT11LIB_VERSION);
    lcd.begin(16, 2);
    lcd.clear();
    lcd.setCursor (0, 0);
    lcd.println("  AKILLI  HAVA  ");
    lcd.setCursor (0, 1);
    lcd.println("   ISTASYONU     ");
    delay (2000);
    lcd.clear();

    lcd.setCursor (0, 0);
    lcd.println("SEBEKEYE BAGLAN-");
    lcd.setCursor (0, 1);
    lcd.println("TI KURULUYOR    ");

    pinMode(7, OUTPUT);
    digitalWrite(7, HIGH);
    delay(3000);
    digitalWrite(7, LOW);
    gsm.begin(9600);
    delay(2000);
    gsm.println("AT+CMGF=1");
    delay(100);
    gsm.println("AT+CNMI=1,2,0,0,0");
    delay(100);
    gsm.println("AT+CMGD=1,4");
    delay(1000);
    SMSgonder("Cihaz ile baglanti kuruldu");


    delay(100);

    gsm.flush();





  }

  void loop()
  {


    int ruzsensoru = analogRead(A0);
    r = map(abs(ruzsensoru), 0, 410, 0.0, 70.0);
    ruz = (float)ruzsensoru / 5.85;


    int chk = DHT11.read();
    sicaklik = (float)DHT11.temperature, DEC;
    //  Serial.print("Nem (%): ");
    //  Serial.println((float)DHT11.humidity, DEC);
    //
    //  Serial.print("SICAKLIK (°C): ");
    //  Serial.println((float)DHT11.temperature, DEC);
    nem = (float)DHT11.humidity, DEC;


    //  Serial.print("Temperature = ");
    //  Serial.print(bmp.readTemperature());
    //  Serial.println(" Celsius");
    //
    //  Serial.print("Pressure = ");
    //  Serial.print(bmp.readPressure());
    //  Serial.println(" Pascal");
    bas = (float)bmp.readPressure() / 100;
    int topraksensoru = analogRead(A1);
    toprak = map(abs(topraksensoru), 0, 1024, 99, 0);






    smscoz();

    for (int say = 0; say < 40; say++)
    {


      smscoz();

      lcd.clear();
      int ruzsensoru = analogRead(A0);
      r = map(abs(ruzsensoru), 0, 410, 0.0, 70.0);
      ruz = (float)ruzsensoru / 5.85;
      if (ruz < 0.2)
      {
        ruz = 0;
      }

      lcd.setCursor(0, 0);

      lcd.print("Ruzgar ");
      lcd.print(ruz);
      lcd.print("    ");
      lcd.setCursor(13, 0);
      lcd.print("m/s");
      if (alinan_ref != ruz) {
        cubuk(ruz + 1);
        alinan_ref = ruz;

      }


      delay(100);
    }



    lcd.clear();

    for (int sayi = 0; sayi < 40; sayi++)
    {

      smscoz();

      int chk = DHT11.read();
      sicaklik = (float)DHT11.temperature, DEC;
      //    Serial.print("Nem (%): ");
      //    Serial.println((float)DHT11.humidity, DEC);
      //
      //    Serial.print("SICAKLIK (°C): ");
      //    Serial.println((float)DHT11.temperature, DEC);
      nem = (float)DHT11.humidity, DEC;
      lcd.setCursor (0, 0);
      lcd.print("SIC : ");
      lcd.print((int)DHT11.temperature, DEC);
      lcd.print("                 ");
      lcd.setCursor (15, 0);
      lcd.print("C");
      lcd.setCursor (0, 1);
      lcd.print("NEM : ");
      lcd.print((int)DHT11.humidity, DEC);
      lcd.print("                 ");
      lcd.setCursor (15, 1);
      lcd.print("%");

      delay(100);
    }

    lcd.clear();

    for (int sayim = 0; sayim < 40; sayim++)
    {
      smscoz();
      //    Serial.println(sayim);
      //    Serial.print("Temperature = ");
      //    Serial.print(bmp.readTemperature());
      //    Serial.println(" Celsius");
      //
      //    Serial.print("Pressure = ");
      //    Serial.print(bmp.readPressure());
      //    Serial.println(" Pascal");
      bas = (float)bmp.readPressure() / 100;
      int topraksensoru = analogRead(A1);
      toprak = map(abs(topraksensoru), 0, 1024, 99, 0);
      lcd.clear();
      lcd.setCursor (0, 0);
      lcd.print("TOPRAK:");

      lcd.print(toprak);
      lcd.print("         ");
      lcd.setCursor (15, 0);
      lcd.print("%");

      lcd.setCursor (0, 1);
      lcd.print("BAR: ");
      lcd.print(bas);
      lcd.print("         ");
      lcd.setCursor (12, 1);
      lcd.print(" hPa");


      delay(100);
    }

    smscoz();






  }



  void cubuk(unsigned int atanan) {
    byte blok_sutun;
    byte blok_satir;
    byte sayac;


    int sutun_hesap      = okunan_max_deger / bar_uzunluk;
    int satir_hesap      = ((sutun_hesap / 5) * 10);


    lcd.setCursor(0, 1);
    blok_sutun = atanan / sutun_hesap;
    for (sayac = 0; sayac < blok_sutun; sayac++)
      lcd.write(4);

    blok_satir = (10 * (atanan - blok_sutun * sutun_hesap)) / satir_hesap;
    if (blok_satir > 0)
      lcd.write(blok_satir - 1);
    else
      lcd.write(' ');

    for (sayac = blok_sutun + 1; sayac < bar_uzunluk; sayac++)
      lcd.write(' ');
    delay(200);
  }

Sosyal Medyada Paylaş Facebook Twitter Google+

Etiketler: , , , , , ,
Eklenme Tarihi: 1 Nisan 2019

Konu hakkında yorumunuzu yazın

HOŞ GELDİNİZ

Youtube kanalıma Abone Olabilirsiniz.