
Hello, I will present here the SM2135 I2C RGBCW bulb configuration for OpenBeken. I will also provide some technical details about how the SM2135 I2C RGBCW protocol works. The bulb described here has WBLC5 module (BK7231T) and the SM2135Eh constant current LED controller.
Purchase of WOJ14415
I bought this lamp on the Polish auction portal as a result of a request from one of my users OpenBeken - I was asked to add support for the SM2135 chip.
I found the product by searching for "GU10 5W RGB LED SPECTRUM SMART WIFI TUYA bulb", besides the title of the offer, there is also its manufacturer code - WOJ14415.

I bought it along with other smart lamps, so I had free shipping.



The product arrived in a box like this:







NOTE- the product is branded on the "spectrum", but it is compatible with the Tuya application!
Teardown of WOJ14415
It is quite easy to remove the plastic transparent cover. Then you can see that SM2135 is inside:



I struggled a bit with the removal of the LED PCB. It was hard. Eventually I made a small hole on the other side and pushed it out.


The board pins are marked. You can see here, among others, CLK, which is the clock from I2C. The unsigned pin next to it is probably DATA, I2C data line. In addition, among others it is 3.3V (LED controller power supply), 20V (LED power supply?), ground...
The LEDs are separate warm, cold and colorful (RGB).
The rest of the system with the WiFi module:



On the board, rather the usual, a fuse resistor (FR1, Fusible Resistor), some 8HMP step down converter (with a 4R7 choke or 4.7uH), probably to power the WiFi module ...
These 8HMP could be TP6841S6:

What's under the sticker? Module with BK7231T:


WBLC5. Dimensions:


Base pinout:


Unfortunately, the programming pins are not described. Fortunately, I have completed the graphics for you:

You will need to solder wires to at least TX1 and RX1.
Rest of the circuit is very usual. Fusible resistor, bridge rectifier, some other elements in SMD, most likely realized to step down power supply that converts mains to 5V or 3V or a similiar voltage (anyone can recognize the markings?):



I have not analyzed the PCB with power supply more deeply, it's time to focus on the SM2135.
Five-channel I2C LED SM2135 controller
The SM2135 controller is used to operate RGBCW lamps, i.e. it supports 5 separate channels. It is controlled via the I2C lines, two signals: DAT and CLK, are sufficient to control 5 channels. In addition, it also requires power. 5 channels + 2 lines + power supply already gives us 8 pins, so the clever manufacturer gave the ground pad on the bottom of the chip:

SM2135 works on rectified mains voltage. No additional power supply is needed for it. An exemplary SM2135 application is presented below:

I must note that I suspect the signature "AC-> DC" on the step down converter powering the microcontroller (WiFi / Bluetooth module) is wrong, because there is already DC at the input. Aside from that, everything is correct, although sometimes there is no separate LDO regulator between the step down and the MCU module, as long as the converter gives a stable 3.3V for ESP or Beken chips (or other, less frequently used).

I2C Communication Diagram:

Here is its description from the datasheet, it should be mostly correct, except the "8byte + 1ack", it should be 8 bits and one ack. Ack signal is generated every 8 bits.

The start of the transmission is indicated by the DATA transition from high to low when CLK is high.
The end of the transmission is indicated by the DATA transition from low to high when CLK is high.
When sending data, the DAT state should change when the clock is low.
After 9 clock cycles, the system generates the ACK by itself, i.e. it sets the DATA pin to the low state.
Data is sent by specifying a byte of the register address and subsequent bytes of the content (you can specify several of them).
When it comes to registers, we have:
- current limit (1 byte) - address 0xC0
- RGB or CW mode (1 byte) - address 0xC1
- color data (5 bytes, RGBCW) - address 0xC2 etc.

Current Limit Values:

Color values and mode selection:

After sending the data (you can send different amounts of bytes, the pointer to the target address increases by itself), you should also generate a stop signal.
Here is the entire message:

