kitesurfer1404 / WS2812FX

WS2812 FX Library for Arduino and ESP8266
MIT License
1.58k stars 343 forks source link

Random blinking on ESP-01 #332

Closed GH0st3rs closed 1 year ago

GH0st3rs commented 1 year ago

Hi. I uploaded it to ESP-01 and noticed a blinking while it should be static. A had attached DSO-TC2 то GPIO2 directly and as you can see the logic level is unstable.

photo_2023-03-27_23-48-00

The frequency of brightness blinks coincides with the appearance of such high-level flashes. Is it possible that this is a software bug inside the library or components?

moose4lord commented 1 year ago

Are you referring to the LED on the ESP-01? That LED is wired to GPIO2, so it will blink whenever GPIO2 is toggled. GPIO2 is toggled when programming the ESP-01 with your UART interface, and is also briefly pulled high when the ESP-01 is booted, so that may be what you're seeing. What sketch are you running?

GH0st3rs commented 1 year ago

I'm using default sketch example "webserver" . And this effect when esp disconnected from uart

moose4lord commented 1 year ago

Do you mean the esp8266_webinterface example sketch?

GH0st3rs commented 1 year ago

Exactly

moose4lord commented 1 year ago

On an ESP-01 the onboard LED wired to GPIO2 will flash at regular intervals depending on the ws2812fx.setSpeed(1000); setting. This is normal. Even when the mode is set to FX_MODE_STATIC, the library continues to refresh the WS2812 LEDs periodically. If you use the web interface to change the "speed" parameter, you'll see the the onboard LED flash rate change as well.

moose4lord commented 1 year ago

I should mention that the ESP-01 comes in two varieties. The ESP-01 and the ESP-01S. The ESP-01S has the onboard blue LED wired to GPIO2, but the older ESP-01 does not. So it looks like you have an ESP-01S.

GH0st3rs commented 1 year ago

But how It will affect to the signal level? As you can see the screenshot there is 3 high level signal package and 1 with medium level. All of those 4 packages contain the same code: Constant color for all LEDs. The difference only that we have a random signal level here

GH0st3rs commented 1 year ago

I should mention that the ESP-01 comes in two varieties. The ESP-01 and the ESP-01S. The ESP-01S has the onboard blue LED wired to GPIO2, but the older ESP-01 does not. So it looks like you have an ESP-01S.

This is correct. But what the reason as different signal level for random packages?

moose4lord commented 1 year ago

I think you're undersampling the waveform on your oscilloscope. 500ms/div is way too slow to capture the true waveform. It takes 30us to update one WS2812 led, so if you have 30 LEDs, the entire waveform is only 900us long, so you'll need to crank the sample rate to at least 1ms/div to see that.

GH0st3rs commented 1 year ago

There is 600 LED. photo_2023-03-30_00-19-19 photo_2023-03-30_00-19-21 photo_2023-03-30_00-19-22 photo_2023-03-30_00-19-23 photo_2023-03-30_00-19-24

moose4lord commented 1 year ago

Hmmmm...I'm not sure what you're trying to show me. Driving 600 LEDs takes about 18ms (600 x 30us), which is what seems to be shown in your first photo, so that makes sense. But that represents 14400 individual pulses (600 x 3 colors x 8 bits per color), which is impossible for your oscilloscope to display at the time scales you've shown. You'll need to crank up the oscilloscope's time scale if you want to capture the waveform with good fidelity. I think your DSO-TC2 can do 10us/div, which should give you a good picture of the waveform.

As an aside, do you have a resistor between the ESP-01 GPIO2 and the first WS2812 Din pin? It can really help dampen under/over shoot noise and make the waveform look much better. I use a 100 ohm resistor.

mindforger commented 1 year ago

from the datasheet of the scope

Analog Bandwidth: 0-200 kHz

way too low for the actual data to be measureable you need at least 800khz

moose4lord commented 1 year ago

Yikes! You're right @mindforger. I missed that in the datasheet.

mindforger commented 1 year ago

i know this runs well off topic but if you know a good and cheap 1Mhz (or bettter) Osc, i am searchign for years now XD nothin below 250 €/$ that is somewhat usefull

mindforger commented 1 year ago

back to topic, can you describe the blinking you experience? is it ony a specific number of LEDs (a) or a sort of brightness difference on each (b) update

a) can be signal problem in general see comment von @moose4lord

As an aside, do you have a resistor between the ESP-01 GPIO2 and the first WS2812 Din pin? It can really help dampen under/over shoot noise and make the waveform look much better. I use a 100 ohm resistor.

b) check if your number of LEDs is correct, try 599 leds in your config and make sure the last led stays dark or whatever color it had previous

GH0st3rs commented 1 year ago

