     else
     {
       sendCheck();
-      client.loop();
     }
   }   
 }

    receivedpayload += (char)inpayload[i];
  }

  Serial.print("[MQTT] intopic : ");
  Serial.print(receivedtopic);
  Serial.print(" payload: ");
  Serial.println(receivedpayload);

  parseMqttMsg(receivedpayload, receivedtopic);
}

bool verifytls()
{
  Serial.print("[MQTT] tls connecting to ");
  Serial.println(mqtt_server);
  if (!sslclient.connect(mqtt_server, 8883))
  {
    Serial.println("[MQTT] tls connection failed");
    return false;
  }

  if (sslclient.verify(MQTT_FINGERPRINT, MQTT_SERVER_CN))
  {
    Serial.println("[MQTT] tls certificate matches");
    sslclient.stop();
    return true;
  }
  else
  {
    Serial.println("[MQTT] tls certificate doesn't match");
    sslclient.stop();
    return false;
  }

{
  if (WiFi.status() != WL_CONNECTED)
  {
    wifi_set_phy_mode(PHY_MODE_11N);
    WiFi.setOutputPower(20);
    WiFi.mode(WIFI_STA);
    WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
    WiFi.hostname("esp-bedroomlight");
