adafruit / Adafruit_NeoPixel

Arduino library for controlling single-wire LED pixels (NeoPixel, WS2812, etc.)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wifi esp8266 error when use adafruit_neopixel

luckystar360 opened this issue · comments

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
  }
}

you can try calling yield() but yeah ESP8266 does not like to share WiFi with uninterrupted neopixels