The IC used inside the neopixel LED is WS2811 which is a signal line 256 Gray level 3 channal Constant current LED drive IC. Eaxh IC can control 3 outputs but the maximum current per channel is limited to 18.5mA. Which is enough for driving an LED but not enough to drive a relay.
Luckily all relay modules come with a built in driver circuit which consist of an optocoupler and a transistor. And it only requires high or low signals to turn on and off the relay. So basically we are switching the LED inside the optocoupler to control the relays.
Keeping that in mind I designed a tiny PCB which contains 8 WS2811 IC. so we will get a total 24 outputs but as I mentioned earlier you can connect more of this ics if required. Then I head over to PCBway for manufacturing the PCB.
After assembling and adding the header pins it is ready for testing. The module is breadboard friendly so you can put it on a breadboard. First I added 12 leds to test the circuit. Now to add the ESP-01 module I used a DIY breadboard adapter. First I run a example sketch from the fastLED library, which seems to work perfectly. Then I replaced the LEDs with relays and modified the code for the project. It is based on fastled Library. I made some changes to it so that you can easily control the individual outputs.
#define NUM_LEDS 8
#define DATA_PIN 2
You need to mention the number of ICs and the pin number it is connected to. Everything is handled by only two functions.
out.on(n);
out.off(n);
For example to turn on an output high use out.on followed by the the output number and out.off to turn it off. As simple as that. Then I added the blynk program and uploaded it to the ESP-01 module. And we are successfully able to control all these relays using only one data pin from the microcontroller.
Or use a TPIC6B595 which is a power version of the 595 shift register. Cascadable, 8 open drain outputs, 150mA capability, output clamp voltage of 50V. About 30¢ each in quantity.