You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1006 B
43 lines
1006 B
|
|
void getWind() {
|
|
|
|
windDirection = "";
|
|
anemometerVal = digitalRead(anemometerPin);
|
|
|
|
//Serial.println(anemometerVal);
|
|
|
|
if ((anemometerState == 1) && (anemometerVal == 0)) {
|
|
anemometerDuration = millis() - startime;
|
|
startime = millis();
|
|
windSpeed = 2500.0/anemometerDuration;
|
|
}
|
|
|
|
anemometerState = anemometerVal;
|
|
|
|
if(millis() >= timer) {
|
|
|
|
Serial.println("--------------------------");
|
|
|
|
timer = millis() + timerLimit;
|
|
|
|
if(digitalRead(northPin)) {windDirection = windDirection + "N";}
|
|
if(digitalRead(southPin)) {windDirection = windDirection + "S";}
|
|
if(digitalRead(eastPin)) {windDirection = windDirection + "E";}
|
|
if(digitalRead(westPin)) {windDirection = windDirection + "W";}
|
|
|
|
if(printSensorsData) {
|
|
Serial.print("Wind speed:\t");
|
|
Serial.print(windSpeed);
|
|
Serial.println("Km/h");
|
|
|
|
Serial.print("Wind direction:\t");
|
|
Serial.println(windDirection);
|
|
|
|
}
|
|
|
|
sendRequest();
|
|
//delay(5000);
|
|
|
|
}
|
|
|
|
}
|