• Witaj na Forum Arduino Polska! Zapraszamy do rejestracji!
  • Znajdziesz tutaj wiele informacji na temat hardware / software.
Witaj! Logowanie Rejestracja


Ocena wątku:
  • 0 głosów - średnia: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Stacja pogodowa Arduino
#5
(27-05-2017, 10:14)Tomuh napisał(a): Pokaż kod

Pomiar Wiatru:
#include <SPI.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define BACKLIGHT_PIN 3


LiquidCrystal_I2C lcd(0x3F,2,1,0,4,5,6,7);


#define am 8 //podlaczenie anemometru do pinu 8
int licznik = 0; //licznik
int rotacja = 0; // number of rotacji
boolean stan =0; //status o
float wiatr;
 
void setup(){
pinMode (am, INPUT);
Serial.begin(9600);
lcd.begin(16,2);
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
lcd.print("wiatr: ");
lcd.begin(16, 2);
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);

}
 
void loop(){
licznik= licznik+1;
if (digitalRead(am)==LOW){  //I've checked that on free position anemometer is always closed
delay(2);
stan=!stan;
while (digitalRead(am)==LOW) ;
rotacja=rotacja+1 ;
}
 
if (licznik==100){
int czas1=millis();
wiatr = rotacja*0.89;
lcd.println(rotacja);
lcd.setCursor(0,0);
lcd.print("Predkosc wiatru= ");
lcd.print(wiatr, 2);
lcd.setCursor(0,6);
lcd.println(" km/h");

licznik=0; //reset licznika
rotacja=0; //reset rotacji

int czas2 =millis();
int czas=czas2-czas1;
Serial.println(czas);
lcd.clear();
}

delay(8); //this delay is put here to extend time of whole loop to 10ms
}

Nadajnik:
#include <DallasTemperature.h>  
#include <Wire.h>
#include <VirtualWire.h>
#include <BMP180.h>
#include <OneWire.h>                                
int one_wire = 9; 
OneWire oneWire(one_wire); 
DallasTemperature sensors(&oneWire);
BMP180 barometer;
float seaLevelPressure = 101000;

String calosc, cisn, temp, cisn1, temp1;
char Msg[20];


void setup()
{
  vw_setup(2000);
  
  
  cisn = String ("C: ");
  temp = String ("T: " );
  Serial.begin(9600);
  delay(5000);
  Serial.println("Stacja Meteo"); 
  
  Wire.begin();
  barometer = BMP180();
  if(barometer.EnsureConnected())
  {
    Serial.println("Connected to BMP180."); // Output we are connected to the computer.
    barometer.SoftReset();
    barometer.Initialize();
  }
  else
  { 
    Serial.println("Could not connect to BMP180.");

  }

  }



void loop()
{
 

if(barometer.IsConnected)
  {
    // Retrive the current pressure in Pascals.
    long currentPressure = barometer.GetPressure();
    
    int b = (currentPressure/100);
    String cisn1 = cisn + b + " hPa"  ;
    Serial.println (cisn1);
 
    sensors.requestTemperatures();    
    float currentTemperature = sensors.getTempCByIndex(0);

    int c = (currentTemperature);
    String temp1 = temp + c + " stC";
    Serial.println (temp1);
  
   String calosc = temp1 + cisn1 ;
   Serial.println(calosc);  
   
    calosc.toCharArray(Msg,(calosc.length()+1));
    for (int i = 0; i <= calosc.length(); i++) 
    Serial.print(Msg[i]);
 }
   
    vw_send((uint8_t *)Msg, strlen(Msg));
    vw_wait_tx(); 
    
    Serial.println("poszlo");         
    Serial.println(); // Start a new line.
    delay(3000); 
}
 
Odpowiedź
  


Wiadomości w tym wątku
Stacja pogodowa Arduino - przez streetek - 26-05-2017, 17:22
RE: Stacja pogodowa Arduino - przez Tomuh - 26-05-2017, 20:55
RE: Stacja pogodowa Arduino - przez streetek - 27-05-2017, 10:00
RE: Stacja pogodowa Arduino - przez Tomuh - 27-05-2017, 10:14
RE: Stacja pogodowa Arduino - przez streetek - 27-05-2017, 12:32
RE: Stacja pogodowa Arduino - przez kastor - 07-07-2017, 22:05
RE: Stacja pogodowa Arduino - przez loczek111 - 25-10-2019, 16:39

Skocz do:


Przeglądający: 1 gości