feature/InfluxDB-Connection-Update #1
2 changed files with 40 additions and 2 deletions
|
@ -37,6 +37,10 @@
|
|||
#define COUNT_TO_MPS (TWO_PI * ROTOR_LENGTH_M / WIND_SENSOR_MEAS_TIME_S)
|
||||
#define WINDSPEED_FACTOR (COUNT_TO_MPS * MPS_CORRECT_FACT)
|
||||
|
||||
#define HTTP_CALL_ON_WINDSPEED_EXCEED_MPS 5.0 // 5.0 m/s == 18 km/h
|
||||
#define HTTP_CALL_ON_WINDSPEED_INTERVAL_S 60 // it's required to be bigger than WIND_SENSOR_MEAS_TIME_S
|
||||
#define HTTP_CALL_ON_WINDSPEED_URL "http://192.168.0.250:3001/button-windspeedexceed?event=click"
|
||||
klaute marked this conversation as resolved
Outdated
|
||||
|
||||
#define BAT_LOW_VOLTAGE 3.6
|
||||
#define BAT_EMERGENCY_DEEPSLEEP_VOLTAGE 3.5
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <ESP8266WiFi.h>
|
||||
#include <DNSServer.h>
|
||||
#include <ESP8266WebServer.h>
|
||||
#include <ESP8266HTTPClient.h>
|
||||
|
||||
#include <WiFiClient.h> // WiFiClient
|
||||
#include <WiFiManager.h> // WiFiManager from bib manager
|
||||
|
@ -11,6 +12,12 @@
|
|||
// Project includes
|
||||
#include "config.h"
|
||||
|
||||
#ifdef HTTP_CALL_ON_WINDSPEED_EXCEED
|
||||
#if (HTTP_CALL_ON_WINDSPEED_INTERVAL_S < HTTP_CALL_ON_WINDSPEED_EXCEED_MPS)
|
||||
#error "HTTP_CALL_ON_WINDSPEED_INTERVAL_S < WIND_SENSOR_MEAS_TIME_S"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include "config_user.h"
|
||||
|
||||
//*************************************************************************//
|
||||
|
@ -19,8 +26,9 @@ const uint8_t VALUES = 8;
|
|||
float currentSensorData[VALUES] = {nanf("no value"), nanf("no value"), nanf("no value"), nanf("no value"), nanf("no value"), nanf("no value"), nanf("no value"), nanf("no value")};
|
||||
float (*sensors[VALUES])() = {};
|
||||
|
||||
uint16_t update_sensor_cnt = 0;
|
||||
uint16_t update_webserver_cnt = 0;
|
||||
uint16_t update_sensor_cnt = 0;
|
||||
uint16_t update_webserver_cnt = 0;
|
||||
uint16_t update_windspeed_exceed_cnt = 0;
|
||||
|
||||
WiFiManager wifiManager;
|
||||
|
||||
|
@ -206,10 +214,36 @@ void loop()
|
|||
#ifdef WEBUPDATER_FEATURE
|
||||
update_webserver_cnt++;
|
||||
#endif
|
||||
|
||||
#ifdef HTTP_CALL_ON_WINDSPEED_EXCEED
|
||||
update_windspeed_exceed_cnt++;
|
||||
#endif
|
||||
}
|
||||
|
||||
void _loop() {
|
||||
|
||||
#ifdef HTTP_CALL_ON_WINDSPEED_EXCEED
|
||||
if (HTTP_CALL_ON_WINDSPEED_INTERVAL_S * 1000 / DELAY_LOOP_MS > update_windspeed_exceed_cnt) {
|
||||
if (sensors[SENSOR_WINDSPEED]) {
|
||||
currentSensorData[SENSOR_WINDSPEED] = sensors[SENSOR_WINDSPEED]();
|
||||
|
||||
if (currentSensorData[SENSOR_WINDSPEED] >= HTTP_CALL_ON_WINDSPEED_EXCEED_MPS)
|
||||
{
|
||||
// call the url HTTP_CALL_ON_WINDSPEED_URL
|
||||
WiFiClient client;
|
||||
HTTPClient http;
|
||||
http.begin(client, String(HTTP_CALL_ON_WINDSPEED_URL).c_str());
|
||||
http.end();
|
||||
// Send HTTP GET request
|
||||
int httpResponseCode = http.GET();
|
||||
}
|
||||
} else {
|
||||
currentSensorData[SENSOR_WINDSPEED] = nan("no value");
|
||||
}
|
||||
update_windspeed_exceed_cnt = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef BATTERY_POWERED
|
||||
if (UPDATE_SENSOR_INTERVAL_S * 1000 / DELAY_LOOP_MS > update_sensor_cnt) {
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue
Ist das die Callback-URL, wenn der Wind zu stark weht?
Es wäre gut, wenn man das Feature an/ausschalten könnte, da es schon sehr spezifisch auf deinen Anwendungsfall gestrickt ist.