Zwer2k / WeatherStationDataRx

Arduino library for read weather data from Venus W174/W132 (tested), Auriol H13726, Hama EWS 1500, Meteoscan W155/W160
MIT License
22 stars 8 forks source link

Weather station demo example code error #14

Closed majo551 closed 3 years ago

majo551 commented 3 years ago

There is a logical error in the "if" branch for the wind Gust:

image

This will never write the wind gust value...

Moreover the code produces very difficult to read values , mixing different sensor IDs with different values coming from other sensors. I think the new sensor receiving should be halted until the previous one is read and fully printed...

I changed the example code little bit, though it still produces repeated lines due to the library logic...

This is my slight quick loop adjustment

`

byte newDataState = wsdr.readData(true);
if (newDataState > 0) {
  //  Serial.print("Sensor ID: ");
  //  Serial.println(wsdr.sensorID());

if (wsdr.dataHas(newDataState, NDTemperature)) {
    Serial.print("Sensor ID: ");
     Serial.print(wsdr.sensorID());
    Serial.print(">>> Battery: ");
    Serial.println(bitRead(wsdr.batteryStatus(), 0) == 0 ? "OK" : "Low");
}

if (wsdr.dataHas(newDataState, NDTemperature)) {
     Serial.print("Sensor ID: ");
     Serial.print(wsdr.sensorID());
    Serial.print(">>> Temperature: ");
    Serial.print(wsdr.readTemperature());
    Serial.print("°");
    Serial.println("C");
}

if (wsdr.dataHas(newDataState, NDHumidity)) {
     Serial.print("Sensor ID: ");
     Serial.print(wsdr.sensorID());
    Serial.print(">>> Humidity: ");
    Serial.print(wsdr.readHumidity());
    Serial.println("%");
}

if (wsdr.dataHas(newDataState, NDWindSpeed)) {
     Serial.print("Sensor ID: ");
     Serial.print(wsdr.sensorID());
    Serial.print(">>> Wind speed: ");
    Serial.print(wsdr.readWindSpeed());
    Serial.println("m/s");
}

if (wsdr.dataHas(newDataState, NDWindDirection)) {
     Serial.print("Sensor ID: ");
     Serial.print(wsdr.sensorID());
    Serial.print(">>> Wind direction: ");
    Serial.print(wsdr.readWindDirection());
     Serial.println("°");
}

if (wsdr.dataHas(newDataState, NDWindGust)) {
    Serial.print("Sensor ID: ");
     Serial.print(wsdr.sensorID());
          Serial.print(">>> Wind gust: ");
    Serial.print(wsdr.readWindGust());
    Serial.println("m/s");      
}

if (wsdr.dataHas(newDataState, NDRainVolume)) {
    Serial.print("Sensor ID: ");
     Serial.print(wsdr.sensorID());
    Serial.print(">>> Rain volume: ");
    Serial.println(wsdr.readRainVolume());
}

 }

}`

Zwer2k commented 3 years ago

Thank you very much. I have corrected the mistake. And improved the output.