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