How to expand pins for WS2812B?

Hi, I need to use 8 outputs for controlling 8 stripes WS2812B, I had a plan to use PCF8574 or PCF8575 to get 8 pins for WS2812B. However I found, that standard rate for I2C is 100Kb/s ( bits per second ) where as a WS2812B communicates at 800Kb/s, even faster I2C would not work as I2C communicates in bytes. Do you have any idea how to do that? Is there any expander with 8 OUTPUT pins which you can use as signal outputs for WS2812B ?

Thanks!

Do you really need more pins or could you treat a single stripe of LEDs as 8 different regions, each with their own range of LED numbers ?

1 Like

I know about segmenting, but i want directly 8 outputs, each of 8 strips are already blend of few segments. I dont want one strip with lot of segments, it will be too long, but main problem is, that 2 of 8 strips are not WS2812B but WS2815 and 1 of 8 is WS2811.

How many LEDs do you have in total ?
Which Arduino are you using ?

1 Like

More than 1000, i am using ESP8266

As an aside, how much current can your power supply provide to drive the LEDs ?

1 Like

It is old 450W PC PSU, all strips will be bright at 50%, why are you asking for that? I am finding any OUTPUT pins expander or device to connect 8 adressable RGB strips. All of other things are solved.

As I indicated, it was an aside. I wondered whether you had taken into account the current required to drive 1000 or more addressable LEDs

Another aside. What else is connected to the ESP8266 apart from the LEDs ? It may be simpler to combine them into fewer pins rather than trying to combine the very time sensitive addressable control LEDS pins

2 Likes

Of course, power, reserve and cable thickness i take very seriously.

Only by creating one huge strip by connecting all 5 strips of WS2812B, it will be very complicated, each end of strip is very distant from start of another strip. But at some cases i can do it.

It will help for ex. an arduino nano connected by I2C and use some 8 (with reducing by the way above eventually 6) pins of nano?

It was whatever else is connected to the ESP8266 that I was suggesting possibly combining into fewer pins

1 Like

Just a few things for consideration that i'm seeing here

Re this

and this

and this

and then this...

Mate, you need to understand a few things

  1. You're status is "Newbie" You have like 4 Badges
    @UKHeliBob is a Moderator and a very experienced person WHO IS TRYING TO HELP YOU

  2. You asked a question, which means You don't know the answer

  3. So.. You're a newbie who doesn't know the answer and you're saying
    of course this and why are you asking that and everything else is solved

  4. Well you see mate, there is no "Of course" , Beginners say this all the time, and then.... We find out they missed something and then they say "Oh sorry, i must have missed that"

also we don't know what you take seriously or not, You can't just assume that we do.
Because taking a beginner seriously and assuming (after they asked a question) that they know what they are doing.. Would be kinda naive for an experienced person to do .

it should also be obvious why he is asking about the current draw.
the fact that you didn't know contributes to your Newbiness so to speak

Basically bob is helping you through your problem and brainstorming through it.
a lot of times brainstorming off to the side does get us to a solution
WHY ARE YOU IMPEDING THAT PROCESS
Just let him ask side questions and allow him to help you

If you come across abrupt people will be less likely to help you.

it's understood on this forum that people ask questions, they show patience and people will more experience contribute and help
it's also understood that you don't shoot a person down for helping

Consider that, ok
Bob is a good guy and he's trying to help you.
I would just roll with it if i was you and let him ask what he wants to ask.
Who knows.. through his questioning he may give you an idea that's even better for a solution.
LET THE PROCESS WORK

Search "ws2812 power injection" - this will have you applying power every "n" neopixels to keep the power from sagging (or burning up the "first" pix).

I once thought splitting neopixels into pins was the way, but I now address all my string on one pin, and use function calls to divide the strings logically. I feel the functions give me more flexibility than the pins.

2 Likes

I am "Newbie" somewhere next to my name, how do you know i am newbie in this field?
I am "Newbie" because I usually dont use any internet forums, i am old-school guy with old pc. I created an account because I have to create one to ask a question. I absolutely dont know anything of anyone here. :slight_smile:

Where do you see that i am deny that? I appreciate every help and moment that another person sacrifices for me.

I asked the question:

Asking if i have right power supply is not relevant in this topic, i have.

Is the idea from Bob, and I will take that idea into consideration. I am good with his advice, that use of one huge strip is much better than many smaller strips. Nothing that belittles his help i did not write.

Yes, I know about adding multiple power points to prevent a significant voltage drop. In fact, some of my WS2812B strips will have this injection. Only one thing i wanted to avoid is taking a long wire with GND and SIG to connect last led of strip no1 and first led of strip no2, and last led of strip no2 with first led of strip no3 etc...

I've been dealing with WS281x strips for several years now and i keep finding new ways to work with them. So aside from the power supply part which is a completely different matter which i am willing to go into, but not first up.

Ok eh, would you be willing to switch to an ESP32 ?
I am asking for a simple reason, On an ESP8266 there is not the possibility to transmit in parallel to more than 1 strip at a time. All libraries that i am aware of transmit a signal sequencially, first to 1 strip, then to another strip. (fastLed & adafruit both support this in a bit-bang method, and i guess if you would go for a UART method, it could be done, but it is not done for you so to speak, and only on 2 channels max). Sending 1000 pixels at 800Khz, takes (1000 * 24) / 800 ms (plus break time but at 300us max i think we can ignore that.) is 30ms, this is the edge of what can be done without it being visibly disturbing (33Hz), and that is assuming you are using a method that transmits in the background so no added computation is required . On an ESP32, if you make use of Makuna Neopixelbus there is the possibilty of sending 8 channels via I2s in parallel is supported. (apparently even 16 & 24 channels is possible) as in this example. It has WiFi so you can receive using ArtNet if you want to, and although a tad trickier, you can also add a W5500 ethernet module. I am confident that this will suit you.

