Elektroda.com
Elektroda.com
X

Search our partners

Find the latest content on electronic components. Datasheets.com
Elektroda.com

Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming

p.kaczmarek2 3549 11
This content has been translated flag-pl » flag-en View the original version here.
  • Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming
    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.

    Some generic information about the project and OpenBK7231T initiative
    As a supplement, I recommend that you familiarize yourself with related topics, including with my initiative to write my own firmware for BK7231 (Tasmota's ESP equivalent):
    WB2S / BK7231 Tutorial - we create our own firmware - UDP / TCP / HTTP / MQTT
    [BK7231T] My HTTP server, configurator, MQTT support from Home Assistant
    I also described the manufacturer's applications (Tuya / eWeLink / Blitzwolf / SmartLife) in previous topics from the series. I will not touch on its subject here.
    Additionally: my Home Assistant tutorial
    Additionally, a twin topic, but with a product from BK7231N (not T!):
    Qiachip Smart Switch - BK7231N / CB2S - interior, programming

    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 ...
    Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming
    The parcel came to me after quite a long time:
    Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming
    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):
    Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming
    Kit Contents:
    Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming
    Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming
    Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming
    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.
    Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming
    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:
    Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming
    There is a fuse at the input, a varistor, a simple filter on the choke:
    Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming
    The power supply itself is transformerless - based on the ICW4008.
    Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming
    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).
    Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming
    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)
    Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming
    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:
    Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming
    Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming
    Remove isolation from the wires, add some solder to them, give a little flux to 1117:
    Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming
    Them solder (with a clean soldering iron tip! Just clean it e.g. with a sponge method):
    Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming
    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:
    Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming
    Before soldering, we also whiten the pads, we also apply flux, we also whiten the ends of the wires (previously isolated).
    Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming
    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):
    Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming
    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):
    Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming
    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:
    Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming
    Only then the actual programming begins:
    Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming
    Programming Success:
    Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming
    After few seconds, the BK access point is already visible:
    Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming
    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:
    Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming
    If it doesn't work, try repowering the BK module.
    Next open the page 192.168.4.1:
    Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming
    Configure the device in "Config" subpage: (e.g. set our home WiFi SSID and pass, etc):
    Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming
    Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming
    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:
    Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming


    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:
    Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming
    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:
    Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming
    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.

    More information
    More information about the firmware and project can be found on the official repository:
    https://github.com/openshwprojects/OpenBK7231T_App

    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.

    Cool? Ranking DIY
    About Author
    p.kaczmarek2
    Level 26  
    Offline 
    p.kaczmarek2 wrote 1720 posts with rating 3439, helped 94 times. Been with us since 2014 year.
  • #2
    khoam
    Level 41  
    p.kaczmarek2 wrote:
    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.
  • #3
    p.kaczmarek2
    Level 26  
    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
  • #4
    khoam
    Level 41  
    p.kaczmarek2 wrote:
    Then the manufacturer (in line with the trend) changed ESP to BK7231T, so of course Tasmota stopped supporting this product.

    What exactly trend it comes? :)

    Added after 1 [minutes]:

    p.kaczmarek2 wrote:
    More and more IoT products are switching from ESP8266 / ESP8285 to microcontrollers such as BK7231T, BK7231N or XR809

    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.
  • #5
    p.kaczmarek2
    Level 26  
    khoam wrote:

    What exactly trend it comes? :)

    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 ...

    Look, even on Hackaday, these WB3L modules exchange for ESP12F instead of just programming them:
    https://hackaday.com/2021/04/17/replacing-an-esp8266-clone-with-the-real-thing/
    Quote:

    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).

    khoam wrote:

    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.
  • #7
    p.kaczmarek2
    Level 26  
    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.

    AHA, I have this topic I wrote about.
    It was this:
    https://www.reddit.com/r/esp8266/comments/l9i...t_moment_when_you_realize_the_30_tuya_lights/
    Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming
    Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming
    Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming
    Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming
    this user "sculpted" 28 (sic!) lamps to replace their WB3L modules with ESP8266 to upload Tasmota ... and he could wait a year and would have OpenBK from me ready to go without replacing the chips.
  • #9
    p.kaczmarek2
    Level 26  
    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.
  • #10
    MustangMatt
    Level 7  
    Tasmota/ESPHome work for ESP32 and ESP8266.

    This is an open firmware (somewhat similar to tasmota) for beken 7231t and 7231n which a lot of newer devices are using instead of ESP based chips.
  • #11
    p.kaczmarek2
    Level 26  
    Small update.
    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:
    Garden Tuya CCWFIO232PK Double Relay - BK7231T - Programming
  • #12
    strigona
    Level 2  
    Hey, I just want to send a huge THANK YOU! This is fantastic, well written and very detailed :) I will definitely be upgrading the firmware on my devices.