 }
 
 void loop() {
-  //setup wifi
-  //in loop to re init connection if necessary
-  setupWifi();
+  unsigned long startTime = millis();
+
+  //delay before DHT measurements
+  delay(2000);
 
   // Reading temperature or humidity takes about 250 milliseconds!
   // Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)

#include "DHT.h"

//WiFi setup
#define ssid       "......."
#define password   "......."

//Thingspeak setup
#define thingspeakApiKey "................"
#define thingSpeakAddress "api.thingspeak.com"
#define thingSpeakUpdateJsonEndpoint "/update.json"
#define thingSpeakHttpPort 80
//Update data for the specific channel not frequently than 16 sec
#define thingSpeakUpdateInterval 16000
//Update data for the specific channel if it's the same not frequently than 5 mins
#define thingSpeakUpdateSameDataInterval 300000 //5 min

//DHT22
#define DHTTYPE DHT22


//wifi client
WiFiClient client;

// === wifi section
void setupWifi() {
