
Hello all, it's time to flash another BK7231N device with my Tasmota clone and pair it with my Home Assistant.
This time it will be a smart LED bulb by Tuya, offering a wide range of colors, RGB and cold and warm white. 12W, E27. I will start with a teardown, then I will show how to hook up USB to UART programmer and finally I will also check its power consumption in standby mode and during operation. For more information related to the used firmware itself, see the main OpenBK7231T topic - OpenBK7231T . Will it really be 12W? Let's check.
IMPORTANT UPDATE
Please scroll down to post #5 in order to see new configuration details with Home Assistant. Now everything is supported, RGB mode, CW mode, dimming.
Purchase of bulbs
I found the bulb under the keyword "Tuya Wifi Smart Life Light Bulb Lamp E27 LED RGBCW Dimmable For Alexa / Google 18W", but I chose the 12W version. I paid about 10$.

RGBCW here means Red Green Blue Cool Warm, i.e. the available colors - red, green, blue, cold (white), warm (white).
This 'light bulb' requires only access to our home WiFi and Tuya application - you do not need any hub or gate.


In addition to the entire range of colors, the bulb offers Tuya automations (timers, scenarios, etc.) and various colorful animations, also following the rhythm of the music.

Naturally, we also have control over its brightness:

Test with the manufacturer's application
First, I tested the bulb with the Tuya application, without changing the firmware.
Pairing is very easy. My iPhone detected the new device immediately, the light was blinking in pairing mode after first connected:






No problems. This is what the color and brightness controls look like:







The colors are expressive and bright. But you know, the Tuya application and its cloud do not interest us so much, so it's time to peek inside ...
The interior of the bulb
Getting inside turned out to be very easy. I just managed to remove the plastic, milky dome with my bare hands, making a slight twisting motion.


Let's see when which LEDs are lit:





The glue can be removed easily with a knife. It is enough to lift the PCB with LEDs. It is not bolted to the rest of the bulb base. I hope it won't heat up excessively, but it's only supposed to be 12W.



The WiFi module inside is based on the BK7231N:



It's time to get the whole module out. If we just want to program the BK7231N it may not be necessary if we can fit the soldering iron to its RX / TX pads. In any case, only one power cord is soldered, the other is only hooked onto the thread:


Let's look at the electronics from inside:





At the input we have a fuse resistor (RF1 - Resistor Fusible 1?), A full bridge rectifierMB6S, then there are places for additional capacitors and a choke (creating a Pi filter?), In addition, there is one electrolytic capacitor for 400V and a controller for the 802X A0KH converter, which, more precisely, does not I analyzed, although I can see, among others there a 1R0 resistor (i.e. one ohm), on which the converter can measure the current (the shunt resistor). ES2JF is an ultrafast diode there, maybe from a snubber from the inverter? The F7 (FR107) diodes in the SOD-123 next to it are also fast. The element marked on the U2 board (the marking on the element is illegible) is probably the LDO regulator providing 3.3V for the WiFi module. Color switching transistors (there are five of them - one per channel R, G, B, W, C) are marked with N81Z, at the moment I have not found their catalog note ( if someone finds it, please comment ), but I must admit that in this topic I was more focused on the programming aspect of this 'light bulb', which will be discussed in a moment.
The WiFi module itself is XH-0068A by sparkleiot com based on BK7231N:




The signals P0 and P1 as well as TXD and RXD are seen here. P0 and P1 is actually a UART too, but not for programming, but only a debug log output:

However, only TXD and RXD will be useful for programming. Possibly also RST (but we can reset by cutting off the power).
The photos also show what signals come from the WiFi module to the PCB - among others. P7, P8, P9, P6, P24. PWM pins...
Programming of the BK7231N
To program the BK7231N, we need to connect an external power supply (disconnect the product from the mains, of course), preferably 3.3V via some own LDO (I used TC1264-3.3), because 5V would damage the WiFi module and connect the UART converter to the TX and RX pins of the BK7231N.
Power connection:

RX and TX connection. Soldering can be tricky. I used flux and first added some solder on wires and pads, and then soldered wires to the pads:




