I will present here the short teardown and programming guide of the garden "smart" two-channel relay Tuya/WiFi model CCWFIO232PK, which I received as a donation from the user @strigona from Canada in order to test my Tasmota replacement for microcontrollers from the Beken family (BK7231T). The topic will be divided into two parts - the teardown of the product and then programming guide for use with BKwriter 1.60 and OpenBK7231T. But first, a special thank you to @strigona - thank you, the template for this product has already been added to my firmware! If someone wants to send me some other product for testing, send me Private Message here on forum.
Tests with the Tuya application, automation I have tested Tuya products in this section so many times that I will not discuss the "obvious" functionalities here. Please see to the previous parts - e.g. here.
Kit contents and product interior @strigona bought this two pieces kit at a Costco store. According to him, earlier versions were based on ESP8266 and Tasmota could be used with them, but Tuya is switching to Beken chips ...
The parcel came to me after quite a long time:
The Polish Post Office could not let it pass - even though it was marked as "Gift" - and counted the postage fee to some 8.5 PLN, which I paid on delivery (the lady from the post office brought a package to the door at least):
Well, in Canada they have a different socket standard than ours in Poland. The device is on 120V. I think that 230V would also work, but you need to check it after opening (check the parameters of all elements and their catalog notes, from the inverter controller as there is, through capacitors to relays).
The housing is held together with screws.
Inside we have two relays, one button and a 32-bit microcontroller with WiFI BK7231T, but simply placed on the main PCB of the device, not in the form of a module such as WB2S or WB3S:
There is a fuse at the input, a varistor, a simple filter on the choke:
The power supply itself is transformerless - based on the ICW4008.
BK7231T - we will program it soon. Right next to it you can see the voltage regulator 3.3V, because BK works at 3.3V and the relay works at 5V (sometimes at 12V).
You can also see two transistors that control the relays.
From the bottom, we have prepared pads for programming signals, including:
- UART1 port (programming via bootloader)
- UART2 port (debug log output with information about what the device is doing)
- SPI pins (programming if bootloader fails)
- CEN pin (system reset)
That's it - in the next paragraph we solder and program.
Programming BK7231T with my firmware Download the last binary binary files and BKwriter 1.60 from my repo:
https://github.com/openshwprojects/OpenBK7231T_App https://github.com/openshwprojects/OpenBK7231T All operations are performed after disconnecting the product from the electrical network. First connect the power from USB to LDO, pinout LM1117, 5V to VIN, ground to ground:
Remove isolation from the wires, add some solder to them, give a little flux to 1117:
Them solder (with a clean soldering iron tip! Just clean it e.g. with a sponge method):
The same for the 1RX, 1TX and CEN. The 2TX 2RX port is only a debug log output, we don't need it if everything is ok:
Before soldering, we also whiten the pads, we also apply flux, we also whiten the ends of the wires (previously isolated).
Next connect the USB UART converter, here the HW-597 USB TTL, in 3.3V mode (jumper between VCC and 3V3), along with the power supply taken directly from the USB (it will not work from the pin marked as "5V" because it has a slightly different role, it is just used to select logic levels of UART, 5V vs 3.3V):
Then run BKwriter 1.60.
First you can make a backup copy of the original firmware (Read button), reading firmware is done in the same way as programming.For programming, just remember to select which firwmare file you want to upload.
So, choose what firmware you want to upload (here, for T version of BK7231, select the UA version) and start programming (actually it starts waiting for BK booting):
Now, as long as BKwriter is actively waiting for the BK boot signal, temporarily connect CEN to ground (here it is just on the USB dongle pin), literally for a second:
Only then the actual programming begins:
After few seconds, the BK access point is already visible:
Next connect to the WiFi Open Access point created by BK7231T.
Here you may need to set our WiFi to a static IP, e.g. 192.168.4.10, in case DHCP does not work:
If it doesn't work, try repowering the BK module.
Next open the page 192.168.4.1:
Configure the device in "Config" subpage: (e.g. set our home WiFi SSID and pass, etc):
After setting the pass and SSID of WiFi, you might need to wait a bit or Restart the device from web page. You may also need to disconnect the power supply temporarily or wait a minute for the device to join our network. Its new IP can be found on our router in the list of DHCP clients:
Pin role configuration, templates and button support Smart devices have different configurations of buttons, relays and LEDs. They can be connected to different pins of the microcontroller.
The "Configure Module" subpage is used to set the role of individual outputs:
The right column is the role of the pin (button, relay, PWM) and the left column is the channel (individual relay number, PWM, etc).
You can learn the roles of the pins experimentally or by following the connections on the board.
Some devices have already been developed by me, so there are ready-made configurations for them - they are in the "Quick config" tab:
The device of this theme is quite unique in that it has two relays and one button. In the original firmware, the relays can be controlled separately, but only from the Tuya application level. The button either turns them both on or off. To this end, I introduced the pin role: "Button Toggle All", which allows one button to disable / enable all channels of the fixture.
Connecting to the Home Assistant Ultimately, my firmware allows you to control any device of this type via MQTT - I recommend reading the "configure MQTT" and "generate Home Assistant config" tabs. Operation is analogous to Tasmota.
Summary The programming of this WiFi-controlled dual relay plug would not be possible without my OpenBK7231T project. There are no alternative firmwares for BK7231T, and conversion to ESP is not an option, because BK7231T here in directly on product board and not in module form such as WB3S. WB3S can be easily replaced with ESP12F, but that's not the case here. Also, why pay for another module when you have OpenBK?
After all, the whole conversion was easy - to upload my firmware, just solder the cables, run BKwriter 1.60 and it's ready.
Finally, I would like to emphasize that the procedure described here works for BK7231T and modules based on it, i.e. WB2S, WB3S, etc.
For BK7231N (N version, not T version) the procedure is slightly different from what I have described here .
There is also the matter of a single button - one button for both relays. Especially for this device I implemented a role in the pin configurator ("Button Toggle All"). It's a bit strange that since the manufacturer gave two relays, he did not try to put two buttons ... but maybe it's because at least one button is necessary to force pairing with Tuya (although I have already seen smart devices where pairing is enabled without buttons - by quick power on / off).
Now I think that this button could be used even better - each click could switch the combinations of relays to the next (two relays give 4 possible combinations on off), or e.g. a short press could switch the first relay, and a long (or double) the second. Perhaps I will add it in future code revisions ... I recommend following my repository on Github.
As for the so-called "outdoor" quality of the product, I wouldn't expect much. It should definitely be under a roof, and with time it will probably be damaged by the moisture itself.
PS: Such a curiosity - I saw that this product (CCWFIO232PK) appeared on the Tasmota website as ESP based. Well, I guess it's no longer supported then, since now it's based on BK7231T!
https://templates.blakadder.com/prime_CCWFIO232PK.html Well, after my intervention, the product is 'supported' again - but this time it's because of my firmware.
PS: Such a curiosity - I can see that this product (CCWFIO232PK) appears on the Tasmota website as "no longer supported" because ESP was previously and now Bekken is: https://templates.blakadder.com/prime_CCWFIO232PK.html Well, after my intervention, the product is 'supported' again - but this time it's because of my firmware.
Can I upload a Tasmota code? The above manifesto is somewhat unclear.
I meant that in CCWFIO232PK there was initially a module with ESP8266 and it was possible to upload Tasmota. Then the manufacturer (in line with the trend) changed ESP to BK7231T, so of course Tasmota stopped supporting this product. Tasmota is only on ESP. You won't put Tasmota there anymore. But my firmware supports BK7231T and is functionally equivalent to Tasmota (even the principle of operation is analogous, pin configuration, MQTT), although "under the hood" is 0 Tasmota code.
More and more IoT products are switching from ESP8266 / ESP8285 to microcontrollers such as BK7231T, BK7231N or XR809, and my firmware is the answer. Ultimately, it should support most of what Tasmota supports - including TuyaMCU.
And I also gave the comparison to Tasmota from here, that as a rule, the end user does not pay attention to what specific firmware will be uploaded, to open the module on MQTT, and whether ESP8266 with Tasmota or Beken with OpenBK is in the middle is a secondary matter
I do not know how much you are interested in Tuya and the products from their stable, but more and more "smart" toys, relays, light bulbs, door opening sensors, flood sensors, were initially built on ESP8266 (TYWE3S and similar), and in recent years they are more and more often inside modules of the Bekken type or other. I don't know why this is so, but for the Home Assistant community this is a big minus, because they can't easily change the firmware ...
With a growing trend towards replacing the venerable ESP8266 with cheaper and less hacker-friendly silicon, buying IoT hardware with the intent to replace its firmware is likely to get riskier in the near future.
And here I say stop - there will be no "riskier", my Tasmota counterpart already supports the BK7231T, BK7231N and XR809 platforms, and on the way there is also https://github.com/w600 (Winner Micro 600, it looks like they are all "puzzles" "needed to run it, but haven't checked yet).
Also on ESP32-C3. It is worth getting acquainted with the offer of AI-Thinker and other manufacturers in order to look at the home IoT devices market a bit wider.
Unfortunately, I know nothing about the ESP32-C3. I do what I managed to "draw" in Tuya products, and I have not seen ESP32 in any of Tuya's products yet. This ESP32 is in some smart products?
PS: I saw an article somewhere from a year ago that someone bought 10 light bulbs with the intention of uploading another firmware to the ESP but it turned out there was Bekken inside and the user eventually ... bought and sold these 10 ESP12F modules by hand And thanks to my firmware it wouldn't be needed. By the way, I can't find this article right now - maybe someone will find it? I think it was on Reddit.
I can see that there is some interest in movement with ESP32, but is it possible to find it in a finished Tuya product, and not buy it separately and solder it?
But overall that's not what I meant. The topic that I had in mind had photos of several / a dozen ESP12F modules attached and its author showed that he is massively desoldering WB3S (probably this one) and in its place he gives ESP12F.
I hope that over time (and with the support of possible contributors - anyone can add their changes to the repository, the so-called pull request, this is what open source is all about), support will also be provided for more popular sensors.
At the moment, he targets the TuyaMCU himself (I have two devices with it) and bl0937 (energy measurement, the device is on its way).
Of course, there is also the question of which sensors are the most popular, etc.
I added ability to control two separate relays with single button. This is very useful for devices like the one from this topic (CCWFIO232PK).
Single click = toggle relay 1.
Double click = toggle relay 2.
See new config: