Browse Source

InfluxDB hostname replaced by IP v4 address. Added a config setup portal timeout.

klaute 2 years ago
parent
commit
d744fffeb0
2 changed files with 15 additions and 4 deletions
  1. 5
    1
      firmware/config.h
  2. 10
    3
      firmware/firmware.ino

+ 5
- 1
firmware/config.h View File

@@ -10,10 +10,13 @@
10 10
 #define SENSOR_PRESSURE       4
11 11
 #define SENSOR_BAT_VOLTAGE    5
12 12
 
13
+#define WIFI_AUTOCONNECT_TIMEOUT_S    60
14
+#define WIFI_CONFIG_PORTAL_TIMEOUT_S  60
13 15
 #define UPDATE_SENSOR_INTERVAL_S      10
14 16
 #define UPDATE_WEBSERVER_INTVERVAL_S   1
15 17
 #define DELAY_LOOP_MS                 50
16 18
 #define POWERSAVING_SLEEP_S          600
19
+
17 20
 #define BAT_LOW_VOLTAGE              3.4
18 21
 
19 22
 #define STATUS_LED_PIN        BUILTIN_LED
@@ -30,7 +33,8 @@
30 33
 
31 34
 #define BME280_ADDRESS 0x76
32 35
 
33
-const char     *INFLUXDB_HOST = "influxdb.okoyono.de";
36
+//const char     *INFLUXDB_HOST = "influxdb.okoyono.de";
37
+const char     *INFLUXDB_HOST = "37.59.213.225";
34 38
 const uint16_t  INFLUXDB_PORT = 80;
35 39
 const char     *INFLUXDB_DB   = "weatherstation";
36 40
 const char     *INFLUXDB_USER = "oko";

+ 10
- 3
firmware/firmware.ino View File

@@ -64,14 +64,19 @@ void setup() {
64 64
 
65 65
   // Establish WiFi connection
66 66
   String wifiName = "oko-weather-" + String(ESP.getChipId());
67
+
67 68
   wifiManager.setMinimumSignalQuality(15);
68
-  wifiManager.setConnectTimeout(60);
69
+
70
+  wifiManager.setConnectTimeout(60); // the time in seconds to wait for the known wifi connection
71
+  wifiManager.setTimeout(60); // the time in seconds to wait for the user to configure the device
72
+
69 73
   if (!wifiManager.autoConnect(wifiName.c_str(), "DEADBEEF")) {
70 74
 #ifdef DEBUG
71 75
     Serial.println("WiFi connection failed, we reboot ...");
72 76
 #endif
73
-    ESP.reset();
74
-    delay(1000);
77
+
78
+    ESP.deepSleep(POWERSAVING_SLEEP_S * 1000000, WAKE_RF_DEFAULT);
79
+    delay(100);
75 80
   }
76 81
 
77 82
 #ifdef DEBUG
@@ -113,6 +118,7 @@ void setup() {
113 118
 
114 119
   // the ESP.deepSleep requires microseconds as input, after the sleep the system will run into the setup routine
115 120
   ESP.deepSleep(POWERSAVING_SLEEP_S * 1000000, WAKE_RF_DEFAULT);
121
+  delay(100);
116 122
 
117 123
 #endif
118 124
 
@@ -128,6 +134,7 @@ void lowBatCheck()
128 134
     Serial.println("Low battery, going into deep sleep.");
129 135
 #endif
130 136
     ESP.deepSleep(4294967295); // battery low, shutting down
137
+    delay(100);
131 138
   }
132 139
 }
133 140
 

Loading…
Cancel
Save