Bug fixed, in case that the ping test was disabled, the ESP would reset every 120s by default. Version String added. Logger update interval (seconds) added.
This commit is contained in:
parent
12aec59c20
commit
e4e35fcd07
3 changed files with 51 additions and 36 deletions
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
// config general setting and behavior of the weatherstation
|
// config general setting and behavior of the weatherstation
|
||||||
|
|
||||||
|
#define VERSION_STRING "1.1.1"
|
||||||
|
|
||||||
#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
|
||||||
|
@ -16,6 +18,7 @@
|
||||||
#define WATCHDOG_TIMEOUT_MS WDTO_8S // Look at Esp.h for further possible time declarations
|
#define WATCHDOG_TIMEOUT_MS WDTO_8S // Look at Esp.h for further possible time declarations
|
||||||
#define WIFI_CHECK_INTERVAL_MS 120000
|
#define WIFI_CHECK_INTERVAL_MS 120000
|
||||||
#define INFLUXDB_TIMEOUT_MS 1000
|
#define INFLUXDB_TIMEOUT_MS 1000
|
||||||
|
#define WEB_LOGGER_UPDATE_S 5
|
||||||
|
|
||||||
#define ENERGY_SAVING_ITERATIONS 30
|
#define ENERGY_SAVING_ITERATIONS 30
|
||||||
|
|
||||||
|
|
|
@ -13,11 +13,11 @@
|
||||||
#include "config_user.h"
|
#include "config_user.h"
|
||||||
|
|
||||||
#ifdef ENABLE_PING_HOST_TEST
|
#ifdef ENABLE_PING_HOST_TEST
|
||||||
#include <ESP8266Ping.h>
|
#include <ESP8266Ping.h> // https://github.com/dancol90/ESP8266Ping
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef DISABLE_WIFIMANAGER
|
#ifndef DISABLE_WIFIMANAGER
|
||||||
#include <WiFiManager.h> // WiFiManager from bib manager
|
#include <WiFiManager.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HTTP_CALL_ON_WINDSPEED_EXCEED
|
#ifdef HTTP_CALL_ON_WINDSPEED_EXCEED
|
||||||
|
@ -286,7 +286,12 @@ void wifiConnectionCheck() {
|
||||||
/*if (WiFi.status() == WL_CONNECTED) {
|
/*if (WiFi.status() == WL_CONNECTED) {
|
||||||
// if we are connected
|
// if we are connected
|
||||||
return;
|
return;
|
||||||
}*/
|
} else {
|
||||||
|
debug("Connection problem (wlan problem), resetting ESP");
|
||||||
|
delay(1000);
|
||||||
|
ESP.reset();
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
#ifdef ENABLE_PING_HOST_TEST
|
#ifdef ENABLE_PING_HOST_TEST
|
||||||
debug("Ping " + String(PING_HOST_IP));
|
debug("Ping " + String(PING_HOST_IP));
|
||||||
|
@ -295,17 +300,17 @@ void wifiConnectionCheck() {
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
debug("Ping success");
|
debug("Ping success");
|
||||||
return;
|
debug("Min Time: " + String(Ping.minTime()) + " ms");
|
||||||
|
debug("Average Time: " + String(Ping.averageTime()) + " ms");
|
||||||
|
debug("Max Time: " + String(Ping.maxTime()) + " ms");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
debug("Connection problem (ping failed), resetting ESP");
|
||||||
|
delay(1000);
|
||||||
|
ESP.reset();
|
||||||
}
|
}
|
||||||
#endif // ENABLE_PING_HOST_TEST
|
#endif // ENABLE_PING_HOST_TEST
|
||||||
|
|
||||||
debug("Connection problem, resetting ESP");
|
|
||||||
#ifdef ENABLE_WATCHDOG
|
|
||||||
// loop endless, watchdog will reset the device
|
|
||||||
while (1 == 1) {}
|
|
||||||
#endif
|
|
||||||
ESP.reset();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DISABLE_WIFIMANAGER
|
#ifdef DISABLE_WIFIMANAGER
|
||||||
|
@ -559,8 +564,9 @@ void _fsm_loop()
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------------- */
|
||||||
case FSM_STATE_6:
|
case FSM_STATE_6:
|
||||||
//debug("log to serial if required");
|
//
|
||||||
#ifdef SERIAL_FEATURE
|
#ifdef SERIAL_FEATURE
|
||||||
|
debug("log to serial");
|
||||||
logToSerial(currentSensorData);
|
logToSerial(currentSensorData);
|
||||||
#endif
|
#endif
|
||||||
fsm_state = FSM_STATE_7;
|
fsm_state = FSM_STATE_7;
|
||||||
|
@ -568,7 +574,6 @@ void _fsm_loop()
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------------- */
|
||||||
case FSM_STATE_7:
|
case FSM_STATE_7:
|
||||||
//debug("send data to influxdb if required");
|
|
||||||
for (uint8_t i = 0; i < 5 and validData == false; i++) { // only check sensor data 0 to 4 -> SENSOR_TEMPERATURE, SENSOR_HUMIDITY, SENSOR_LIGHT, SENSOR_WINDSPEED, SENSOR_PRESSURE
|
for (uint8_t i = 0; i < 5 and validData == false; i++) { // only check sensor data 0 to 4 -> SENSOR_TEMPERATURE, SENSOR_HUMIDITY, SENSOR_LIGHT, SENSOR_WINDSPEED, SENSOR_PRESSURE
|
||||||
if (currentSensorData[i] != 0 and currentSensorData[i] != nanf("no value") and (not isnan(currentSensorData[i]))) {
|
if (currentSensorData[i] != 0 and currentSensorData[i] != nanf("no value") and (not isnan(currentSensorData[i]))) {
|
||||||
validData = true;
|
validData = true;
|
||||||
|
@ -577,6 +582,7 @@ void _fsm_loop()
|
||||||
#ifdef INFLUXDB_FEATURE
|
#ifdef INFLUXDB_FEATURE
|
||||||
if (validData == true) {
|
if (validData == true) {
|
||||||
// send data only if valid data is available
|
// send data only if valid data is available
|
||||||
|
debug("send data to influxdb");
|
||||||
pushToInfluxDB(DEVICE_NAME, currentSensorData);
|
pushToInfluxDB(DEVICE_NAME, currentSensorData);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -585,9 +591,10 @@ void _fsm_loop()
|
||||||
|
|
||||||
/* -------------------------------------------------------------------------------- */
|
/* -------------------------------------------------------------------------------- */
|
||||||
case FSM_STATE_8:
|
case FSM_STATE_8:
|
||||||
//debug("set sensor data in webupdater if required");
|
|
||||||
#ifdef WEBUPDATER_FEATURE
|
#ifdef WEBUPDATER_FEATURE
|
||||||
#ifdef SHOW_SENSOR_DATA_ON_WEBUPDATER_MAIN_PAGE
|
#ifdef SHOW_SENSOR_DATA_ON_WEBUPDATER_MAIN_PAGE
|
||||||
|
debug("set sensor data in webupdater");
|
||||||
setSensorData(currentSensorData);
|
setSensorData(currentSensorData);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -105,10 +105,11 @@ void setSensorData(float sensorValues[]) {
|
||||||
|
|
||||||
void showHTMLMain(void) {
|
void showHTMLMain(void) {
|
||||||
|
|
||||||
String message = "<html><head><title>OKO Weatherstation - " + String(_webUpdater_dev) + "</title>"
|
String message = "<html><head><title>OKO Weatherstation " + String(VERSION_STRING) + " - " + String(_webUpdater_dev) + "</title>"
|
||||||
"<meta http-equiv=\"refresh\" content=\"20\">"
|
"<meta http-equiv=\"refresh\" content=\"20\">"
|
||||||
"</head><body>"
|
"</head><body>"
|
||||||
"<br><a href=\"http://"
|
"OKO Weatherstation " + String(VERSION_STRING) + " - " + String(_webUpdater_dev) + "<br>"
|
||||||
|
"<br><a href=\"http://"
|
||||||
+ _webUpdater_ip + ":8080/update\">firmware update</a><br><br>"
|
+ _webUpdater_ip + ":8080/update\">firmware update</a><br><br>"
|
||||||
#ifdef USE_LOGGER
|
#ifdef USE_LOGGER
|
||||||
"<br><a href=\"http://"
|
"<br><a href=\"http://"
|
||||||
|
@ -165,11 +166,12 @@ void hb_webstat_send(void) {
|
||||||
|
|
||||||
void resetESP() {
|
void resetESP() {
|
||||||
|
|
||||||
String message = "<html><head><title>OKO Weatherstation - " + String(_webUpdater_dev) + " - reset WiFi manager</title>"
|
String message = "<html><head><title>OKO Weatherstation " + String(VERSION_STRING) + " - " + String(_webUpdater_dev) + " - reset WiFi manager</title>"
|
||||||
"<meta http-equiv=\"refresh\" content=\"20\">"
|
"<meta http-equiv=\"refresh\" content=\"20\">"
|
||||||
"</head><body>"
|
"</head><body>"
|
||||||
"Rebooting...<br>"
|
"OKO Weatherstation " + String(VERSION_STRING) + " - " + String(_webUpdater_dev) + "<br>"
|
||||||
"</body></html>";
|
"Rebooting...<br>"
|
||||||
|
"</body></html>";
|
||||||
|
|
||||||
httpServer.send(200, "text/html", message);
|
httpServer.send(200, "text/html", message);
|
||||||
|
|
||||||
|
@ -190,12 +192,13 @@ void resetESP() {
|
||||||
|
|
||||||
void resetWifiManager() {
|
void resetWifiManager() {
|
||||||
|
|
||||||
String message = "<html><head><title>OKO Weatherstation - " + String(_webUpdater_dev) + " - reset WiFi manager</title>"
|
String message = "<html><head><title>OKO Weatherstation " + String(VERSION_STRING) + " - " + String(_webUpdater_dev) + " - reset WiFi manager</title>"
|
||||||
"<meta http-equiv=\"refresh\" content=\"20\">"
|
"<meta http-equiv=\"refresh\" content=\"20\">"
|
||||||
"</head><body>"
|
"</head><body>"
|
||||||
"Reset WifiManager config.<br>"
|
"Reset WifiManager config.<br>"
|
||||||
"Rebooting...<br>"
|
"OKO Weatherstation " + String(VERSION_STRING) + " - " + String(_webUpdater_dev) + "<br>"
|
||||||
"</body></html>";
|
"Rebooting...<br>"
|
||||||
|
"</body></html>";
|
||||||
|
|
||||||
httpServer.send(200, "text/html", message);
|
httpServer.send(200, "text/html", message);
|
||||||
|
|
||||||
|
@ -227,9 +230,10 @@ void measureWindspeed() {
|
||||||
float tmp_windspeed = wind_speed();
|
float tmp_windspeed = wind_speed();
|
||||||
digitalWrite(STATUS_LED_PIN, LOW);
|
digitalWrite(STATUS_LED_PIN, LOW);
|
||||||
|
|
||||||
String message = "<html><head><title>OKO Weatherstation - " + String(_webUpdater_dev) + " - manual wind measurement</title>"
|
String message = "<html><head><title>OKO Weatherstation " + String(VERSION_STRING) + " - " + String(_webUpdater_dev) + " - manual wind measurement</title>"
|
||||||
"</head><body>"
|
"</head><body>"
|
||||||
"Windsensor measurement result: "
|
"OKO Weatherstation " + String(VERSION_STRING) + " - " + String(_webUpdater_dev) + "<br>"
|
||||||
|
"Windsensor measurement result: "
|
||||||
+ String(tmp_windspeed) + "<br>"
|
+ String(tmp_windspeed) + "<br>"
|
||||||
"</body></html>";
|
"</body></html>";
|
||||||
|
|
||||||
|
@ -261,10 +265,11 @@ void logdata(String s) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void showLog() {
|
void showLog() {
|
||||||
String message = "<html><head><title>OKO Weatherstation - " + String(_webUpdater_dev) + " - logfile</title>"
|
String message = "<html><head><title>OKO Weatherstation " + String(VERSION_STRING) + " - " + String(_webUpdater_dev) + " - logfile</title>"
|
||||||
"<meta http-equiv=\"refresh\" content=\"5\">"
|
"<meta http-equiv=\"refresh\" content=\""+String(WEB_LOGGER_UPDATE_S)+"\">"
|
||||||
"</head><body>"
|
"</head><body>"
|
||||||
"Logfile data:<br>";
|
"OKO Weatherstation " + String(VERSION_STRING) + " - " + String(_webUpdater_dev) + "<br>"
|
||||||
|
"Logfile data:<br>";
|
||||||
|
|
||||||
for (uint16_t lp = 0; lp < logger_pos; lp++) {
|
for (uint16_t lp = 0; lp < logger_pos; lp++) {
|
||||||
message = message + logfile[lp] + "<br>";
|
message = message + logfile[lp] + "<br>";
|
||||||
|
|
Loading…
Reference in a new issue