• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

ws2812B drive by ESP8266 behaviour: what am I missing?

Q&A Forum › Category: ESP8266 › ws2812B drive by ESP8266 behaviour: what am I missing?
0 Vote Up Vote Down
Enzo Pontone asked 4 years ago

Hi everybody,
I’m trying to control a strip of ws2812B LEDs by MicroPython on a ESP8266 board. I followed the basic examples in this and other sites tutorials but the results I get are not consistent. I enclose a couple pictures and a short video to explain what I mean.
I initialize this way:

from machine import Pin
from neopixel import NeoPixel
from time import sleep
np = NeoPixel(Pin(4, Pin.OUT), 72, bpp=4)

bpp=4 is due to my strip having white LEDs, too.
In “BW2180B_test_1.jpg” you can see the result of this code from this site’s tutorial:

def set_color(r, g, b, w):
for i in range(72):
np[i] = (r, g, b, w)
np.write()
set_color(0, 102, 230, 128)

It’s supposed to turn all LEDs on with the color passed as RGBW argument (I inserted a 4th argument because of the white LEDs). The result is that all the LEDs are turned on with different colors in a repeating pattern: blue, yellow, white, red. If I omit the “white” component I get a repeating pattern of blue, red, green (not 4 colours as in the previous example).
More strange is a second example:

np[0] = (0, 0, 0, 128)
np[1] = (0, 0, 128, 0)
np[2] = (128, 0, 0, 0)
np[3] = (0, 128, 0, 0)
np[4] = (0, 0, 128, 0)
np[5] = (128, 0, 0, 0)
np[6] = (0, 128, 0, 0)
np[7] = (0, 0, 128, 0)
np.write()

I had to shift the argument “green” to get all green LEDs but every way I pass the arguments I can’t get all the right LEDs on: I get the first 4 green on, 1 off, 2 green on, 1 off and 1 green on as you can see in the photo named “BW2180B_test_2.jpg”. Trying to pass all the same arguments for green (0, 0, 0, 128) to contiguous different LEDs I get the pattern green, red, blue, off.
The only test giving me the expected result was the flashing of 1 green LED:

def fade_in_out(led, times, red = 0, green = 0, blue = 0, white = 0):
count = 0
while count < times:
for i in range(white):
np[led] = (red, green, blue, i)
np.write()
for i in range(white, 5, -1):
np[led] = (red, green, blue, i)
np.write()
sleep(.05)
count += 1 
all_off()
fade_in_out(0, 10, white = 128)

But if I try this passing LED 1 I get it flashing red , with LED 2 I get it flashing blue, with LED 3 I get the 5th LED flashing green in a pattern similar to the previous ones.

I tried 3 different strips (only difference the LEDs density) and got the same result.
Obviously there something i miss! Please, any hint?
Thanks in advance.

Question Tags: ws2812B MicroPython
6 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Hi.
 
I couldn’t see your pictures. To share your pictures, please share a link to google drive, imgur, dropbox or other service. Alternatively, you can send the pictures via email.
 
That behavior is very weird.
 
Did you try the exact code we have on the tutorial?
The only thing I see that is different is the initialization of the strip.
Can you initialize the strip as follows:

np = NeoPixel(Pin(4), 72, bpp=4)

 
And see if something changes?
Regards,
Sara
 

0 Vote Up Vote Down
Enzo Pontone answered 4 years ago

Hi Sara,
these are the links:
https://rg.to/file/9fe58ef676d639323a416348b715fc3c/BW2180B_test_1.jpg.html
https://rg.to/file/ecb27ee046fd2a88e623faef3f3481a2/BW2180B_test_2.jpg.html
https://rg.to/file/e31622f958f548491efa6593d19eec9b/BW2180B_test_flash.mp4.html
I included the short video with the green LED flashing (green only for the 1st LED, blue or red in the other cases).
I initialized as:

np = NeoPixel(Pin(4), 72, bpp=4)

from the start of my tries, you can see this in the first part of my post (didn’t get out as code!).
Thanks
Enzo

0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Hi.
You pasted:

np = NeoPixel(Pin(4, Pin.OUT), 72, bpp=4)

And not:

np = NeoPixel(Pin(4), 72, bpp=4)

Did you try it?
What is exactly the “name” of the LED strip you’re controlling?
Regards,
Sara
 

0 Vote Up Vote Down
Enzo Pontone answered 4 years ago

Hi Sara,
I changed as you told but the result is the same.
This code:

>>> np[0] = (0, 0, 0, 128)
>>> np.write()
>>> np[1] = (0, 0, 0, 128)
>>> np.write()
>>> np[2] = (0, 0, 0, 128)
>>> np.write()

output is:
https://rg.to/file/822d40e9f8e665af1f5ce09b8b77625b/BW2180B_test_3.jpg.html
I really can’t understand!

0 Vote Up Vote Down
Enzo Pontone answered 4 years ago

Update: trying on I just discovered that if I use 3 argument the result is always correct!
They sent me the RGB version and not the RGBW!
Thanks and apologize for my mistake.
 

0 Vote Up Vote Down
Sara Santos Staff answered 4 years ago

Hi again.
Don’t worry about that.
I’m glad you found the issue.
I’ll close this issue. If you need further help, you just need to open a new question in our forum.
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.