Hi, yes I have 220Ohm resistor. About the blinking, this is a random, for example for the static color I can notice the brightness blinking. Then I use any effects that can change the color it became a random led blinking a random color. The count of LEDs does not solve the problem. So I can use only one effect "random noise" then those blinking looks perfect, otherwise it's annoying.

I also tested it with Arduino nano + Fastled, and I do not noticed any blinking. That's why I'm asking is any reason in the code?

mindforger commented 1 year ago

did you make sure your last led stays dark/unchanged when you reduce the number of leds?

the issue is, for some reason unknown reason, the leds turn darker when you send more data than leds are present ... i don't know if there is some sort of reflection going on or whatever

and that darkening is also delayed, so every update makes them flash brighter for a brief moment

GH0st3rs commented 1 year ago

Yes I'm pretty sure about led count. But maybe there is any thing else that I can to check this days?

mindforger commented 1 year ago

you can adda significant delay between updates and see if that fixes the issue ... there was an issue in the past where the espressif chip would cause interruptions during an update if you do not yield enough between updates

moose4lord commented 1 year ago

i know this runs well off topic but if you know a good and cheap 1Mhz (or bettter) Osc, i am searchign for years now XD nothin below 250 €/$ that is somewhat usefull

I have an Owon HDS272S (Amazon link). I don't use it very often, but it's a nice oscilloscope, although not cheap. Owon makes a cheaper one without the signal generator, if that's not something you need.

moose4lord commented 1 year ago

Sorry, I misunderstood the problem. I thought it was the ESP-01's onboard LED that was "blinking" strangely, not the actual WS2812 LEDs. I do not notice any WS2812 blinking in any of my ESP installations. Although my largest installation has only 300 LEDs, so I have no experience with 600 LEDs.

The only thing I can think of is it's some kind of power distribution problem. A strip of 600 LEDs would have a considerable voltage drop from one end to the other, unless you're injecting power at intermediate locations along the length of the strip. Although I would expect FastLED to show the same blinking issue if that were the case. Still it may be wise to check the 5V voltage on the far end of the LED strip.

Are you using a 3.3V-to-5V level shifter between the ESP-01 and the WS2812s?

GH0st3rs commented 1 year ago

Yes I have a level shifter, but it doesn't mater, because the same effect with or without it. I recorded a video how it look.

In the example I used "Twinkle" pattern, and it turned on a random colors for random leds while in update process. https://user-images.githubusercontent.com/20622766/229296469-9114499c-dfa7-4e7f-9f12-56a646d87c95.MOV

moose4lord commented 1 year ago

Wow, that's so odd. Thanks for the video, that shows the issue pretty clearly. I'm still not sure what the problem could be. I have my ESP-01S connected to 64 WS2812Bs and I don't see any strange blinking. If I set the led count to 600 with #define LED_COUNT 600 to trick it into thinking it's driving 600 LEDs, I still don't see a problem. You've tried setting LED_COUNT to something small, like 30, and you still see the issue, right?

I can only guess that there's some noise being injected into your system somehow. Double check that your ESP-01, level shifter and WS2812s are sharing a common ground. And have a pretty beefy decoupling capacitor (a few hundred micro farads) across the +5V and GND connections of the LED strip. What kind of power supply and level shifter are you using?

GH0st3rs commented 1 year ago

@moose4lord Can you share your сonnection scheme? I just want to double check that's everything is ok.

I have my ESP-01S connected to 64 WS2812Bs

moose4lord commented 1 year ago

This is what my circuit looks like: Screen shot

GH0st3rs commented 1 year ago

Ok, I think it's not a coding problem. I was trying to use different circuits with IRFZ44N as level shifter and without it, and I noticed that time to time it has some interference's. Also I met the problem that time-to-time the ESP may reboot or crashed while it connected to wifi, as I understand it something wrong with arduino wifi core for ESP because it based on an oldest ESP API.

I'm Attaching the my circuit that works not bad with minimal random blinking. I know that it looks strange and it looks like P-chanel mosfet. But In my point of view the 74hct125N level-shifter DIP-14 too large for this project. I also tried to implement i2c-version of level shifter like bs138. Screenshot from 2023-04-19 14-08-48

I also found this project will try to implement it https://www.instructables.com/How-to-Controls-WS2812B-Using-ESP-01-Arduino-ESP82/

moose4lord commented 1 year ago

Your MOSFET circuit looks a little unconventional to me. Shouldn't there by a pull down resistor on the source?

I never had good luck creating a level shifter with discrete components. I tried using a BJT once and it was a nightmare to get the bias and drive currents right. I think it's definitely worth a few cents to buy a non-inverting buffer to drive the WS2812s. If you're concerned about size, try a dual gate driver like a 74HCT2G34. It will save you a lot of headache.