Power section and connection on the breadboard (3.3V connection is prepared in such a way so it's easy to disconnect it in order to force the system reboot).


Only Python programmer works for BK7231N, BKwriter1.60 won't do it here.
Download and install this tool:
https://github.com/OpenBekenIOT/hid_download_py
Prepare the firmware in the QIO version (not UA!), compile yourself or get it from here:
https://github.com/openshwprojects/OpenBK7231T_App
Then use the command:
python uartprogram W:\GIT\OpenBK7231N\apps\OpenBK7231N_App\output\1.0.0\OpenBK7231N_app_QIO_1.0.0.bin --unprotect -d com9 -w --startaddr 0x0
First run the programmer with this command:

At this stage, reboot (aka reset) the system (cut off and connect the power supply - sometimes it takes several times to get it; you can also reset with EN/RST pin):


Success. After restarting, you should see an open WiFi network for firmware configuration:

Connect to it and enter the configuration page at 192.168.4.1.
In case of any problems, if DHCP does not work, set your device IP manually to something like 192.168.4.15 (static IP), reconnect to WiFi and try again:

The roles of the pins are easy to assign - you could already see what signals go to the PCB:

NOTE: when setting channel indexes, keep order: 1 - red, 2 - green, 3 - blue, 4 - cool white, 5 - warm white
This is the default order used by "color" command (for MQTT as well).
Continue configuration (MQTT etc) like in these topics (they are both in Polish and English versions):
Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming
Qiachip Smart Switch - BK7231N / CB2S - interior, programming
The RGBCW (color picker) interface itself is not fully ready yet.
When it comes to setting the color in one go, there is a "color" command, which works in the same way as in Tasmota.
Color command syntax:
color #RRGGBB[CW][WW]
The color is in hex format, successive bytes corresponds to successive channels. It is enough to properly format the query on the Home Assistant side and we can set all the colors at once.
Example of a query that sets the color red:
color #FF0000
If we want to know what color is what code, we can find "RGB hex color picker" on the web.
This command can also be sent via MQTT, for example from Home Assistant.
Can such a bulb help you save electricity?
Let's start with the basics. Standby power consumption with lights turned off. It should be noted here that if we have a normal light switch and we turn off the light in the room, of course this consumption also disappears, but it is always just a few pennies...

Double-checking with the second meter:

Standby - 0.5W. Comparable with other smart products (eg Tuya, Blitzwolf sockets).
Now the colors:



And the most interesting - all the colors at once...

The energy consumption (just over 6W) does not resemble the sum of the energy consumption of the individual channels. The main power supply seems to be limiting the current. So with this bulb we will never get more than 6W ...
Dimming test:


Dimming works ok, very practical option. It allows, for example, to reduce the power consumption to just only 2W while maintaining a certain acceptable level of lighting in the room.
For comparison - the inside of an ordinary LED bulb
First, the 13W bulb (nominal):

Two burned LEDs, of course this can be fixed:

Interior:







MB10FH Bridge Rectifier, BP2861 Constant Current LED Controller:

Second, 14W:


PCB with LEDs screwed to the heat sink:


Much better cooling, the entire housing dissipates heat here , the first one is probably 13W only written on the housing.






Similar layout. BP2833D, surprisingly in THT.

Other ways to control RGBCW in Tuya bulbs
Finally, I would like to mention that in some other Tuya bulbs RGBCW control is done via the I2C interface. On the board with LEDs there is a dedicated controller (already with integrated transistors) and the BK7231N (either T or another) communicates with it via I2C. I am also going to support such dimming in the future. An example of such a controller can be SM2135:

This, however, will be on a different topic.
Summary
This Tuya Smart Bulb does not deliver promised 12W, but only 6W [/b] . More power will not be squeezed out of it, because it must be limited by the LED supply system, even when I force 100% duty on all channels (R, G, B, C, W) through my own firmware. However, this is not a surprise, with such poor cooling, probably the 12W would be an overkill.
In standby it consumes 0.5W (because the WiFi module is still working), just like other products of this type (WiFi sockets, contacts, etc.).
Besides, it's not that bad ... I can see some potential in such a bulb. The colors are unlikely to be useful in a practical way, but e.g. changing the temperature of the light (cold for work, warm for relaxation) is already a useful feature, and the possibility of dimming (e.g. as part of energy saving or late evening) is also something that could be used on a daily basis.
There is BK7231N inside - my firmware supports it . It's a bit of a drag to access inside, but it is still possible to do this without destroying the casing.
I know that I have not presented the full integration here (for example, my firmware is missing a convenient, graphical color picker), but I will try to develop it futher in the upcoming updates.
Feel free to follow:
https://github.com/openshwprojects/OpenBK7231T_App
I wonder how long will this LED smart bulb last. Does any of the forum users use this type of smart bulbs, e.g. as an alternative to replacing light switches with the 'smart' ones, and share their experiences?
I am attaching interesting doc about the BK7231.
Cool? Ranking DIY Helpful post? Buy me a coffee.