 
     Serial.print("task start: now = ");
     Serial.println(millis());
+
+    if (!mqttClient.connected()) {
+        Serial.println("End of setup, NOT connected");
+    } else {
+        Serial.println("End of setup, still connected");
+    }
 }
 
 void loop()

#include <TaskManager.h>
#include <WiFi.h>

#include "config.h"
/**
 * config.sh should define:
 * const char* wifiSSID = "...";
 * const char* wifiPassword = "....."
 **/

// Constants
const int DHT_DATA_PIN = 17;

// Globals
DHTesp dht;

void setup()
{
    // Serial setup
    Serial.begin(115200);
    delay(2000);

    // Sensor setup
    dht.setup(DHT_DATA_PIN, DHTesp::DHT11);
    Serial.println("DHT initiated");

    // Wifi setup
    Serial.print("Connecting to ");
    Serial.println(wifiSSID);
    WiFi.disconnect();


    Serial.print("IP number assigned by DHCP is ");
    Serial.println(WiFi.localIP());
}

void setupMQTT()
{
    mqttClient.setServer(mqttServer, mqttPort);
    mqttClient.setCallback(mqttSubHandler);
    mqttConnect();
}

void setup()
{
    // Serial setup
    Serial.begin(115200);
    delay(2000);

    // Sensor setup
    dht.setup(DHT_DATA_PIN, DHTesp::DHT11);
    Serial.println("DHT initiated");

    setupWiFi();
    setupMQTT();

    // Read dht every 1000[ms] and repeat forever
    Tasks.interval(10000, [] {
        char buffer[8];
        // Reading temperature for humidity takes about 250 milliseconds!
        // Sensor readings may also be up to 2 seconds 'old' (it's a very slow sensor)
        TempAndHumidity newValues = dht.getTempAndHumidity();
