logo elektroda
logo elektroda
X
logo elektroda

BK7231N and CB3S: Detailed Guide on LoraTap SC400W-EU Switch Board Desoldering and Flashing

paulomac1000 4857 51
ADVERTISEMENT
  • #31 20990453
    p.kaczmarek2
    Moderator Smart Home
    hezipereg wrote:
    Quote:
    You need to create a branch. Issues are irrevelant for creating PR.

    I don't have the open branch button available.

    My Github knowledge is not good but I think that you need to first fork my repository. Then you will be able to open PRs from your fork to main repo.


    hezipereg wrote:

    Quote:
    run build in cygwin

    I tried to build using wsl. I get: ./b.sh: 1: ./build_app.sh: not found

    Please double check paths, here is how it looks on my side:
    Screenshot of a folder with various script and document files in Windows File Explorer.
    Screenshot of the apps folder in Windows with highlighted paths to location.

    Added after 2 [minutes]:

    BTW: On my side build in wsl fails, hmm:
    Screenshot of a terminal showing compilation errors of a script in Linux.
    Linux console showing compilation errors in the OpenBK7231T_App repository.
    I don't know why, we may want to investigate that. I know that it works in cygwin.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #32 20993164
    hezipereg
    Level 7  
    Any progress with figuring out why it is not working in wsl?

    I also get the following error:
    Screenshot of a compilation error in a Linux terminal.
  • ADVERTISEMENT
  • #33 20993226
    p.kaczmarek2
    Moderator Smart Home
    I didnt' have time yet, I think it would be faster to just install Cygwin.

    There was also an alternative docker build system on the repository somewhere.
    Helpful post? Buy me a coffee.
  • #35 20995202
    p.kaczmarek2
    Moderator Smart Home
    Good job, I will post that information in a form of miniguide for compiling on WSL soon. I didn't know that.

    Regarding rebuild, I think that @btsimonh added the recursive "delete generated files" in the build script somewhere because there was some kind of issue. I am not sure.

    I do the 90% of the development on Windows port in MSVC and test things through the unit tests like:
    https://github.com/openshwprojects/OpenBK7231T_App/tree/main/src/selftest
    I only upload to the physical device for the final testing.
    Helpful post? Buy me a coffee.
  • #36 20995745
    hezipereg
    Level 7  
    If you want me to write the shutter driver, I need you to give me some guidance.
  • #37 20995747
    p.kaczmarek2
    Moderator Smart Home
    Sure, how can I help you futher? Just ask and I will try to help the best I can.

    Do you want to develop first in Windows, like I do, or do you want to test everything on BK7231, as some people prefer?
    Helpful post? Buy me a coffee.
  • #38 20995782
    hezipereg
    Level 7  
    I will develop on Windows.
    I need to know what are these driver function are all about:
    Code: C / C++
    Log in, to see the code
  • ADVERTISEMENT
  • #39 20995798
    p.kaczmarek2
    Moderator Smart Home
    hezipereg wrote:
    I will develop on Windows.

    Do you need help with compiling OBK to run on Windows (as a simulator with self tests)?

    hezipereg wrote:

    Code: C / C++
    Log in, to see the code

    This is called once when a driver starts. You can create custom commands there via CMD_RegisterCommand. The registered commands can be later called via MQTT, etc.

    hezipereg wrote:

    Code: C / C++
    Log in, to see the code


    This is called on every second. I am not sure if you need it.

    hezipereg wrote:

    Code: C / C++
    Log in, to see the code


    This is used to add custom information to HTTP page. Maybe you can use it to display the percentages, etc, how much shutters are open.


    hezipereg wrote:

    Code: C / C++
    Log in, to see the code

    This is called on quick tick, every 25ms. See QUICK_TMR_DURATION . Use this to update your timer counters and when they overflow, stop the shutter operations.

    hezipereg wrote:

    Code: C / C++
    Log in, to see the code

    This is called when a driver is stopped. This is often ignored, as we just assume user will restart the device.

    hezipereg wrote:

    Code: C / C++
    Log in, to see the code

    This is a channel change callback in case that you might need that. If you decide that you want to use some channel as as shutter percentage level, you may watch for it to change.

    For more specific information, please see our drivers directory here:
    https://github.com/openshwprojects/OpenBK7231T_App/tree/main/src/driver
    Just open any driver file of interest and check out how are init/everysecond/quick tick functions used.

    Keep in mind that there are many possible approaches to implementing the shutters driver and even I don't know which is the best. You can use our SDK in many ways, just find the one that suits your needs best.
    Helpful post? Buy me a coffee.
  • #40 21101397
    PSlowik
    Level 12  
    Hello you.

    Till today I had a controller working about 2 years and suddenly disconnected from the Wifi network. I can not normally add to Tuya :( so I decided if it is possible to do an Open Beken?


    Hover up down pause and light.

    Control panel with four buttons: up, pause, light, down. .
  • #42 21101441
    PSlowik
    Level 12  
    >>21101398 I haven't had a chance to open it yet. The question is whether it is the software that has crashed somehow? Will an OB help hmmm
  • ADVERTISEMENT
  • #43 21101445
    p.kaczmarek2
    Moderator Smart Home
    It is hard to assess remotely. It is also possible that a capacitor in the power supply is simply damaged. In that case the Tuya will continue to work after repair. In such a situation, the repair looks like here:
    How do I fix a smart device that chirps, squeaks and makes strange noises? .
    Helpful post? Buy me a coffee.
  • #44 21101451
    PSlowik
    Level 12  
    Even strangely reports this device after bluetooth probably in the application. No drawing and no name :/

    App interface for adding a new Bluetooth device

    Printed circuit board with electronic components and a module labeled CBU. Electronic module with coils and connectors held in a hand. Image of a round circuit board with visible electronic components and soldering. Image of a round circuit board with visible electronic components and soldering.
  • #45 21108076
    PSlowik
    Level 12  
    There is a problem because the device reports as New Device when it should be a Curtain Switch.
    I have checked the capacitors and replaced them without any change.
    I still need to change the software :) .
    Can I ask for help?
  • #46 21109623
    p.kaczmarek2
    Moderator Smart Home
    You can upload OpenBeken on it, but that MCU there is on the UART pins? So it's a TuyaMCU device?
    Helpful post? Buy me a coffee.
  • #47 21109628
    PSlowik
    Level 12  
    >>21109623 .
    I do not know TuyaMCU... it worked normally with tuya app.
    I have something to upload the soft so maybe check.
    Where can I generate the soft? You have already helped me in the past with the light switch flies nicely
  • #48 21109635
    p.kaczmarek2
    Moderator Smart Home
    Our flasher downloads the soft from the internet:
    https://github.com/openshwprojects/BK7231GUIFlashTool
    But first check with a multimeter if the RX and TX from the WiFi module is not connected to this microcontroller by any chance?
    Helpful post? Buy me a coffee.
  • #49 21109641
    PSlowik
    Level 12  
    >>21109635 ok I'll get back to you in about 2 hours :) thanks
  • #50 21109644
    p.kaczmarek2
    Moderator Smart Home
    I recommend looking through the topic on TuyaMCU, it will definitely help:
    TuyaMCU flashing, installation and configuration guide - configure dpID for Home Assistant .
    Helpful post? Buy me a coffee.
  • #51 21477597
    antonioriosarroyo
    Level 4  
    Hello, good morning. Sorry for the message, but I find the blind drivers very interesting. How's it going? I'm interested. Thank you very much.
  • #52 21484624
    antonioriosarroyo
    Level 4  
    Hello, very good, just thank @rodionzhitomirsky and @gliga69 for your code. I modified it and it works very well. Both the physical and web buttons work correctly, and the blind percentage seems great. I have it on a Loratap SC400W-EU, but don't trust the PINs; each Loratap is unique.

    I'm leaving the code here, with a comment on where to put your PINs, in case anyone is interested.

    Translated with Google, in case it's not clear.
    
    clearIO
    // ====== CONFIG ======
    // Used to hold the delay value in millis for sleeping during closing or opening loop
    // Play with your curtain and find the right value for this delay
    
    SetChannel 8 100
    
    // Delay to wait (millis) before starting to move the curtain after we close both relays
    // maybe it is not necessary, but I prefer it to be to ensure we do not have
    // both open and close relays powered simultaneously:
    SetChannel 7 500
    
    // MQTT stuff
    MqttClient lr_curtain_2
    MqttHost <YOUR_HA_MQTT_HOST>
    MqttUser <YOUR_HA_MQTT_USER>
    MqttPassword <YOUR_HA_MQTT_PASSWORD>
    
    // ====== END OF CONFIG ======
    
    // set channels 7, 8 and 9 to be private, so that we do not spend resources to publish their values:
    SetChannelPrivate 7 1
    SetChannelPrivate 8 1
    SetChannelPrivate 9 1
    
    // HIde relays from GUI
    setChannelVisible 1 0
    setChannelVisible 3 0
    
    // We start the main opening/closing loop with a delay
    // and than immediately have a calibration delay
    // so, let's decrement the calibration delay to not have them both
    // at the beginning of the loop:
    
    addChannel 7 -$CH8 0 5000
    
    PowerSave 1
    //startDriver ntp
    
    // set pins and channels
    
    // Pin 7 is connected to opening relay
    SetPinRole 7 Rel
    // we also connect it to channel 1
    SetPinChannel 7 1
    SetChannelLabel 1 "Up"
    
    // Pin 6 is connected to closing relay
    SetPinRole 6 Rel
    // we also connect it to channel 3
    SetPinChannel 6 3
    SetChannelLabel 3 "Down"
    // crea los botones
    setChannelType 20 Toggle
    SetChannelLabel 20 "Down"
    setChannelType 21 Toggle
    SetChannelLabel 21 "Stop"
    SetChannel 21 1
    setChannelType 22 Toggle
    SetChannelLabel 22 "Up"
    // 23 - stop button 
    SetPinRole 26 Btn
    // 24 - opening button
    SetPinRole 9 Btn
    // 26 - closing button
    SetPinRole 24 Btn
    
    // CH9 - saved position for reboot
    // CH10 - current position
    // CH11 - target position
    
    SetChannelLabel 9 "Saved Position"
    setChannelType 9 Dimmer
    SetChannelLabel 10 "Current Position"
    setChannelType 10 Dimmer
    SetChannelLabel 11 "Target Position"
    setChannelType 11 Dimmer
    
    SetStartValue 9 -1
    
    // read position saved before reboot:
    SetChannel 10 $CH9
    SetChannel 11 $CH9
    
    // Setup LED:
    //SetPinRole 10 LED
    //SetPinChannel 10 4
    
    // ============= MQTT ============
    
    // Let it shine when MQTT connection is established:
    addEventHandler MQTTState 1 SetChannel 4 1
    addEventHandler MQTTState 0 SetChannel 4 0
    
    // [2] Always set MQTT Retain flag to all published values;
    // [7] Broadcast self state every N seconds:
    // [10] Broadcast self state on MQTT connect
    flags 1156
    
    // Inform HA about our values every 30 seconds, publish 2 values per second
    mqtt_broadcastInterval 30
    mqtt_broadcastItemsPerSec 2
    
    alias Set_Stop backlog setChannel 3 0; setChannel 1 0
    alias Start_Opening backlog SetChannel 22 1; stopAllScripts; startScript autoexec.bat openSkylight
    alias Start_Closing backlog SetChannel 20 1; stopAllScripts; startScript autoexec.bat closeSkylight
    alias Stop_All backlog stopAllScripts; startScript autoexec.bat stopSkylight
    alias Open_To_Target backlog stopAllScripts; startScript autoexec.bat openSkylightToTarget
    
    alias Stop_Clicked backlog Set_Stop; Stop_All; SetChannel 21 1
    
    // Click and fast release will effect in fully closing or opening.
    // If during this process we click on the same button again, it stops 
    // EDIT PINS..............................................................................................................................................
    addEventHandler OnClick 24 if $CH03==1 then Stop_Clicked else Start_Closing
    addChangeHandler Channel20 == 1 if $CH03==1 then Stop_Clicked else Start_Closing
    addEventHandler OnClick 9 if $CH01==1 then Stop_Clicked else Start_Opening
    addChangeHandler Channel22 == 1 if $CH01==1 then Stop_Clicked else Start_Opening
    addEventHandler OnClick 26 Stop_Clicked
    addChangeHandler Channel21 == 1 if $CH02==1 then Stop_Clicked else Stop_Clicked
    //..............................................................................................................................................................................
    
    addChangeHandler Channel20 == 1 backlog SetChannel 21 0; SetChannel 22 0
    addChangeHandler Channel21 == 1 backlog SetChannel 20 0; SetChannel 22 0
    addChangeHandler Channel22 == 1 backlog SetChannel 20 0; SetChannel 21 0
    return
    
    // === OPEN TO GIVEN PERCENTAGE ===
    openSkylightToTarget:
       Set_Stop
       delay_ms $CH7
    openSkylightToTarget_again:
       delay_ms $CH8
            if $CH10<$CH11 then goto continue_opening
            if $CH10>$CH11 then goto continue_closing
    
       // we are done, we reached our target
       // If we were opening or closing fully, we let the motor
       // run for 3 seconds for the case we are uncalibrated:
       if $CH10==0 then goto calibrate
       if $CH10==100 then goto calibrate
       goto openSkylightFinished
    continue_opening:
            // Unset_Close
       setChannel 3 0
            // Set_Open
       setChannel 1 1
       // increment:
            addChannel 10 1 0 100
       goto openSkylightToTarget_again
    
    continue_closing:
            // Unset_Open
       setChannel 1 0
            // Set_Close
       setChannel 3 1
       // decrement:
            addChannel 10 -1 0 100
       goto openSkylightToTarget_again
    
    calibrate:
       delay_ms 3000
       Set_Stop
       SetChannel 9 $CH10
       return
    openSkylightFinished:
       Set_Stop
       SetChannel 9 $CH10
       return
    
    // === CLOSE ===
    closeSkylight:
       SetChannel 11 0
       goto openSkylightToTarget
    return
    
    // === OPEN ===
    openSkylight:
       SetChannel 11 100
       goto openSkylightToTarget
    return
    
    // === STOP ===
    stopSkylight:
       Set_Stop
       SetChannel 11 $CH10
       SetChannel 9 $CH10
    return
    

Topic summary

The discussion revolves around the desoldering and flashing of the LoraTap SC400W-EU switch board, specifically focusing on the BK7231N and CB3S modules. Users share detailed instructions on how to connect the switch for flashing, including pin configurations for RX, TX, VCC, and GND. Several participants discuss LED control, including how to change LED states and colors through GPIO configurations. The conversation also touches on integrating the switch with Home Assistant, particularly for controlling the open/close duration of shutters and implementing a slider for percentage control. Users explore the possibility of creating a dedicated driver for shutter control and share insights on troubleshooting and building firmware for the device.
Summary generated by the language model.
ADVERTISEMENT