Wifi esp8266 error when use adafruit_neopixel

Hi everybody. I have a question.
I use AP wifi on esp8266 and adafruit_neopixel to control 300 ws2812 leds with high frequency. after each show() function I use delay(1). Unfortunately, the system ran 15s then the wifi died. But i use delay(10) after show(),it works ok.

This is my code:

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

#define PIN        D5
#define NUMPIXELS 300
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

#define APSSID "TestWIFI"
#define APPSK  "12345678"

/* Set these to your desired credentials. */
const char *ssid = APSSID;
const char *password = APPSK;

void setup() {
  WiFi.softAP(ssid, password);
  pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
}

void loop() {
  pixels.clear(); // Set all pixel colors to 'off'
  for(int i=0; i<NUMPIXELS; i++) { // For each pixel...
    pixels.setPixelColor(i, pixels.Color(0, 150, 0));
    pixels.show();   // Send the updated pixel colors to the hardware.
    delay(1); // Pause before next pass through loop
  }
}

Do you think it might help if you posted your full program ?

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination

I'm sorry. I added the code to the post

Thanks

It is a common issue on an ESP. WiFi needs interrupts enabled to work properly and show() disables them for the time the signal is sent. WiFi is not compatible with a 'bit-banged' LED signal. You should switch to a library that support DMA mode on an ESP, like Makuna NeopixelBus or even FastLED. There will be restrictions on which output pin to use, but your wifi will work correctly again.

thanks deva,
Your idea is very good. but i will use i2s pin to play audio in future. Do you have any other ideas?

I don't see the relevance.

As I know, both fastled dma and sound i2s use pin 3

Ah yes, in that case you should use UART mode for the LEDs, which can be on either TX-pin GPIO1 or GPIO2. Pretty sure both Neopixelbus & Fastled have that as an option.

yes, can you share me the link to integrate UART mode with Fastled???

For FastLED i don't have it, maybe google can provide you (pretty sure it does exist using GPIO2, but i can't find it now)
For NeoPixelBus the details are described in the comments here Also it will use GPIO2

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.