@@ -44,7 +44,7 @@ ESP8266WiFiMulti wifiMulti;
44
44
// Japanesse: "JST-9"
45
45
// Central Europe: "CET-1CEST,M3.5.0,M10.5.0/3"
46
46
#define TZ_INFO " CET-1CEST,M3.5.0,M10.5.0/3"
47
- // NTP servers the for time syncronozation .
47
+ // NTP servers the for time synchronization .
48
48
// For the fastest time sync find NTP servers in your area: https://www.pool.ntp.org/zone/
49
49
#define NTP_SERVER1 " pool.ntp.org"
50
50
#define NTP_SERVER2 " time.nis.gov"
@@ -54,6 +54,8 @@ ESP8266WiFiMulti wifiMulti;
54
54
55
55
// InfluxDB client instance with preconfigured InfluxCloud certificate
56
56
InfluxDBClient client (INFLUXDB_URL, INFLUXDB_ORG, INFLUXDB_BUCKET, INFLUXDB_TOKEN, InfluxDbCloud2CACert);
57
+ // InfluxDB client instance without preconfigured InfluxCloud certificate for insecure connection
58
+ // InfluxDBClient client(INFLUXDB_URL, INFLUXDB_ORG, INFLUXDB_BUCKET, INFLUXDB_TOKEN);
57
59
58
60
// Data point
59
61
Point sensorStatus (" wifi_status" );
@@ -71,14 +73,17 @@ void setup() {
71
73
Serial.print (" Connecting to wifi" );
72
74
while (wifiMulti.run () != WL_CONNECTED) {
73
75
Serial.print (" ." );
74
- delay (100 );
76
+ delay (500 );
75
77
}
76
78
Serial.println ();
77
79
78
80
// Add tags
79
81
sensorStatus.addTag (" device" , DEVICE);
80
82
sensorStatus.addTag (" SSID" , WiFi.SSID ());
81
83
84
+ // Alternatively, set insecure connection to skip server certificate validation
85
+ // client.setInsecure(true);
86
+
82
87
// Accurate time is necessary for certificate validation and writing in batches
83
88
// Syncing progress and the time will be printed to Serial.
84
89
timeSync (TZ_INFO, NTP_SERVER1, NTP_SERVER2);
@@ -143,8 +148,9 @@ void loop() {
143
148
sensorStatus.clearFields ();
144
149
145
150
// If no Wifi signal, try to reconnect it
146
- if ((WiFi. RSSI () == 0 ) && ( wifiMulti.run () != WL_CONNECTED))
151
+ if (wifiMulti.run () != WL_CONNECTED) {
147
152
Serial.println (" Wifi connection lost" );
153
+ }
148
154
149
155
// End of the iteration - force write of all the values into InfluxDB as single transaction
150
156
Serial.println (" Flushing data into InfluxDB" );
0 commit comments