WeMos D1 rebooting 2-5 seconds into driving stepper motor
The problem was that my loop() was running too long and WeMos thought it's stuck. To solve this, I added delay(1); in relevant places.

#include &lt;Stepper.h&gt;

Stepper stepper(200, 5, 4, 0, 2);

void setup() {
  stepper.setSpeed(30);
  pinMode(16, INPUT_PULLUP);
  Serial.begin(9600);
}

void home() {
  Serial.println("looking for home");
  while (digitalRead(16) == HIGH) {
    stepper.step(1);
    delay(1); // Prevent "Soft WDT reset"
  }
  while (digitalRead(16) == LOW) {
    stepper.step(-1);
    delay(1); // Prevent "Soft WDT reset"
  }
  Serial.println("at home");
}

void loop() {
  home();
  delay(1000);
  for (int i = 0; i &lt; 100; i++) {
    Serial.println("step " + String(i));
    stepper.step(-1);
    delay(1); // Prevent "Soft WDT reset"
  }
  delay(5000);
}