logo elektroda
logo elektroda
X
logo elektroda

[BK7231N] KS-602S 120V Intertek Kuled K36 Switch Flashing

bgardner46 3381 20
ADVERTISEMENT
  • I have now successfully flashed 4 of these switches so it's time to provide the details. I have purchased switches from both Amazon and directly from Kuled. The box on the left is how they come from Kuled and the box on the right is from Amazon.

    [BK7231N] KS-602S 120V Intertek Kuled K36 Switch Flashing

    Amazon link - https://www.amazon.com/Compatible-Requires-Ne...00a87a1346&ref_=pd_gw_ci_mcx_mr_hp_atf_m&th=1

    Kuled link - https://kuled.com/product/smart-wifi-light-switch-k36-4pack/

    This is the front of the switch.

    [BK7231N] KS-602S 120V Intertek Kuled K36 Switch Flashing

    This is the back.

    [BK7231N] KS-602S 120V Intertek Kuled K36 Switch Flashing

    There seem to be a number of similar switches from other locations that all have the same model number - KS602-S although sometimes the switches are advertised as K36 - not sure what that's all about.

    [BK7231N] KS-602S 120V Intertek Kuled K36 Switch Flashing

    If you remove the 4 screws you see the back of the PCB.

    [BK7231N] KS-602S 120V Intertek Kuled K36 Switch Flashing

    Then if you remove 2 more screws you get to the top of the board.

    [BK7231N] KS-602S 120V Intertek Kuled K36 Switch Flashing

    There is a 2 X 6 X 2mm PCB hole layout that can be used for flashing. The first switch I soldered wires to the holes but for the others I actually soldered in a 2 X 6 header and left the header since there was plenty of room.

    [BK7231N] KS-602S 120V Intertek Kuled K36 Switch Flashing

    The header labels refer to these pins on the MCU:

    T - Transmit
    R - Receive
    G - Ground

    R - CEN
    I - No Connection
    V - 3.3 volts

    As usual the Transmit goes to Receive on the USB - Serial adapter and Receive goes to Transmit on the adapter. Make sure you are using a 3.3 volt adapter and connect V and G to the appropriate connections on the USB adapter. For the R terminal I used a single wire.
    Once you are wired up and ready to go it's time to flash. I already had Python installed on my PC so I just installed hid_download_py and then moved the bin flash into the same directory as uartprogram. Once I had all that set up I opened the command line window and changed the default directory to the uartprogram directory and entered the flash command.

    [BK7231N] KS-602S 120V Intertek Kuled K36 Switch Flashing

    After pressing enter, I briefly touched the CEN pin wire to ground and the flash started. Once completed, I followed the standard procedure to log into the temporary access point and configure the WiFi settings. Then I determined the IP address assigned by my router and logged into the switch. It was then a simple matter to configure the correct pins as below:

    P17 - Relay - channel 1
    P24 - LED - channel 2
    P26 - Button - channel 1

    After saving these setting, I configured the MQTT settings and I was ready to go. I was able to control the switch via MQTT through my home control system and was even able to set up device groups which greatly simplified setting up 3 way switches.

    Well, that's about it. I am greatly impressed with the software and would really only like 2 additional features that Tasmota implements. I would like to configure a static IP without using router address reservation and it would be nice to configure 2 SSIDs, a main one and a fall back.

    If anyone has any questions or needs more information or pictures, please feel free to ask.

    Bob

    Cool? Ranking DIY
    About Author
    bgardner46
    Level 3  
    Offline 
    bgardner46 wrote 26 posts with rating 4. Been with us since 2022 year.
  • ADVERTISEMENT
  • #2 20355365
    p.kaczmarek2
    Moderator Smart Home
    Very good job, I'm happy it worked out for you. Your description is very detailed, so I will separate this post from the base thread and add it to our presentations/guides list.

    Yes, our Tasmota Device Groups is useful for 3 way switches (aka stair switches, etc), you can easily pair Tasmota with OBK that way, even without MQTT.

    I can look into the IP setting, but I must admit that I assumed people use MAC reservation on router so it's not a top priority. Still, very nice suggestions, same for SSID2. Btw, do you know we have the same commands as Tasmota for most of the configuration?
    [BK7231N] KS-602S 120V Intertek Kuled K36 Switch Flashing

    By the way, regarding flashing, it's also worth to do a full 2MB flash read first. Just in case, and there is also that tuya-convert equivalent for BK7231, but it sadly requires support added per-device model basis (so someone have to do a binary read first, and then they add support for given binary, and next devices from the same batch/series can be flashed over the air).
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #3 20356619
    stan.
    Level 15  
    This switch is for 110V 60Hz
  • #4 20356742
    Krzysztof Kamienski
    Level 43  
    stan. wrote:
    This switch is for 110V 60Hz
    Horrible! Only you see, the Author is from the United States of North America, and there are other Mayan prunds. :cry:
  • #5 20356764
    p.kaczmarek2
    Moderator Smart Home
    Our forum is multilingual. The English site is https://elektroda.com/ and there are English-language materials, and the Polish site is https://elektroda.pl/. Some of the materials are common and are translated and transferred to the other side. The translations are machine-made (only sometimes corrected by hand), so sometimes there are errors in them.
    Helpful post? Buy me a coffee.
  • #6 20403928
    mannsteve
    Level 6  
    bgardner46 wrote:
    Once you are wired up and ready to go it's time to flash. I already had Python installed on my PC so I just installed hid_download_py and then moved the bin flash into the same directory as uartprogram. Once I had all that set up I opened the command line window and changed the default directory to the uartprogram directory and entered the flash command.
    Bob


    Where can I find the uartprogram?
  • #7 20404005
    p.kaczmarek2
    Moderator Smart Home
    All links are here:
    https://openbekeniot.github.io/webapp/devicesList.html
    uartprogram is in "hid_download_py" but maybe you should try Windows exe UART flasher first? Or bkWriter 1.60?
    https://github.com/openshwprojects/BK7231GUIFlashTool
    [BK7231N] KS-602S 120V Intertek Kuled K36 Switch Flashing
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #8 20405543
    mannsteve
    Level 6  
    I used the BK7231 Easy UART Flasher on my PC and successfully flashed the file: OpenBK7231N_QIO_1.15.384.bin.

    When the upload finished, I restarted the device and got the device AP. I pointed my browser to 192.168.4.1 and I entered my network credentials.

    Then, nothing. When I rebooted the device, the MAC address was not found in my IP scanner (Advanced IP Scanner).

    Thinking that I may have made an error with my network credentials, I flashed it again using "Do firmware write". Now, when I reboot the device I do not see the device AP in my phone's "Available networks".

    Any tips would be appreciated.
  • #9 20405599
    p.kaczmarek2
    Moderator Smart Home
    @mannsteve what kind of device do you have? What is in the serial log? Use TX2 pin with 115200 baud to see what device logs.

    EDIT initial test shows that 384 works for me, no surprises here.... I will investigate more:
    [BK7231N] KS-602S 120V Intertek Kuled K36 Switch Flashing
    Helpful post? Buy me a coffee.
  • #10 20407097
    mannsteve
    Level 6  
    bgardner46 wrote:
    If anyone has any questions or needs more information or pictures, please feel free to ask.

    Bob


    What are the MQTT commands to turn the switch on or off?
  • ADVERTISEMENT
  • #11 20407162
    bgardner46
    Level 3  
    To turn the switch on you would use "topic/1/set 1"

    To turn the switch off you use "topic/1/set 0"

    Without the quotes and topic is whatever name you gave the switch.

    Bob
  • #12 20407262
    mannsteve
    Level 6  
    bgardner46 wrote:
    To turn the switch on you would use "topic/1/set 1"

    To turn the switch off you use "topic/1/set 0"

    Without the quotes and topic is whatever name you gave the switch.

    Bob


    Thanks. That's what I thought watching the get command on MQTT explorer, but I can't control it with a publish. Is there a status command?
    I am connected to the MQTT broker or I wouldn't be able to publish the get command.

    [BK7231N] KS-602S 120V Intertek Kuled K36 Switch Flashing

    The button on the switch, and the toggle button on the menu page just toggle the LED from green to red. The relay does nothing.
    Could the GPIO pins in my switch be different than yours?

    [BK7231N] KS-602S 120V Intertek Kuled K36 Switch Flashing

    Any ideas would be appreciated.
  • #13 20407313
    p.kaczmarek2
    Moderator Smart Home
    mannsteve wrote:

    Any ideas would be appreciated.

    You are most likely using an older version (didn't do OTA to latest) and you didn't reboot device after changing MQTT topic?

    But.. I will just note that we also support Tasmota syntax, as said in project subtitle, so you can do:
    
    cmnd/obkFFBBCCAADD/POWER
    

    with argument

    and it should work as well.
    Or POWER2, etc,. Please try.

    both cmnd and set/get are working
    Helpful post? Buy me a coffee.
  • #14 20407323
    bgardner46
    Level 3  
    You should also set the LED to 2 instead of 1 and you get individual control of the relay and the led.

    [BK7231N] KS-602S 120V Intertek Kuled K36 Switch Flashing

    Bob
  • #15 20407345
    mannsteve
    Level 6  
    bgardner46 wrote:
    To turn the switch on you would use "topic/1/set 1"

    To turn the switch off you use "topic/1/set 0"

    Without the quotes and topic is whatever name you gave the switch.

    Bob


    Many thanks. The switch is now working using MQTT commands.
    Do you know how to add the switch to Home Assistant?
  • #16 20407563
    p.kaczmarek2
    Moderator Smart Home
    mannsteve wrote:

    Do you know how to add the switch to Home Assistant?

    Update to latest version and follow guide:
    [youtube]
    https://www.youtube.com/watch?v=pkcspey25V4
    [/youtube]
    See here for more information: https://openbekeniot.github.io/webapp/devicesList.html
    Helpful post? Buy me a coffee.
  • #17 20435024
    Phrede
    Level 2  
    I just did this my first time using bk7231flasher v1.0.4. Considering it was my first, things went smoothly. Hardest part was finding the which signal was on which test point on the board, mine has no labels.

    FWIW, I use static IPs on all my devices. Router DHCP has limits. A fall back ssid also would be nice. I usually flash and configure in my lab then move the device to the working location which has a different ssid.

    Home Assistant discovery went easy enough. HA installed the Tuya integration automatically, which I quickly disabled.

    I've noticed that the switch for the green LED is reversed. Switch on = led off. I just renamed it accordingly.

    Questions:
    Is there any way to disable leds completely? or control via MQTT only? The red led may be hardwired to the relay IDK.
    Is there any way to have the button detached from the relay and publish the MQTT only without toggling the relay? (ie Tasmota setoption 114 / switchmode 15)

    Thanks for your work on this.
  • #18 20435125
    p.kaczmarek2
    Moderator Smart Home
    Phrede wrote:

    I've noticed that the switch for the green LED is reversed. Switch on = led off. I just renamed it accordingly.

    LED_n is a negated LED

    Phrede wrote:

    Is there any way to disable leds completely? or control via MQTT only? The red led may be hardwired to the relay IDK.

    Just don't set LED role for given pin, you can always set AlwaysHigh or AlwaysLow to force given state forever

    Phrede wrote:

    Is there any way to have the button detached from the relay and publish the MQTT only without toggling the relay? (ie Tasmota setoption 114 / switchmode 15)

    we are much more flexible than that. You can just set relay pin AlwaysHigh or AlwaysLow, or you can set relay to be on the separate channel.

    And if you want to publish under custom names you can always script it in autoexec.bat, for example:
    
    	// this will only happens when Channel12 value changes from not equal to 0 to the one equal to 0
    	addChangeHandler Channel12 == 0 publish myChannel valueIsZero
    	// this will only happens when Channel12 value changes from not equal to 1 to the one equal to 1
    	addChangeHandler Channel12 == 1 publish myChannel valueIsOne
    	// this will only happens when Channel12 value changes from not equal to 2 to the one equal to 2
    	addChangeHandler Channel12 == 2 publish myChannel valueIsTwo
    	// this will only happen every time when channel changes, and publish value multiplied by 10
    	addEventHandler OnChannelChange 12 publishInt twelveValue $CH12*10
    

    See related self test:
    https://github.com/openshwprojects/OpenBK7231...n/src/selftest/selftest_changeHandlers_mqtt.c
    You can also script button events to publish stuff directly in OnClick, OnDblClick, OnHold, etc.
    https://github.com/openshwprojects/OpenBK7231...lob/main/src/selftest/selftest_buttonEvents.c
    Helpful post? Buy me a coffee.
  • #19 20440060
    Phrede
    Level 2  
    Thanks for the info. Everything except being able to see a button press is resolved. BTW, there is no way to turn off the red LED.

    You mention an autoexec.bat file, something I have not heard in many years since MS-DOS. Where/how is this file accessible?

    My second device did not go smoothly as it did not connect after setting the ssid and password. The "erase all" function in the latest version flashing tool solved the problem.
  • #20 20440218
    p.kaczmarek2
    Moderator Smart Home
    After doing "Erase all" you should restore RF partition in Web App -> Flash Tab.

    The autoexec.bat can be created in Web App -> FileSystem Tab.

    What do you mean with "see button press"? A log message? Or how can I help?
    Helpful post? Buy me a coffee.
  • #21 20440686
    Phrede
    Level 2  
    After doing "Erase all" you should restore RF partition in Web App -> Flash Tab.

    Yes, I found it finally. The MAC changed, but I could fix it.

    The autoexec.bat can be created in Web App -> FileSystem Tab.

    Yes, again I found it by hunting.

    What do you mean with "see button press"? A log message? Or how can I help?

    This device is a wall switch with a Push Button activation. I want to use a binary sensor in HA that is on when this button is pressed.

    I configured the GPIO "btn" for channel 3 and created a message script in the autoexec.bat. The problem with this is that a button press toggles channel 3, not momentary. Not useful if I want to know when the PB is pressed.

    I then defined the input as "dInput_n" and rewrote the homeassistant discovery statement with better names. It all seems solved now. For double press or long press I will write automations to do that in HA.

    Thanks for your help

Topic summary

The discussion revolves around flashing the KS-602S 120V Intertek Kuled K36 smart switch using the BK7231N chip. Users share their experiences with flashing the device, including successful methods and tools like the BK7231 Easy UART Flasher and various firmware versions. Key topics include configuring MQTT commands for switch control, troubleshooting connectivity issues, and integrating the switch with Home Assistant. Users also discuss LED behavior, GPIO configurations, and the use of autoexec.bat for custom scripts. The conversation highlights the importance of proper network settings and firmware updates for optimal functionality.
Summary generated by the language model.
ADVERTISEMENT