Compare commits
No commits in common. "6aa242da8504ebd1150273df0570000d504eac09" and "417493c8ba8c88e3b9392765522ca9cd0f680121" have entirely different histories.
6aa242da85
...
417493c8ba
4 changed files with 19 additions and 35 deletions
|
@ -6,7 +6,7 @@
|
||||||
#define WIFI_AUTOCONNECT_TIMEOUT_S 60
|
#define WIFI_AUTOCONNECT_TIMEOUT_S 60
|
||||||
#define WIFI_CONFIG_PORTAL_TIMEOUT_S 120
|
#define WIFI_CONFIG_PORTAL_TIMEOUT_S 120
|
||||||
#define UPDATE_SENSOR_INTERVAL_S 300
|
#define UPDATE_SENSOR_INTERVAL_S 300
|
||||||
#define UPDATE_WEBSERVER_INTVERVAL_MS 500 // Values greater than 1000 will negative affect availability of the webinterface
|
#define UPDATE_WEBSERVER_INTVERVAL_S 1 // Do not change, bigger values will prevent using webupdater webinterface
|
||||||
#define DELAY_LOOP_MS 100
|
#define DELAY_LOOP_MS 100
|
||||||
#define POWERSAVING_SLEEP_S 600
|
#define POWERSAVING_SLEEP_S 600
|
||||||
#define EMERGENCY_SLEEP_S 172800 // Sleep for 2 days to recover
|
#define EMERGENCY_SLEEP_S 172800 // Sleep for 2 days to recover
|
||||||
|
@ -14,7 +14,6 @@
|
||||||
#define WIND_SENSOR_MEAS_TIME_S 15
|
#define WIND_SENSOR_MEAS_TIME_S 15
|
||||||
#define WATCHDOG_TIMEOUT_MS 30000
|
#define WATCHDOG_TIMEOUT_MS 30000
|
||||||
#define WIFI_CHECK_INTERVAL_MS 120000
|
#define WIFI_CHECK_INTERVAL_MS 120000
|
||||||
#define INFLUXDB_TIMEOUT_MS 1000
|
|
||||||
|
|
||||||
#define ENERGY_SAVING_ITERATIONS 30
|
#define ENERGY_SAVING_ITERATIONS 30
|
||||||
|
|
||||||
|
|
|
@ -338,7 +338,7 @@ void _fsm_loop()
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef WEBUPDATER_FEATURE
|
#ifdef WEBUPDATER_FEATURE
|
||||||
if ((update_webserver_cnt + (UPDATE_WEBSERVER_INTVERVAL_MS)) <= millis())
|
if ((update_webserver_cnt + (UPDATE_WEBSERVER_INTVERVAL_S * 1000)) <= millis())
|
||||||
{
|
{
|
||||||
//debug("web updater call");
|
//debug("web updater call");
|
||||||
update_webserver_cnt = millis();
|
update_webserver_cnt = millis();
|
||||||
|
@ -360,12 +360,9 @@ void _fsm_loop()
|
||||||
// reset the wait timer to get a value every HTTP_CALL_ON_WINDSPEED_INTERVAL_S independently to the runtime of the measurement
|
// reset the wait timer to get a value every HTTP_CALL_ON_WINDSPEED_INTERVAL_S independently to the runtime of the measurement
|
||||||
update_windspeed_exceed_cnt = millis();
|
update_windspeed_exceed_cnt = millis();
|
||||||
|
|
||||||
// start measurement of wind speed
|
start_measure_wind(); // start measurement of wind speed
|
||||||
start_measure_wind();
|
|
||||||
|
|
||||||
fsm_state = FSM_STATE_11; // wait untile the wind meas time exceeded
|
fsm_state = FSM_STATE_11; // wait untile the wind meas time exceeded
|
||||||
break; // abort case here to prevent read of next sensor in list
|
break; // abort case here to prevent read of next sensor in list
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
fsm_state = FSM_STATE_2;
|
fsm_state = FSM_STATE_2;
|
||||||
|
|
|
@ -176,35 +176,26 @@ void pushToInfluxDB(String device, float sensorValues[]) {
|
||||||
void _writePoint()
|
void _writePoint()
|
||||||
{
|
{
|
||||||
|
|
||||||
uint32_t _timeout = millis();
|
|
||||||
|
|
||||||
//debug("InfluxDB2: check connection");
|
|
||||||
do {
|
|
||||||
} while (client.validateConnection() and (_timeout + INFLUXDB_TIMEOUT_MS) <= millis());
|
|
||||||
|
|
||||||
if (! client.validateConnection())
|
|
||||||
{
|
|
||||||
debug("Can't write to InfluxDB2, timeout validating connection");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_timeout = millis();
|
|
||||||
|
|
||||||
//debug("InfluxDB2: waiting for write ready");
|
|
||||||
// wait unitl ready
|
// wait unitl ready
|
||||||
do {
|
do {
|
||||||
} while (client.canSendRequest() == false and (_timeout + INFLUXDB_TIMEOUT_MS) <= millis());
|
#ifdef DEBUG
|
||||||
|
Serial.print("InfluxDB: waiting for write ready\n");
|
||||||
if (! client.canSendRequest())
|
#endif
|
||||||
{
|
} while (client.canSendRequest() == false);
|
||||||
debug("Can't write to InfluxDB2, timeout canSendRequest");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write point
|
// Write point
|
||||||
if (!client.writePoint(sensor))
|
if (!client.writePoint(sensor)) {
|
||||||
{
|
#ifdef DEBUG
|
||||||
debug("InfluxDB2 write failed: " + String(client.getLastErrorMessage()) + " Err: " + String(client.getLastStatusCode()));
|
Serial.print("InfluxDB write failed: ");
|
||||||
|
Serial.println(client.getLastErrorMessage());
|
||||||
|
Serial.print("\nErrorcode: ");
|
||||||
|
Serial.println(client.getLastStatusCode());
|
||||||
|
Serial.print("\n");
|
||||||
|
#endif
|
||||||
|
} else {
|
||||||
|
#ifdef DEBUG
|
||||||
|
Serial.print("InfluxDB write done\n");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,11 +25,9 @@ float wind_speed()
|
||||||
|
|
||||||
void start_measure_wind()
|
void start_measure_wind()
|
||||||
{
|
{
|
||||||
|
|
||||||
start_meas_wind_time = millis();
|
start_meas_wind_time = millis();
|
||||||
anemometerRotations = 0;
|
anemometerRotations = 0;
|
||||||
interruptNumber = digitalPinToInterrupt(ANEMOMETER_PIN);
|
interruptNumber = digitalPinToInterrupt(ANEMOMETER_PIN);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean check_measure_wind_done()
|
boolean check_measure_wind_done()
|
||||||
|
@ -44,6 +42,5 @@ boolean check_measure_wind_done()
|
||||||
|
|
||||||
float measure_wind_result()
|
float measure_wind_result()
|
||||||
{
|
{
|
||||||
start_meas_wind_time = 0;
|
|
||||||
return (float)anemometerRotations * WINDSPEED_FACTOR;
|
return (float)anemometerRotations * WINDSPEED_FACTOR;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue