Can't connect to WiFi when using NeoPixel library on Wemos?

I have a WeMos D1 Mini and a WS2812B RGB LED strip. My end goal is to create a sort of Phillips Hue knockoff.

I can upload the NeoPixel strandtest example and it animates the LEDs just fine.

I start running into problems why I try to also incorporate ESP8266WiFi

#include <ESP8266WiFi.h>
#include <Adafruit_NeoPixel.h>

constexpr uint8_t LED_PIN = D1;
constexpr uint8_t NUM_LEDS = 34;

Adafruit_NeoPixel strip{ NUM_LEDS, LED_PIN, NEO_RGB + NEO_KHZ800 };

const char* ssid = "network-name";
const char* password = "password";
constexpr int port = 8181;

WiFiServer server{ port };

void setup()
{
  Serial.begin(9600);
 
//  strip.begin();
//  strip.setBrightness(0);
//  strip.show();

  WiFi.begin(ssid, password);

  Serial.print("Connecting");
 
  while (WiFi.status() != WL_CONNECTED)
  {
    delay(500);
    Serial.print(".");
//    strip.setBrightness(strip.getBrightness() ? 0 : 50);
//    strip.show();
  }

  Serial.println();
  Serial.print("Connected, IP address: ");
  Serial.println(WiFi.localIP());

  server.begin();
}

void loop()
{  
  WiFiClient client = server.available();
  while (client.connected())
  {
    if (client.available())
    {
      uint8_t buf;
      size_t length = 1;
      client.read(&buf, length);
      client.write(handleCmd(buf));
    }
  }
}

char* handleCmd(uint8_t cmd)
{
  Serial.println(cmd);
  switch (cmd)
  {
  case '1':
    strip.setBrightness(50);
    return "Relay pin set to high\n";

  case '0':
    strip.setBrightness(0);
    return "Relay pin set to low\n";

  default:
    return "Send ASCII 1 for on, and 0 for off.\n";
  }
}

With the three lines setting up the strip commented out, the WeMos connects to my WiFi just fine. I can connect via a telnet terminal, send commands, and see the string returned from handleCmd.

If I uncomment strip.begin() then nothing will be printed via serial. Not even the first line that just says “Connecting”. It doesn’t matter where I put strip.begin() either. I’ve put it inside loop() and still nothing prints. The LEDs don’t change brightness either, so it’s as if not even setup() runs.

Adafruit_NeoPixel strip{ NUM_LEDS, LED_PIN, NEO_RGB + NEO_KHZ800 };
WiFiServer server{ port };

I know it shouldn't make any difference, but maybe try () instead of {} ?

PaulRB:
I know it shouldn't make any difference, but maybe try () instead of {} ?

The initialization syntax doesn't change the behavior. Changing the constexprs to #defines also doesn't make a difference.

Put more Serial.print() in to see if strip.begin() or WiFi.begin() is not returning or setup() is not executing.

If setup() is not executing, check you have not connected something to the gpio pins that prevents that. I think D3, D4 need to be high and D8 must be low. There are pull-up/down resistors on the wemos for that purpose but they are weak and easily overcome.

PaulRB:
If setup() is not executing, check you have not connected something to the gpio pins that prevents that. I think D3, D4 need to be high and D8 must be low. There are pull-up/down resistors on the wemos for that purpose but they are weak and easily overcome.

This must’ve been it. I never had anything physically plugged into the WeMos besides the LED strip. Unplugging the strip didn’t change anything.

But as it turned out D1 had actually been #defined as 1 somewhere before my code. Some WeMos documentation says that D1 is actually pin 5, and pin 1 is TX. Changing the value of my LED_PIN to 5 made everything work.

Well, I'm glad if I helped in some way, but I don't understand what you meant by "somewhere before my code".