Compare commits

...

3 commits

4 changed files with 17 additions and 6 deletions

View file

@ -27,7 +27,7 @@
#define WIFI_MINIMUM_SIGNAL_QUALITY 10 // percent #define WIFI_MINIMUM_SIGNAL_QUALITY 10 // percent
#define RESET_ESP_TIME_INTERVAL_MS 3600000 #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 WIND_SENSOR_MEAS_TIME_S 5.0
#define SEC_TO_HOUR_FACTOR (60.0 * 60.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) #define COUNT_TO_KMH ((TWO_PI * ROTOR_LENGTH_KM / WIND_SENSOR_MEAS_TIME_S) * SEC_TO_HOUR_FACTOR)

View file

@ -68,9 +68,11 @@ void setup()
wifiManager.setTimeout(WIFI_CONFIG_PORTAL_TIMEOUT_S); wifiManager.setTimeout(WIFI_CONFIG_PORTAL_TIMEOUT_S);
#ifndef SLEEP_IF_NO_WLAN_CONNECTION #ifndef SLEEP_IF_NO_WLAN_CONNECTION
// do not sleep, repeat connecting
while while
#endif #endif
#ifdef def SLEEP_IF_NO_WLAN_CONNECTION #ifdef def SLEEP_IF_NO_WLAN_CONNECTION
// stop connecting after fail to connect to wifi
if if
#endif #endif
(!wifiManager.autoConnect(wifiName.c_str(), "DEADBEEF")) (!wifiManager.autoConnect(wifiName.c_str(), "DEADBEEF"))
@ -82,6 +84,7 @@ void setup()
delay(100); delay(100);
#endif #endif
#ifndef SLEEP_IF_NO_WLAN_CONNECTION #ifndef SLEEP_IF_NO_WLAN_CONNECTION
// sleep a few seconds and go on trying to connect
delay(5000); delay(5000);
#endif #endif
} }

View file

@ -12,7 +12,8 @@ ICACHE_RAM_ATTR void _anemometerInterrupt()
#endif #endif
} }
float wind_speed() { float wind_speed()
{
anemometerRotations = 0; anemometerRotations = 0;
int interruptNumber = digitalPinToInterrupt(ANEMOMETER_PIN); int interruptNumber = digitalPinToInterrupt(ANEMOMETER_PIN);
@ -21,6 +22,13 @@ float wind_speed() {
delay(1000 * WIND_SENSOR_MEAS_TIME_S); // time to measure delay(1000 * WIND_SENSOR_MEAS_TIME_S); // time to measure
detachInterrupt(interruptNumber); 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;
} }

View file

@ -26,7 +26,7 @@ float _webUpdater_sensValues[VALUES];
String hb_ws_msg_start = "{"; String hb_ws_msg_start = "{";
String hb_ws_msg_temp = "\"temperature\": "; String hb_ws_msg_temp = "\"temperature\": ";
String hb_ws_msg_humi = "\"humidity\": "; String hb_ws_msg_humi = "\"humidity\": ";
String hb_ws_msg_light = "\"light\": "; String hb_ws_msg_light = "\"lightlevel\": ";
String hb_ws_msg_windspeed = "\"windspeed\": "; String hb_ws_msg_windspeed = "\"windspeed\": ";
String hb_ws_msg_end = "}"; String hb_ws_msg_end = "}";
@ -87,9 +87,9 @@ void hb_webstat_send(void)
hb_ws_msg_temp + hb_ws_msg_temp +
String(_webUpdater_sensValues[SENSOR_TEMPERATURE], 2) + ", " + String(_webUpdater_sensValues[SENSOR_TEMPERATURE], 2) + ", " +
hb_ws_msg_humi + hb_ws_msg_humi +
String(_webUpdater_sensValues[SENSOR_HUMIDITY], 2) + ", " + String(int(_webUpdater_sensValues[SENSOR_HUMIDITY]), 2) + ", " +
hb_ws_msg_light + hb_ws_msg_light +
String(_webUpdater_sensValues[SENSOR_LIGHT], 2) + ", " + String(int(_webUpdater_sensValues[SENSOR_LIGHT]), 2) + ", " +
hb_ws_msg_windspeed + hb_ws_msg_windspeed +
String(_webUpdater_sensValues[SENSOR_WINDSPEED], 2) + String(_webUpdater_sensValues[SENSOR_WINDSPEED], 2) +
hb_ws_msg_end); hb_ws_msg_end);