sending sensor_id for future multiple sensors and some better error correction
This commit is contained in:
parent
32a74c611c
commit
78a628dc4f
|
@ -55,8 +55,8 @@ void setup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// main loop speed
|
// main loop speed
|
||||||
if (sds011.setDutyCycle(2)) {
|
if (sds011.setDutyCycle(3)) {
|
||||||
Serial.println("SDS011 Duty Cycle set to 2min");
|
Serial.println("SDS011 Duty Cycle set to 3min");
|
||||||
} else {
|
} else {
|
||||||
Serial.println("FAIL: Unable to set Duty Cycle");
|
Serial.println("FAIL: Unable to set Duty Cycle");
|
||||||
}
|
}
|
||||||
|
@ -119,6 +119,7 @@ void loop() {
|
||||||
doc["humidity"] = humidity;
|
doc["humidity"] = humidity;
|
||||||
doc["pm25"] = pm25;
|
doc["pm25"] = pm25;
|
||||||
doc["pm10"] = pm10;
|
doc["pm10"] = pm10;
|
||||||
|
doc["sensor_id"] = sensorId;
|
||||||
|
|
||||||
// send data
|
// send data
|
||||||
String response;
|
String response;
|
||||||
|
@ -138,7 +139,7 @@ void loop() {
|
||||||
// retry on error
|
// retry on error
|
||||||
int retry = 0;
|
int retry = 0;
|
||||||
while ((!client.connect(host, 443)) && (retry < 5)) {
|
while ((!client.connect(host, 443)) && (retry < 5)) {
|
||||||
delay(1000);
|
delay(2000);
|
||||||
Serial.print(".");
|
Serial.print(".");
|
||||||
retry++;
|
retry++;
|
||||||
}
|
}
|
||||||
|
@ -175,13 +176,13 @@ void loop() {
|
||||||
WiFi.reconnect();
|
WiFi.reconnect();
|
||||||
reconnects ++;
|
reconnects ++;
|
||||||
// try reconnecting
|
// try reconnecting
|
||||||
while (WiFi.status() != WL_CONNECTED && reconnects < 10 ) {
|
while (WiFi.status() != WL_CONNECTED && reconnects < 5 ) {
|
||||||
delay(2000);
|
delay(10000);
|
||||||
Serial.print(".");
|
Serial.print(".");
|
||||||
reconnects ++;
|
reconnects ++;
|
||||||
}
|
}
|
||||||
// restart if all failed
|
// restart if all failed
|
||||||
if (WiFi.status() == WL_CONNECTED) {
|
if (WiFi.status() != WL_CONNECTED) {
|
||||||
ESP.restart();
|
ESP.restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,3 +5,5 @@ const char* password = "my-wifi-password";
|
||||||
|
|
||||||
const char* authUsername = "username";
|
const char* authUsername = "username";
|
||||||
const char* authPassword = "password";
|
const char* authPassword = "password";
|
||||||
|
|
||||||
|
const int sensorId = 1;
|
||||||
|
|
Loading…
Reference in New Issue