So as part of a bigger project im building Wifi Led Controllers using ESP8266-12 (not something like the node mcu just the esp), and im running into a problem where the Neopixels seem to flicker Randomly.
Some details:
-
I'm controlling an (unadressable) 12V Led strip and the Neopixels in my Case fan (which are WS2812B's) with one Esp.
-
The Esp sits on a developing/programming board (see picture) and is powered by the usb from my pc.
-
I used 3 150 ohm resistors for the data line because i dont have any other suitable resistors at the time.
-
The flickering seems to occur more often when i set the 12V strip to a dark brightness with 2 colors
(aka like a dark purple or a dark yellow)
When i set them to full brightness Red, Green, Blue or off, the Flickering is gone. -
When i comment out the code for the 12V Strip there also is no flickering.
-
Everything exept the 12V is powered from my Pc.
-
It doesnt seem to matter if i use the logic level shifter or not, and if i use the resistors or not the problem stays the same.
-
After some time the Esp doesnt respond or looses connection and needs to be reset.
I've read that using PWM and the Neopixels at the same time on a esp can cause errors due to the strict timing of the pixels, but as far as i know the Adafruit NeoPixel Libary, which im using, disables interupts when pushing data to the Led's.
A Video displaying the problem:
My Code:
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include <Adafruit_NeoPixel.h>
Adafruit_NeoPixel pixels(20, 2, NEO_GRB + NEO_KHZ800);
WiFiClient wifiClient;
PubSubClient client(wifiClient);
byte r;
byte g;
byte b;
byte r2;
byte g2;
byte b2;
byte modus = 1;
byte circle = 0;
byte lastR, lastG, lastB = 0;
byte lastR2, lastG2, lastB2 = 0;
void callback(char* topic, byte* payload, unsigned int length) {
r = payload[0];
g = payload[1];
b = payload[2];
r2 = payload[3];
g2 = payload[4];
b2 = payload[5];
modus = payload[6];
}
void loadingCircle(byte red, byte green, byte blue) {
noInterrupts();
pixels.clear();
for(int i = 0; i <= 20; ++i) {
pixels.setPixelColor((i + circle) % 20, pixels.Color(red / 20 * i, green / 20 * i, blue / 20 * i));
}
++circle;
if(circle > 40) {
circle = 0;
}
pixels.show();
interrupts();
delay(50);
}
void oneColor(byte red, byte green, byte blue) {
if(red != lastR2 && green != lastG2 && blue != lastB2) {
pixels.clear();
for(int i = 0; i <= 20; ++i) {
pixels.setPixelColor(i, pixels.Color(red, green, blue));
}
lastR2 = red;
lastG2 = green;
lastB2 = blue;
pixels.show();
}
}
void stripOutput(byte red, byte green, byte blue) {
if(red != lastR && green != lastG && blue != lastB) {
analogWrite(4, red);
analogWrite(5, green);
analogWrite(14, blue);
lastR = red;
lastG = green;
lastB = blue;
}
}
void setup() {
analogWriteFreq(100);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(14, OUTPUT);
pixels.begin();
WiFi.begin("Psalm_31.5", "GANZgeHeimer!");
while (WiFi.status() != WL_CONNECTED) {
pixels.clear();
loadingCircle(240, 240, 240);
stripOutput(6 * circle, 6 * circle, 6 * circle);
pixels.show();
}
client.setServer("192.168.178.49",1883);
client.setCallback(callback);
while(!client.connect("esp1", "pc", "ledEnvironment")) {
pixels.clear();
loadingCircle(240, 40, 0);
stripOutput(6 * circle, circle, 0);
pixels.show();
}
for(int i = 0; i <= 20; ++i) {
pixels.setPixelColor((i + circle + 1) % 20, pixels.Color(0, 255, 0));
pixels.show();
stripOutput(0, i * 12, 0);
delay(30);
}
client.subscribe("led/pc");
delay(970);
pixels.clear();
stripOutput(0, 0, 0);
oneColor(0, 0, 0);
pixels.show();
delay(50);
pixels.clear();
stripOutput(0, 255, 0);
oneColor(0, 255, 0);
pixels.show();
delay(100);
pixels.clear();
stripOutput(0, 0, 0);
oneColor(0, 0, 0);
pixels.show();
delay(50);
pixels.clear();
stripOutput(0, 255, 0);
oneColor(0, 255, 0);
pixels.show();
delay(100);
pixels.clear();
oneColor(0, 0, 0);
stripOutput(0, 0, 0);
pixels.show();
}
void loop() {
switch(modus){
case 1:
oneColor(r2, g2, b2);
stripOutput(r, g, b);
break;
case 2:
loadingCircle(r2, g2, b2);
stripOutput(r, g, b);
break;
}
client.loop();
}
My Circuit:
The Programming/Developing board:
The logic level shifters:
Further Details:
The Esp gets the Color data from a MQTT-Broker on a raspberry pi 0 w. There i have a node red Ui to control the colors.
Anyway does somebody have any idea what could be causing this? Or are there any workarounds? (Preferrably software
)
I have been searching the web but cant find any solutions.


