BAĞLAN

Arduino ve Processing İle Meteoroloji İstasyonu Projesi

  • Görüntüleme 1796
  • Bu projemizde hava istasyonumuzu yaparak bilgisayarımızdan gerçek zamanlı grafik çıktı alacağız. Processing arayüz ile görsel olarak anlık rüzgar hızı, basınç, sıcaklık ve rüzgar yönünü takip edeceğiz.Elde ettiğimiz verileri her 10 dakikada bir jpg olarak kaydedeceğiz.

    Malzemeler:

    1. Arduino
    2. Anemometre
    3. BMP085 barometrik basınç sensörü
    4. Potansiyometre

    Elektronik Devre Şeması:

    Arduino Yazılımı:

    #include <Wire.h>
    #include <Adafruit_Sensor.h>
    #include <Adafruit_BMP085.h>
     
    Adafruit_BMP085 bmp = Adafruit_BMP085(10085);
    int wSpeed;
    int wDirect;
    int temp1;
    int press1;
    int wsee;
    void setup(void)
    {
    Serial.begin(9600);
     
    if(!bmp.begin())
    {
    Serial.print("Sensör bağlantılarını kontrol et");
    while(1);
    }
     
    }
     
    void loop(void)
    {
     
    sensors_event_t event;
    bmp.getEvent(&event);
    wsee=analogRead(A0);
    wSpeed=map(wsee,0,1023,0,1534); //rüzgar hızı
    wDirect=analogRead(A1);
    if (event.pressure)
    {
    press1=map(event.pressure,850,1100,0,1023);
    float temperature;
    bmp.getTemperature(&temperature);
    temp1=map(temperature,-30,55,0000,1023);
    }
    if (wSpeed<1000&&wSpeed>99){
    Serial.print("0");
    Serial.print(wSpeed);
    }
    else if(wSpeed<100&&wSpeed>9)
    {
    Serial.print("00");
    Serial.print(wSpeed);
    }
    else if(wSpeed<10){
    Serial.print("000");
    Serial.print(wSpeed);
    }
    else{
    Serial.print(wSpeed);
    }
     
    if (press1<1000&&press1>99){
    Serial.print("0");
    Serial.print(press1);
    }
    else if(press1<100&&press1>9)
    {
    Serial.print("00");
    Serial.print(press1);
    }
    else if(press1<10){
    Serial.print("000");
    Serial.print(press1);
    }
    else{
    Serial.print(press1);
    }
     
    if (temp1<1000&&temp1>99){
    Serial.print("0");
    Serial.print(temp1);
    }
    else if(temp1<100&&temp1>9)
    {
    Serial.print("00");
    Serial.print(temp1);
    }
    else if(temp1<10){
    Serial.print("000");
    Serial.print(temp1);
    }
    else{
    Serial.print(temp1);
    }
     
    if (wDirect<1000&&wDirect>99){
    Serial.print("0");
    Serial.print(wDirect);
    }
    else if(wDirect<100&&wDirect>9)
    {
    Serial.print("00");
    Serial.print(wDirect);
    }
    else if(wDirect<10){
    Serial.print("000");
    Serial.print(wDirect);
    }
    else{
    Serial.print(wDirect);
    }
    Serial.print("\n");
     
    delay(996);
     
    }

     

    Processing Kodu:

    import processing.serial.*;
    PFont p;
    Serial myPort; 
    int xPos = 100; 
     
    void setup () {
    size(700,500);
    p=createFont("Arial",16,true);
     
    background(0); 
    for(int u=99;u<width;u=u+60) { stroke(100); line(u,0,u,height-99); } for(int t=height-99;t>0;t=t-25) 
    {
    stroke(100);
    line(99,t,width,t);
    }
     
    textFont(p,12); 
    textAlign(LEFT);
    fill(255,0,0); //red
    text("Wind Speed MPH",100,height-25); 
    fill(0,255,0); 
    text("Barometric pressure mb",210,height-25);
    fill(0,0,255); //blue
    text("Degrees Celsius",355,height-25);
    fill(255); //white
    text("Wind direction N = 0 deg",460,height-25);
    fill(100); //gray
    textAlign(RIGHT);
    text("0",110,height-87);
    for (int m=160;m<width;m=m+60) { int Min=(m-100)/60; fill(100); textAlign(CENTER); text(Min,m,height-87); } fill(100); textAlign(CENTER); text("Minutes",width/2,height-70); for(int p=400;p>0;p=p-50) {
    float pat=map(p,400,0,0,200);
    int pati=int(pat); 
    fill(255,0,0);
    textAlign(RIGHT);
    text(pati,98,p+5); //wind speed measurements
    float patie=map(p,400,0,850,1100);
    int paties=int(patie);
    fill(0,255,0);
    text(paties,75,p+5);//pressure measurements
    float patiesTemp=map(p,400,0,-30,55);
    int patiesTemp1=int (patiesTemp);
    fill(0,0,255);
    text(patiesTemp1,45,p+5); //temp measurements
    float patiesDirec=map(p,400,0,0,359);
    int patiesDirect=int(patiesDirec);
    fill(255);
    text(patiesDirect,25,p+5); 
    }
     
    println(Serial.list());
     
    myPort = new Serial(this, Serial.list()[0], 9600);
    myPort.bufferUntil('\n');
     
    }
    void draw(){}
     
    void serialEvent (Serial myPort) {
     
    String inString = myPort.readStringUntil('\n');
     
    String xWindSpeed= inString.substring(0,4);
    String xPressure= inString.substring(4,8);
    String xtemp= inString.substring(8,12);
    String xWindDirect=inString.substring(12,16);
    int yWindSpeed=int(xWindSpeed);
    int yPressure=int(xPressure);
    int ytemp=int(xtemp);
    int yWindDirect=int(xWindDirect);
     
    float WindSpeed=map(yWindSpeed,0,1023,height-104,-3);
    float Pressure=map(yPressure,0,1023,height-104,-3);
    float temp=map(ytemp,0,1023,height-104,-3);
    float WindDirect=map(yWindDirect,0,1023,height-104,-3);
     
    stroke(255,0,0,150);
    line(xPos,WindSpeed+4,xPos,WindSpeed);
     
    stroke(0,255,0,150);
    line(xPos,Pressure+4,xPos,Pressure);
     
    stroke(0,0,255,150);
    line(xPos,temp+4,xPos,temp);
     
    stroke(255,255,255,150);
    line(xPos,WindDirect+4,xPos,WindDirect);
     
    xPos++;
     
    if (xPos >= width) { 
    saveFrame("Weather-####.jpg");
    xPos=100;
    p=createFont("Arial",16,true);
     
    background(0); //set background black
    for(int u=99;u<width;u=u+60) { stroke(100); line(u,0,u,height-99); } for(int t=height-99;t>0;t=t-25) 
    {
    stroke(100);
    line(99,t,width,t);
    }
     
    textFont(p,12); //set font size to 12
    textAlign(LEFT);
    fill(255,0,0); //red
    text("Wind Speed MPH",100,height-25); 
    fill(0,255,0); //green
    text("Barometric pressure mb",210,height-25);
    fill(0,0,255); //blue
    text("Degrees Celsius",355,height-25);
    fill(255); //white
    text("Wind direction N = 0 deg",460,height-25);
    fill(100); //gray
    textAlign(RIGHT);
    text("0",110,height-87);
    for (int m=160;m<width;m=m+60) { int Min=(m-100)/60; fill(100); textAlign(CENTER); text(Min,m,height-87); } fill(100); textAlign(CENTER); text("Minutes",width/2,height-70); for(int p=400;p>0;p=p-50)
    {
    float pat=map(p,400,0,0,200);
    int pati=int(pat); 
    fill(255,0,0);
    textAlign(RIGHT);
    text(pati,98,p+5); 
    float patie=map(p,400,0,850,1100);
    int paties=int(patie);
    fill(0,255,0);
    text(paties,75,p+5);//pressure measurements
    float patiesTemp=map(p,400,0,-30,55);
    int patiesTemp1=int (patiesTemp);
    fill(0,0,255);
    text(patiesTemp1,45,p+5); //temp measurements
    float patiesDirec=map(p,400,0,0,359);
    int patiesDirect=int(patiesDirec);
    fill(255);
    text(patiesDirect,25,p+5); 
     
    }
    if (xPos < width) {
    xPos++;
    }
    }
    }

     

    PAYLAŞ

    Sezgin GÜL

    Makine Mühendisi, Maker, Robotik Sistemler Uzmanı

    Bir yorum yaz

    E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir

    Projeler Devamı

    Bizi Takip Et

    izmir escort- izmir escort- izmir escort- izmir escort- izmir escort