     reconnect();
     }
     client.loop();
+    if (now < OTAUntilMillis && OTARdyFlag == 0) {
+      wifiSetupOTA();
+      OTARdyFlag = 1;
+    }
+    if (now < OTAUntilMillis && OTARdyFlag == 1) {
+      ArduinoOTA.handle();
+    }
 }
 
 

unsigned long now           = 0 ;
unsigned long prevMillis    = 0 ;
unsigned long OTAUntilMillis = 0 ;
uint8_t discSlipPrecond     = 0 ;
uint8_t restartCount        = 0 ;
char msg[50];                   

pinMode(HALLSENSORPIN, INPUT_PULLUP);
digitalWrite(STARTRELAYPIN, LOW);
attachInterrupt(digitalPinToInterrupt(HALLSENSORPIN), sensorPulseCount, FALLING);
Serial.begin(115200);
wifiSetup();
client.setServer(mqtt_server, 1883);
client.setCallback(callback);
/////////////////////////////
delay(5000);
//motionControlStart(); // remove when MQTT is active. testing only 
