 
 #define NB_PROXIM_SAMPLES 20
 #define NB_ANOMALY_COUNTS 15
+
+#define MAX_CLIENT_RETRIES 10
 
 uint16_t proxim_nominal = 2000;
 uint16_t proxim_anomaly = 100;

  setup_wifi();
  mqttClient.setServer(MQTT_SERVER, MQTT_PORT);

  // Prepare client
  connectClient();
  
  // Schedulers
  // tickerHeartbeat.attach(10, heartbeat);
  // tickerUpdate.attach_ms(100, update);

  }
}

bool connectClient() {
  uint8_t nbtry = 0;
  bool connected = mqttClient.connected();
  while ( !connected && nbtry < MAX_CLIENT_RETRIES ) {
    Serial.print("Attempting MQTT connection...");
    nbtry++;
    if (mqttClient.connect("MistyDoor")) {
      Serial.println("connected");
      connected = true;
    } else {
      Serial.print("failed, rc=");
      Serial.print(mqttClient.state());
