D1 Mini- Bridge request overload?

Hey all,

I’m looking into using a D1 mini (on local server) to remotely control an ESP+Mega that’s connected to a relay board- basically sending a number of digitalWrite’s over bridge.

When I enable the below code (using SimpleTimer at 15 sec intervals), my ping (from Serial debug) changes from about 5ms to over 300ms, and I get craptons of disconnects. Doesn’t seem to be working right.

I should also add that I’m using a generated token, but I actually have nothing besides the D1 connected (I’m just testing this out). But i get slowdown if I use virtualWrite OR digitalWrite.

void motorControl() {

  motorControlInProgress = true;

  //..........................................................................................................
  //Temperatre Control
  //..........................................................................................................

  //Room Temp Stable
  if ((tempSlider != 0) && (t != 1)) {
    if (t <= tempSlider) {
      hrvValveTemp = false;
      bridgeChamber2.digitalWrite(coolValveRelay, HIGH);  //Closes chiller valve
      chillerLED.off();
      blowerTemp = false;   //No request for blower
    }

    //Cooling Needed
    else if (t >= (tempSlider + tThreshold)) {
      blowerTemp = true;      //Turns on high speed blower
      bridgeChamber2.digitalWrite(coolValveRelay, LOW);   //Turns on the cooling valve relay
      chillerLED.on();
    }
  }

  //MANUAL TEMPERATURE 'OFF' MODE
  if (tempSlider == 0) {
    hrvValveTemp = false;
    bridgeChamber2.digitalWrite(coolValveRelay, HIGH);
    chillerLED.off();
    blowerTemp = false;
  }
  //MANUAL TEMPERATURE 'ON' MODE
  if (tempSlider == 1) {
    blowerTemp = true;      //Requests high speed blower
    bridgeChamber2.digitalWrite(coolValveRelay, LOW);   //Turns on the cooling valve relay
    chillerLED.on();
  }

  //..........................................................................................................
  //Humidity Control
  //..........................................................................................................

  //Room Humidity Stabe
  if ((humdSlider != 0) && (humdSlider != 1)) {
    if (h >= humdSlider) {
      bridgeChamber2.digitalWrite(humdRelay, HIGH);
      humidityLED.off();
      blowerHumd = false;
    }

    //Low Humidity Condition
    else if (h <= humdSlider - hThreshold) {
      bridgeChamber2.digitalWrite(humdRelay, LOW);
      humidityLED.on();
      blowerHumd = true;
    }
  }
  
  //MANUAL HUMIDITY 'OFF' MODE
  if (humdSlider == 0) {
    bridgeChamber2.digitalWrite(humdRelay, HIGH);
    humidityLED.off();
    blowerHumd = false;
  }
  
  //MANUAL HUMIDITY 'ON' MODE
  if (humdSlider == 1) {
    bridgeChamber2.digitalWrite(humdRelay, LOW);
    humidityLED.on();
    blowerHumd = true;
  }

  //..........................................................................................................
  //Co2 Control
  //..........................................................................................................

  //Co2 Stable
  if (co2Slider != 0 && co2Slider != 1) {
    //Stable CO2 condition
    if (co2 <= co2Slider && co2 != 0) {
      blowerCo2 = false;
      hrvValveCo2 = false;
    }
    //Co2 too high
    else if (co2 >= (co2Slider + co2Threshold)) {
      blowerCo2 = true;
      hrvValveCo2 = true;
    } else if ((co2 == 0) || (co2 < 0)) {
      blowerCo2 = false;
      hrvValveCo2 = false;
    }
  }

  //MANUAL CO2 'OFF' MODE
  if (co2Slider == 0) {
    blowerCo2 = false;
    hrvValveCo2 = false;
  }
  //MANUAL CO2 'ON' MODE
  if (co2Slider == 1) {
    blowerCo2 = true;
    hrvValveCo2 = true;
  }


  //..........................................................................................................
  //High/Low Blower Control
  //..........................................................................................................

  if (blowerCo2 || blowerHumd || blowerTemp) {
 
    bridgeChamber2.digitalWrite(lowSpeedBlowerRelay, HIGH);  //Makes sure low speed is disabled
    lowBlowLED.off();
    bridgeChamber2.digitalWrite(highSpeedBlowerRelay, LOW);
    highBlowLED.on();
    isBlowerOff = false;

  } else if (!blowerCo2 && !blowerHumd && !blowerTemp && lowSpeedBlower) {
    bridgeChamber2.digitalWrite(highSpeedBlowerRelay, HIGH);
    highBlowLED.off();
    bridgeChamber2.virtualWrite(lowSpeedBlowerRelay, LOW);
    lowBlowLED.on();
    isBlowerOff = false;

  } else if (!blowerCo2 && !blowerHumd && !blowerTemp && !lowSpeedBlower) {
    if (!isBlowerOff) {
      bridgeChamber2.digitalWrite(highSpeedBlowerRelay, HIGH);
      highBlowLED.off();
      bridgeChamber2.digitalWrite(lowSpeedBlowerRelay, HIGH);
      lowBlowLED.off();
      isBlowerOff = true;
    }
  }
  //..........................................................................................................
  //HRV Control
  //..........................................................................................................

  if (hrvValveCo2 || hrvValveTemp) {
    bridgeChamber2.digitalWrite(damperRelay, LOW);
    damperLED.on();
    bridgeHRV.digitalWrite(chamberNumber, 1);  // Sends request for HRV
    hrvLED.on();

  } else {
    bridgeHRV.digitalWrite(chamberNumber, 0);   //Sends request for no HRV
    hrvLED.off();
    bridgeChamber2.digitalWrite(damperRelay, HIGH);
    damperLED.off();
  }

  motorControlInProgress = false;
}