6 changed files with 104 additions and 59 deletions
@ -0,0 +1,14 @@ |
|||
void getBME280Data() { |
|||
|
|||
float temp(NAN), hum(NAN), pres(NAN); |
|||
|
|||
BME280::TempUnit tempUnit(BME280::TempUnit_Celsius); |
|||
BME280::PresUnit presUnit(BME280::PresUnit_Pa); |
|||
|
|||
bme.read(pres, temp, hum, tempUnit, presUnit); |
|||
|
|||
temperature = temp; |
|||
humidity = hum; |
|||
pressure = pres; |
|||
|
|||
} |
@ -0,0 +1,34 @@ |
|||
|
|||
void getWind() { |
|||
|
|||
windDirection = ""; |
|||
anemometerVal = digitalRead(anemometerPin); |
|||
|
|||
if ((anemometerState == 1) && (anemometerVal == 0)) { |
|||
anemometerDuration = millis() - startime; |
|||
startime = millis(); |
|||
windSpeed = 2500.0/anemometerDuration; |
|||
} |
|||
|
|||
anemometerState = anemometerVal; |
|||
|
|||
if(millis() >= timer) { |
|||
Serial.println("--------------------------"); |
|||
Serial.println("Sending..."); |
|||
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(); |
|||
} |
|||
} |
Loading…
Reference in new issue