logo elektroda
logo elektroda
X
logo elektroda

OpenBeken WS2812B driver (compatible with SM16703P, etc) - short scripting presentation

p.kaczmarek2 10653 52
ADVERTISEMENT
📢 Listen (AI):
  • #31 20970128
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14416
    Help: 650
    Rate: 12370
    MnM1 wrote:

    MnM1 wrote:

    WS2811 LED strip with a SOIC chip and 3 RGB LEDs.

    Well, @MnM1 , I can clearly see on your picture that this device has one LED controller per 3 RGB LEDs, so the LEDs are working in group of 3, that's fully expected and understandable, so please stop reporting this as potential firmware error.

    Here is a breakdown of most common WS strips:
    Image showing a comparison of LED strips WS2812, WS2811, WS2813, and WS2815.
    Your device has WS2811 LED strips, that's the strip where SOIC chip controls 3 LEDs in a group. Here is WS2811 pinout:
    Pin diagram of the WS2811 chip with pin function description.
    So everything works as expected.


    Now I think we can focus on the user interface. What kind of features would you like to have on the main panel, @MnM1 ?


    @igfotfrank ok that is now clear. I will make a better driver dedicated for such case, I will let you know once it's ready for testing.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #32 20971186
    igfotfrank
    Level 7  
    Posts: 17
    i've wrote a small script.
    Now im abel to control the RGB and White mode seperate.
    Now i want to create a virtual button to enable/disable the Light completly.

    
    startDriver SM16703P
    SM16703P_Init 60
    again:
    if  $led_enableAll<1 then goto color
    SM16703P_SetPixel all 0 0 0
    SM16703P_Start
    led_temperature $led_temperature*$led_enableAll
    led_dimmer $led_dimmer*$led_enableAll
    goto end
    color:
    SM16703P_SetPixel all 1*$led_red*$led_dimmer/255 1*$led_green*$led_dimmer/255 1*$led_blue*$led_dimmer/255
    SM16703P_Start
    end:
    delay_s 1
    goto again
    
  • #33 20971678
    MnM1
    Level 10  
    Posts: 175
    Help: 4
    Rate: 13
    OK, for me I will like to see some effects that are available in the Tuya app - Gradient mode (this one I use the most),, Jump mode, Flash Mode, Symphony Mode, Trail Mode, etc

    Also I think will be good if there is a speed slider on the main page to slow down or speed up any effects.

    This might be doable with scripting but I don't have much experience in that area...
  • #34 20971707
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14416
    Help: 650
    Rate: 12370
    Don't worry about scripting, I will make this in firmware for you guys.

    Speed slider is a good idea. I will also note down the effects.

    Okay, any futher ideas?

    @igfotfrank good job on the script, it should be good for a start until I get some dedicated drivers for your lamp
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #35 20971798
    igfotfrank
    Level 7  
    Posts: 17
    @p.kaczmarek2
    Would be good if you could take the standard variables for led red green blue, so that you could set the leds with the topic "cmnd/device_name/led_basecolor_rgb" and then get a state via mqtt in which state(rgb/white/both) the stripe is.
  • ADVERTISEMENT
  • #36 20972135
    jkwim
    Level 13  
    Posts: 186
    Help: 4
    Rate: 25
    p.kaczmarek2 wrote:
    Why do you want to use SM16703P_SetRaw for single pixel if there arleady is SM16703P_SetPixel?

    The update parameter determines whether the data is automatically sent to the LEDs. It's an option to have "SM16703P_Start" called automatically.


    I want to use the color codes in HEX.

    Added after 7 [minutes]:

    p.kaczmarek2 wrote:
    Don't worry about scripting, I will make this in firmware for you guys.

    Speed slider is a good idea. I will also note down the effects.

    Okay, any futher ideas?



    Don't know whether something closer to FastLED Library can be embedded. I mean the upper layers. FastLED runs on ordinary GPIO pins using bit banging. So that is out for OpenBK since we can only use MOSI pin.

    FastLED has lot of functions in the upper layer eg: gradient fill etc.

    And even color addition, subtraction.
  • #37 20972178
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14416
    Help: 650
    Rate: 12370
    I've did a groundwork for the driver, and by groundwork I mean I've started creating automatic self tests for LED control:
    https://github.com/openshwprojects/OpenBK7231...mmit/a61c9965ef1f163551772be62bac9f8fe3d63b01
    This will automatically test LED system to ensure that everything works as expected. This is required because it's easy to break something during development and it's hard to test every possible combination by hand.

    I will start expanding LED driver later.

    igfotfrank wrote:
    @p.kaczmarek2
    Would be good if you could take the standard variables for led red green blue, so that you could set the leds with the topic "cmnd/device_name/led_basecolor_rgb" and then get a state via mqtt in which state(rgb/white/both) the stripe is.

    This is my plan. I am going to extend old LED driver and add there an extra state for animations.


    jkwim wrote:

    Don't know whether something closer to FastLED Library can be embedded.

    I have looked at one library so far but it was in CPP (so it would require mixing, like IR did) and it required quite a lot of porting. Maybe I will decide to just create few simple effects myself first. I don't know yet. I'm open to suggestions.

    jkwim wrote:
    FastLED runs on ordinary GPIO pins using bit banging.

    I've tried that and failed. The instruction cache causes lags. It would only work with ramfunc, but we failed to get ramfunc running on BK.
    Helpful post? Buy me a coffee.
  • #38 20972834
    MnM1
    Level 10  
    Posts: 175
    Help: 4
    Rate: 13
    @p.kaczmarek2 - is this available for BK7231T as well?
  • #39 20972896
    jkwim
    Level 13  
    Posts: 186
    Help: 4
    Rate: 25
    p.kaczmarek2 wrote:
    Why do you want to use SM16703P_SetRaw for single pixel if there arleady is SM16703P_SetPixel?

    The update parameter determines whether the data is automatically sent to the LEDs. It's an option to have "SM16703P_Start" called automatically.

    I want to use the color codes in HEX.




    Also I observed that the delay caused by SM16703P_Start command can be eliminated when using RAW command.

    I created two scripts of my loop above using the different commands.

    I could observe that the SM16703P_Start loop causes the LED to be lit for longer period than when using RAW command. Both loops did not have any delay_ms statement.

    So if somebody wants to create faster patterns, it would be better to use the RAW mode.[/quote]
  • #40 20981268
    igfotfrank
    Level 7  
    Posts: 17
    How is the status of the driver
  • ADVERTISEMENT
  • #41 20981483
    jkwim
    Level 13  
    Posts: 186
    Help: 4
    Rate: 25
    igfotfrank wrote:
    How is the status of the driver


    please see my testing results in previous posts.
  • #42 21042004
    alfakenzo
    Level 9  
    Posts: 32
    Help: 1
    Rate: 3
    Hi guys, i updated my led stripe to newest firmware how can i now use the new things you wrote? How must i set the correct pin on the firmware? I cant configire still the stripe with the needed things.
  • #43 21042131
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14416
    Help: 650
    Rate: 12370
    Have you tried the script from the Class LED controller (single color only) section of the first post?
    Helpful post? Buy me a coffee.
  • #44 21066567
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14416
    Help: 650
    Rate: 12370
    I am working on LEDs again. For now, to make development quicker, I have integrated per-pixel lighting into OBK simulator, more here:
    https://www.elektroda.com/rtvforum/topic4046056.html
    Here is a sample:
    Circuit simulation with WS2812 LEDs in OpenBeken software.
    More updates coming soon!
    Helpful post? Buy me a coffee.
  • #45 21082916
    igfotfrank
    Level 7  
    Posts: 17
    Are they any new Updates for the GUI Toggeling the White/RGB Mode. In my prevoius post i have wrote my script but i don't know how to integrate it with HomeAssistant. So that i can toggle between them.
  • #46 21082923
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14416
    Help: 650
    Rate: 12370
    Yes, latest version should work without scripts. We also have a WIP version of pixel animations: https://github.com/openshwprojects/OpenBK7231T_App/pull/1205
    Helpful post? Buy me a coffee.
  • #47 21083738
    igfotfrank
    Level 7  
    Posts: 17
    Sorry but i doesn't understand. Should i set some Flags ? I can control the color but i can't toggle between RGB and Cold/Warm White Mode/ON/OFF over the WebGUI.
    Edit:
    HomeAssistant works great thanks
  • #48 21098975
    divadiow
    Level 38  
    Posts: 4859
    Help: 424
    Rate: 860
    very cool

    I'm just playing with a new device that came today that is almost the perfect thing for OBK SPI LED control

    CBU. SPI LED connector. Toggle button. Connected but vacant IR pad for DIY expansion. 12-24v barrel connector. The only issue is that it outputs 12V and was advertised as being for WS2811. Easy enough to mod though.

    Here's my device running OBK and RGB full length static script. 120 WS2128B LED strip, external PSU.

    The image shows an RGB LED strip and a controller placed on a wooden table.
  • #49 21098997
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14416
    Help: 650
    Rate: 12370
    Hey @divadiow, do you think that we can put PixelAnim in the public release? Have you checked this driver?

    @igfotfrank where do you have CW slider? Can you provide more info? WS2812B LEDs are RGB only. There is no CW.
    Helpful post? Buy me a coffee.
  • #50 21099011
    divadiow
    Level 38  
    Posts: 4859
    Help: 424
    Rate: 860
    p.kaczmarek2 wrote:
    do you think that we can put PixelAnim in the public release? Have you checked this driver?


    Not yet. Will do shortly. Only just flashed to OBK.
  • #51 21099045
    igfotfrank
    Level 7  
    Posts: 17
    On page 1. I described my stripe. It's almost the same as the first post.
    Quote:
    It has 2 Pwm pins for the white led (brightness/temperatur) and i configured one pin for the sm16703p.
    Rgb led and white leds are seperate
  • Helpful post
    #52 21099114
    divadiow
    Level 38  
    Posts: 4859
    Help: 424
    Rate: 860
    it works.

    Screenshot of the user interface for the LED lighting controller OpenBK_BK7231N_CBU_Outsmart.

    autoexec for me
    Code: Text
    Log in, to see the code






    curiously the last few LEDs are a bit static or off and each time you turn off the strip odd ones remain on

    Two LED strips on a carpet with several brightly lit bulbs of different colors. LED strip light illuminating in various colors on a carpeted floor. LED strip emitting various colors, arranged in a loop on a brown carpet.

    Added after 6 [minutes]:

    and the speed slider is reverse - left = faster. right = slower.

    :)
  • #53 21101531
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14416
    Help: 650
    Rate: 12370
    The speed is actually "interval between refreshes" so I may need to rename that...

    Anyway, let's continue in the release topic:
    https://www.elektroda.com/rtvforum/topic4057187.html
    Please report problems there. I will close the current topic now.
    Helpful post? Buy me a coffee.