There is a way to pass the data signal between strips while powering them from individual PSU's i use MAX485 transceivers, one at the end of the first strip, in driver mode, a twisted pair cable, i use UTP-cat 5 but a DMX cable would also work, still that tends to cause confusion on site, and one on the receiving end in receive mode, with a 120R resistor as a terminator. Works like a charm and like that you can even combine 12v & 5v strip within the same chain without having a long GND line which might start to function as an antenna. Hope this helps.

And remember, If you are a bit bored and looking for some stress in your life, you know... You should do something with Led-strip ! :wink:

1 Like

Switching from ESP8266 to ESP32 will be not problem, but i had plan to use that with ethernet module, so i choosed ESP8266, because i did not find any project with ESP32 with ethernet that works (but i am using ENC28J60). However, when you type:

if it is possible, its good news for me, this is actually best way.

Thank you so much for this example, in that example, the declaration of first 4 strips is exactly, what i wanted to do. So, every strip of same type i will connect into long segment (after your and meny others advices i decided it is most efficient way of driving more strips) and other types use separately. Switch to ESP32 is probably much better than any "slave" device with extra pins.

Yes that is for sure !

I have managed successfully using VSPI default pins and Ethernet_Generic.h but i think also the standard Ethernet.h works.

Keep in mind that the I2S parallel mode is rather memory wasteful. I considered using 3 ports but 4 universes for each, and it sucked up a whopping 102Kb of RAM. so in the end i decided for single channel I2S instead. With shorter strips this is of course less of an issue. I just ran out of memory with the Ethernet port using some , and the Sd-card using 50Kb, i had Udp on both WiFi and Ethernet, and in the end i had no space left for a webserver and Http Updates anymore. So if you plan to use multiple strips, try and make them the same length.
I2S converts 2 bits into 1 byte, the nibble representing either a 0 or a 1 (eg 1000 = 0 & 1110 = 1) due to the nature of the WS281x signal. the pixelbuffer is also still needed before compile, so in the end 4 universes is 680 pixels * 3 = 2040 bytes * 5 equals 10200 bytes just for the output buffer, and in parallel mode all 8 channels get allocated.
This is the ethernet example i use


//#define W5500_RST_PORT   21  // i had it connected to the RST of the ESP32 before, but it is good to pull the //RST of the W5500 LOW for 1 ms before init
//#define ETHERNET_LARGE_BUFFERS
#define W5500_CS 5 
#define SPI_FRQ 32000000 

#include <WiFi.h>
#include <WebServer.h>

#include <SPI.h>
#include <EthernetWebServer.h>
#include "Ethernet_Generic.h"
// #include <EthernetUdp.h> // not needed yet

const char* ssid     = "XXX";
const char* password = "xxxxxxxx";

EthernetWebServer ethernetServer(80);
WebServer wifiServer(80);

const int led = 2;

void handleEthernetRoot() {
  ethernetServer.send(200, "text/plain", "Hello from ESP32 Ethernet!");
}

void handleWiFiRoot() {
  wifiServer.send(200, "text/plain", "Hello from ESP32 WiFi!");
}

void setup() {
  Serial.begin(115200);
  delay(100);
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }

  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());

  SPI.setFrequency(SPI_FRQ);

  Ethernet.init (W5500_CS);
  // start the ethernet connection and the server:
  // Use DHCP dynamic IP
  byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01}; 
  //uint16_t index = millis() % NUMBER_OF_MAC;
  // Use Static IP
  //IPAddress ip(192, 168, 2, 222);
  //Ethernet.begin(mac, ip);
  Ethernet.begin(mac);

  Serial.println("Currently Used SPI pinout:");
  Serial.print("MOSI:");
  Serial.println(MOSI);
  Serial.print("MISO:");
  Serial.println(MISO);
  Serial.print("SCK:");
  Serial.println(SCK);
  Serial.print("CS/SS:");
  Serial.println(W5500_CS);

  ethernetServer.on("/", handleEthernetRoot);
  ethernetServer.begin();

  Serial.print("HTTP EthernetWebServer is @ IP : ");
  Serial.println(Ethernet.localIP());

  wifiServer.on("/", handleWiFiRoot);
  wifiServer.begin();

  Serial.print("HTTP WiFiWebServer is @ IP : ");
  Serial.println(WiFi.localIP());
}

void loop() {
  ethernetServer.handleClient();
  wifiServer.handleClient();
}

This is a working ethernet example which actually run a webserver on both ethernet & wifi, and Udp can work on both (though do need a separate object)
You can keep an eye on memory usage using something like this

void ShowFreeHeap(String msg) {
  static uint32_t Freeheap = esp_get_free_heap_size();
  Serial.println("Free memory: " + String(esp_get_free_heap_size()) + " bytes");
  Serial.println(msg + " : " + String(Freeheap - esp_get_free_heap_size()) + "bytes");
  Freeheap = esp_get_free_heap_size();

}

Amazing to think that i actually ran out on an ESP32.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.