Decreased the delay of rest response. Finished issue #4 and #6

This commit is contained in:
2017-08-24 22:24:06 +02:00
parent e12b9331ec
commit 464929cf88

View File

@@ -39,6 +39,13 @@ WiFiServer server(LISTEN_PORT);
float temperature; float temperature;
float humidity; float humidity;
//milli counter
long millitotal = 0;
void setup() { void setup() {
Serial.begin(115200); Serial.begin(115200);
Serial.println("Sensornode start"); Serial.println("Sensornode start");
@@ -74,8 +81,8 @@ void setup() {
void loop() { void loop() {
// Wait a few seconds between measurements. // Wait a few seconds between measurements.
delay(2000); float millicounter = millis();
if (millicounter >= millitotal) {
// Reading temperature or humidity takes about 250 milliseconds! // Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor) // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float h = dht.readHumidity(); float h = dht.readHumidity();
@@ -93,6 +100,9 @@ void loop() {
} }
//set new milli counter
millitotal = millis() + 2000;
}
// Handle REST calls // Handle REST calls
WiFiClient client = server.available(); WiFiClient client = server.available();
if (!client) { if (!client) {