📢 Listen (AI):

Topic summary

✨ The discussion focuses on the implementation and control of individually addressable LEDs, specifically WS2812B and SM16703P, using the OpenBeken (OBK) firmware. Users share their experiences with integrating these LEDs into various devices, such as smart wall switches and LED strips. Key topics include manual LED control, scripting for LED commands, and troubleshooting issues related to firmware versions and LED behavior. Users also discuss the potential for advanced animations and the need for specific configurations to toggle between RGB and white modes. The conversation highlights the importance of using the correct firmware version and the impact of power supply on LED performance.
Generated by the language model.

FAQ

TL;DR: OpenBeken can drive 60 LEDs on BK7231 using P16, and one tester confirmed support was "good to go now" after updating from build 451 to 469. This FAQ helps OpenBeken users script, debug, and integrate WS2812B, SM16703P, WS2811, DDP, and PixelAnim control on BK7231 devices. [#20968181]

Why it matters: This thread turns scattered LED-driver notes into a practical setup guide for getting addressable strips working reliably on OpenBeken hardware.

Option Control method Best use Key limitation
Manual script SM16703P_* commands in autoexec.bat Static colors, loops, dimmer logic You must write and maintain the script
DDP startDriver DDP Fast external effects from xLights or WLED Packet/buffer size limits long single-device runs
PixelAnim startDriver PixelAnim Built-in GUI animations Was still work-in-progress in May 2024
Classic LED UI hack Script maps $led_* variables to pixels Reuse OBK color picker and dimmer Single-color style control only

Key insight: OpenBeken’s WS2812B support depends more on the right pin, firmware build, and pixel protocol than on the LED brand name. Most reported “driver bugs” were actually old firmware, GRB/RGB order mismatches, or strips that group 3 LEDs per controller.

Quick Facts

  • OpenBeken’s addressable LED driver uses P16 only, because it relies on the BK7231 SPI DMA path for timing-accurate signaling rather than ordinary GPIO bit-banging. [#20966201]
  • A working basic setup shown in the thread initializes 3 LEDs and then writes pixel 0, 1, and 2 before calling SM16703P_Start. [#20966201]
  • For DDP, startDriver DDP 1024 sets a 1024-byte packet buffer, which the thread estimates at about 341 LEDs when using 3 bytes per LED. [#20968257]
  • One real-world test used a 16-LED OpenBeken DDP endpoint chained to a 180-LED WLED installation, creating a logical total of 196 LEDs with acceptable speed. [#20968181]
  • WS2811-style hardware may drive LEDs in groups of 3, so seeing three LEDs change together can be expected behavior, not a firmware fault. [#20970128]

How do I control a WS2812B or SM16703P LED strip in OpenBeken with a basic autoexec.bat script?

Use a short autoexec.bat that starts the driver, initializes the LED count, sets pixels, and then pushes the frame. 1. Add startDriver SM16703P. 2. Run SM16703P_Init 3 or your strip length. 3. Use SM16703P_SetPixel lines and finish with SM16703P_Start. The thread’s first example lights LED 0 green, LED 1 blue, and LED 2 red. The same command set works for WS2812B and SM16703P in OpenBeken. [#20966201]

What is the correct BK7231 pin for OpenBeken WS2812B control, and why does the driver only use P16 (MOSI)?

The correct pin is P16, which is the BK7231 MOSI pin. OpenBeken uses only that pin because the driver depends on SPI DMA to generate precise timings for WS2812B-like protocols. Ordinary GPIO timing was described as unreliable due to instruction-cache delays. That is why the thread repeatedly says addressable LEDs can only be connected on P16 for this driver path. [#20966201]

How can I break out or reroute P16 on CB2S or CB3S modules to use OpenBeken with addressable LEDs?

You can reroute P16 by exposing the hidden SPI pin on the module and wiring it out manually. For CB2S, the thread points to a dedicated P16 breakout method. For CB3S, a user reports that P14 can be modified for the purpose after opening the RF shield and soldering a wire. In both cases, you still need common ground, and external 5 V power can feed the LEDs while the module supplies data. [#20966561]

What is DDP in OpenBeken LED control, and how does it work with xLights or WLED?

DDP is the thread’s network-control method for sending pixel data from external software into OpenBeken. "DDP is a protocol that transports pixel data over UDP, letting another controller stream effects to the strip." In practice, you start both drivers, for example startDriver SM16703P, startDriver DDP, and SM16703P_Init 60. The thread shows it working with xLights and with WLED, including a 16-LED OBK target appended to a 180-LED WLED setup. [#20968181]

What does the SM16703P_SetRaw command do in OpenBeken, and what does the bUpdateAfterSet parameter mean?

SM16703P_SetRaw sends a raw byte stream to the LED buffer without converting values into color fields first. Its syntax is SM16703P_SetRaw bUpdateAfterSet firstByte hexData. The bUpdateAfterSet flag decides whether OpenBeken immediately transmits the prepared data to the LEDs. In plain terms, 1 makes it auto-run the equivalent of SM16703P_Start, while 0 lets you queue data first and start later. [#20968399]

Why do OpenBeken raw logs show translated SPI bytes like 0x88 and 0xEE instead of the original RGB values such as 0x00 and 0xFF?

The logs show SPI-translated transport bytes, not your original RGB payload. OpenBeken splits each source byte into 4 groups of 2 bits, then maps them through a lookup table: 0x88, 0x8E, 0xE8, 0xEE. That is why values like 0x00 and 0xFF appear in logs as repeated translated bytes instead of unchanged color bytes. The thread explains this as part of the SPI DMA timing method. [#20967350]

How do I set all pixels to one color or create an RGB repeating pattern on a full WS2812B strip in OpenBeken?

Use either a loop or the special all index. For one color, the simplest form is SM16703P_SetPixel all 0 255 0, which the thread uses for a full-strip green fill. For a repeating RGB pattern, initialize the strip length, step an index by 3, and write red, green, and blue to $CH6, $CH6+1, and $CH6+2 before SM16703P_Start. The example shown was written for 60 LEDs. [#20966201]

Why were LEDs lighting in the wrong sequence on a WS2812B strip until the firmware was updated from OpenBeken build 451 to 469?

The wrong sequence came from using an older firmware build, not from the LED protocol itself. A tester first saw LEDs 3 and 4 light together and color inconsistencies on build 451, then reported that upgrading to build 469 fixed both the sequence and color issues. The same user also confirmed the strip was GRB, which explained remaining color-order differences after the firmware update. [#20968181]

How do I handle GRB versus RGB color order when WS2812B colors look wrong in OpenBeken?

Swap the channel order in your SM16703P_SetPixel values to match the strip’s actual protocol. One tester found that a strip advertised as WS2812B was really GRB, so correct red required entering 0 0 255 in the RGB argument positions shown in the script comments. If white looks purple or colors seem shifted, treat color order as the first thing to check before blaming the driver. [#20968181]

What’s the difference between WS2812B, SM16703P, and WS2811 strips in OpenBeken, especially when one controller drives groups of 3 LEDs instead of individual pixels?

WS2812B and SM16703P can work with the same OpenBeken command set here, but WS2811 hardware may control LEDs in fixed groups instead of per-pixel. "WS2811 is a LED-driver category that controls external RGB sections, often with one controller chip driving 3 LEDs as one logical pixel." That is why one user saw 3 reds, 3 greens, and 3 blues in a test; the hardware grouped them by design, and the thread says this was expected. [#20970128]

How can I use the classic OpenBeken single-color LED web UI and dimmer to control an addressable strip through a script?

Enable the legacy LED-control flag, then map $led_* variables to every pixel in a loop. The thread’s example initializes 60 LEDs, repeatedly writes all pixels from $led_enableAll, $led_red, $led_green, $led_blue, and $led_dimmer, then calls SM16703P_Start every 1 second. This lets the normal OBK color picker and dimmer work, although the author notes the CW controls do not apply in that script path. [#20966201]

What is PixelAnim in OpenBeken, and how is it different from manual scripting or DDP-based LED effects?

PixelAnim is OpenBeken’s built-in pixel animation driver, intended to reduce or replace custom scripts for common effects. Manual scripting gives direct control through autoexec.bat, while DDP streams frames from external tools like xLights or WLED. PixelAnim sits between those approaches: local animations with a GUI, but less external dependency than DDP. A public test showed it working with startDriver SM16703P, SM16703P_Init 120, and startDriver PixelAnim, though some LEDs at the end still behaved oddly in that early build. [#21099114]

How do I integrate an OpenBeken RGBIC plus tunable white strip with Home Assistant so I can switch between RGB mode and cold/warm white mode?

Use the newer OpenBeken version rather than relying only on custom scripts. The thread shows a user first scripting separate RGB and white behavior for a strip with 2 PWM pins for white and one SM16703P data path, then later reporting that Home Assistant works great with the latest version. That means HA integration succeeded there, while the Web GUI mode toggle was still confusing. For this hardware, OpenBeken’s updated driver path was the practical answer. [#21083738]

What is the maximum practical LED count for OpenBeken DDP control, and how does the DDP buffer size like startDriver DDP 1024 affect strip length?

A 1024-byte DDP buffer supports about 341 LEDs when each pixel uses 3 bytes. The thread explicitly does the math as 1024/3=341 and treats that as plenty because WLED or other controllers can cascade effects across multiple OBK devices. That makes the practical ceiling depend on your packet size and topology, not only on one strip. Long decorative layouts can therefore be split across devices instead of forcing one huge DDP endpoint. [#20968297]

How does WS2812B support work on BK7231T compared with BK7231N in OpenBeken?

The thread does not describe a separate scripting model for BK7231T versus BK7231N, and the same OpenBeken LED work is presented as a shared driver feature. The opening post links both BK7231T and BK7231N under the same OBK project and explains WS2812B support through the common SM16703P-based driver flow. A later user explicitly asked whether this was available on BK7231T as well, which indicates the feature was being treated as part of the same platform family rather than a different API. [#20966201]
Generated by the language model.
ADVERTISEMENT