Debug output of windspeed calculation added.

This commit is contained in:
Kai Lauterbach 2022-05-16 10:45:08 +02:00
parent e13d72fa2c
commit fe3232cfe3
2 changed files with 11 additions and 3 deletions

View file

@ -27,7 +27,7 @@
#define WIFI_MINIMUM_SIGNAL_QUALITY 10 // percent
#define RESET_ESP_TIME_INTERVAL_MS 3600000
#define ROTOR_LENGTH_KM 0.000105
#define ROTOR_LENGTH_KM 0.000115
#define WIND_SENSOR_MEAS_TIME_S 5.0
#define SEC_TO_HOUR_FACTOR (60.0 * 60.0)
#define COUNT_TO_KMH ((TWO_PI * ROTOR_LENGTH_KM / WIND_SENSOR_MEAS_TIME_S) * SEC_TO_HOUR_FACTOR)

View file

@ -12,7 +12,8 @@ ICACHE_RAM_ATTR void _anemometerInterrupt()
#endif
}
float wind_speed() {
float wind_speed()
{
anemometerRotations = 0;
int interruptNumber = digitalPinToInterrupt(ANEMOMETER_PIN);
@ -21,6 +22,13 @@ float wind_speed() {
delay(1000 * WIND_SENSOR_MEAS_TIME_S); // time to measure
detachInterrupt(interruptNumber);
return (float)anemometerRotations * COUNT_TO_KMH;
// calculate the speed as km/h
float tmp_speed = (float)anemometerRotations * COUNT_TO_KMH;
#ifdef DEBUG
Serial.print("Windspeed: " + String(tmp_speed));
#endif
return tmp_speed;
}