Neopixel "flicker"/noise only when Wifi is on
Port, board and/or hardware
esp32-C3 Mini
Matrix board like this https://www.hobbyelectronica.nl/wp-content/uploads/2021/11/8x8_WS2812_Led_matrix.jpg
with WS2812b Neopixels, all individual Neopixels have decoupling capacitors.
MicroPython version
MicroPython v1.24.1 on 2024-11-29; ESP32C3 module with ESP32C3
Reproduction
When Wifi is enabled and connected, a neopixel matrix (8x8) gives unexpected glitches.
Power and signal levels are checked and ok. (checked with an oscilloscope.)
This bug is the same as in https://github.com/micropython/micropython/issues/8161 however the fix will not work because the esp32-C3 Mini has only one core.
If this bug cannot be solved, I suggest adding a warning in the documentation that Neopixels on eps32 (single core types) cannot be used reliable when Wifi is on and used.
import time
from neopixel import NeoPixel # Standard lib of MicroPython v1.24.1
from machine import Pin
import config as cfg
import network
wlan = network.WLAN(network.STA_IF)
wlan.active(False)
ap_if = network.WLAN(network.AP_IF)
ap_if.active(False)
if not wlan.active():
wlan.active(True)
time.sleep_ms(100)
if not wlan.isconnected():
wlan.connect(cfg.ssid, cfg.passwd)
while not wlan.isconnected():
time.sleep_ms(100)
print('.', end='')
np = NeoPixel(Pin(4, Pin.OUT), 32) # Use 4 rows of 8 pixels
np.fill((0,0,0)) # All pixels off
np.write()
np[0] = np[8] = (1,0,0) # Red, lowest intensity
np[16] = np[24] = (0,1,0) # Green, lowest intensity
while True:
np.write()
time.sleep_ms(20)
The configuration of the pixels of this board is as follows:
0 1 . . . . . 6 7
8 9 . . . . . . .
16 etc.
So the example program above should give
R . . . . . . .
R . . . . . . .
G . . . . . . .
G . . . . . . .
Expected behaviour
First column (0) should be as above and steady
Observed behaviour
Only when Wifi is on and connected, glitches appear like for example:
R . . . . . . .
R . R . . . . .
G . G . . . . .
G . . . . . . .
or
R . . . . . . .
R . . . . . . .
G . G . . . . .
G . G . . . . .
The glitches always appear in column 2 (two pixels away from the first column)
and has the same color as the left one. I have not seen glitches in top row (0)
Additional Information
Conditions:
- Power supply (both 5 and 3.3Volt) has 100nF ceramic parallel with 470uF capacitors.
- Input signal of matrix module is within datasheet specs and look clean (Checked with oscilloscope).
- No long wires.
- No high currents (average current of the setup is below 50mA)
I checked the (total) time of the pulsetrain on the output of the esp with a oscilloscope, it shows 32 * 24 * 1.25uS = 960uS
This is as expected. However sometimes the pulsetrain is extended an extra 60uS.
This is probably when the glitches appear.
I also did the test with all 64 pixels (total time of pulstrain 1.92mS, column 0 -> RRRRGGGG) then also sometimes the extra 60 uS appear. Also parts of (bottom of) column 0 is copied to column 2 like above.
I have tested this with a few esp32-C3 and a few matrix boards. They all have the same behaviour.
I also tried using machine.bitstream but the same behavior shows up.
Code of Conduct
Yes, I agree
RMT + Neopixel + WiFi = Flickering
This is related to #8158 + #7985.
I am experiencing neopixel "flicker"/noise only when Wifi is on.
Some background on my setup (same as what I described in #7985):
- a 16x16 RGB panel (256 LEDs)
- connected directly to my LOLIN D32 Pro board on GND, USB (+5V), 25
- I'm using the firmware that @jimno built and shared in #7985
- no capacitors or level shifters (maybe this would help, but this setup seems to work fine in FastLED, so I'm doubtful)
- I've powered it both through USB on my computer, and by unplugging the USB connection and putting +5V over the panel's connection, which feeds back into the "USB" pin as +5V
- works fine with FastLED from what I can tell
- the current amount of flickering (which is signalled with RMT, on this firmware, I assume), is much less than what I experienced in #7985
- it seems to happen only in the "later" part of the panel—I haven't seen any flickering in the first 4 or 5 rows of 16 pixels
- I've tried this on different ESP32 boards (a second LOLIN D32 Pro, and a different WROOM board); same results
- I tried a different LED panel that appears to be the same hardware, and the same problem
- I've taken a short video. It's a bit hard to see, but definitely visible. The 0 pixel is on the right and the 255 pixel is on the left.
Here's the code I'm using (with various timings; all similarly flickery, but only with wifi turned on and connected to a local WLAN in boot.py):
import machine
import neopixel
np = neopixel.NeoPixel(
machine.Pin(CONFIG["DATA_PIN"]),
CONFIG["NUM_PINS"],
# timing=(350, 800, 800, 350), # , timing=(400, 850, 800, 450)
)
while True:
print("doing a round.")
for p in range(CONFIG["NUM_PINS"]):
np.fill((0, 0, 0))
np[p] = (64, 0, 0)
np.write()
in #7985, @odi6331 suggested:
I changed them on my setup to a timing=(350,800,800,350) and all the flickering was gone since then.
I tried this timing on my setup, and it worked fine with wifi off, but when I turned it on, the flickering came back.