I know all this may not seem very intuitive, so let's look at a practical example:
Code: C / C++
An attentive reader will see some inaccuracy here ... RGB mode but 5 colors? In practice, this is how it works that in RGB mode you can set all 5 outputs and additionally control the shades of white (cold and warm) in this way. The order of bytes from the table is changed because the LEDs were connected on this board.
In my case, it was enough to handle all modes. I have not implemented any other methods.
The question of I2C itself remains. You can use hardware, but you can also do it in software via simple digitalWrite and digitalRead, i.e. changing the states of digital pins in the Arduino style.
This is exactly the implementation of popular software for ESP (based on Arduino) and I used this approach.
(EDIT: by "popular software" I mean Tasmota, Esphome, etc, I am not referring here to Arduino Software I2C Library)
Code: C / C++
The first question from the reader should appear here - why "SetHigh" sets ... the INPUT mode? Why not just digital output with High value?
This is because the device should be able to generate a response, the famous ACK, that is, "overwrite" the high state set by the pull up resistor (programmable) on the input pin.
You can imagine it like a button operation, when we have a button on the input pin (between it and ground), we set the programmed pull-up and the default is state 1, but if someone presses the button, it's state 0.
Code: C / C++
Here is the procedure for writing one byte. This weird bit shift loop just iterates through the bits of a byte and then checks to see if that bit is lit in the byte we want to send.
Then the ACK bit is received, according to what I wrote earlier, the DAT pin is set to high mode but through the input pullup (and not the output state 1), so you can read the response from the system through ReadDigitalInput. This is a simple check to see if the communication has been successful.
It was a fairly simplified description, but I think that's enough. We already know how to set the colors in the lamps on the SM2135 and by the way we also learned a bit about the I2C itself .
By the way, I do not see the option of selecting the device address here (i.e. it is not possible to connect many SM2135 on one bus), but probably the manufacturer did not plan it at all ...
Full communication implementation code which I modeled on (based on digitalWrite etc):
https://github.com/arendst/Tasmota/blob/devel...tasmota/tasmota_xlgt_light/xlgt_04_sm2135.ino
Quick test with the Tuya application
The Tuya application has been discussed many times, so I won't comment it here much.
I entered the pairing mode by repowering the lamp five times. Bluetooth had to be enabled on the phone. Pairing required my WiFi data to connect the lamp to the internet. Pairing went smoothly.













SM2135 at OpenBeken
This section is for all OBK users. First, do OpenBeken flashing as described, for example, here:
Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming
I performed the RESET by cutting off the power supply. In order not to overload the USB port with the current consumed by the capacitors, I used external power supply. Of course, connected via external 3.3V LDO to get stable 3.3V for WiFi module.
In OpenBeken WWW panel, after doing the standard configuration, select the SM2135 I2C pins:

That's basically it. From now on, you can control the lamp from Home Assistant:
Code: YAML
(the YAML configuration does not differ from the RGBCW lamp configuration based on five PWM channels on the BK7231T)
You can also control it from the OpenBeken level, but it still requires selecting one flag in Options-> General, because without PWM pins, the system itself will not detect that it is RGBCW:

From this moment on, you get full control on OBK WWW panel:

The brightness level option is always active, but the "white temperature" and "RGB color" modes are self-exclusive. Only one can be used at time. Just like in Home Assistant.
Order of channels in OpenBeken
The order of RGB channels is not standardized. I found out about it thanks to the help of testers of my firmware. Therefore, the following command has been added to OpenBeken:
SM2135_Map 0 1 2 3 4
This command sequentially maps RGBCW channels (five channels) to SM2135 channel indexes.
The device does not remember the mapping by itself, the command should be added to "short startup command" from Options or "autoexec.bat" from LittleFS in the new javascript panel.
Compatible with Tasmota Device Groups
OpenBeken is compatible with Tasmota Device Groups, which allow you to synchronize the work of many devices at the same time, as well as control a large number of devices without the use of Home Assistant. More details coming soon.
Summary
So SM2135 is fully functional with OpenBeken now. Thanks to good documentation as well availability of ready-made drivers there was no problem with that. Simple operations on the IO pins are available on any platform, so you only need to port the code. It is true that in the case of my OpenBeken the control is implemented a bit differently than in other systems (at the moment everything goes through RGB mode, all 5 colors), but at the moment I did not experience any problems with it.
I would also like to thank user @rawilson for telling me to check this light. The adventure was interesting and OpenBeken got another driver.
I attach the datasheet of the SM2135 chip.
Cool? Ranking DIY Helpful post? Buy me a coffee.