logo elektroda
logo elektroda
X
logo elektroda
Dostępna jest polska wersja

Czy wolisz polską wersję strony elektroda?

Nie, dziękuję Przekieruj mnie tam

TOB9-63M Smart Switch Freezes After Adding SetStartValue Command with OpenBK

Exkilla 1320 11
ADVERTISEMENT
  • #1 20895551
    Exkilla
    Level 2  

    Hello! I bought the "TOB9-63M" WIFI Smart Switch Energy Meter Relay. I made the backup and flashed "OpenBK7231N_QIO_1.17.391.bin". Everything worked fine until I added "SetStartValue 1 1;" to the startup command line. The device hangs after restart and the LEDs light up a little. If I re-flash the OpenBK firmware - nothing changes. It still hangs. If I restore the original firmware (Tuya) from the backup - the relay works fine. Please tell me what the problem is and how to solve it?
  • ADVERTISEMENT
  • Helpful post
    #2 20896320
    p.kaczmarek2
    Moderator Smart Home
    I can check that SetStartValue command, but can you show your full script?

    Futhermore, why are you using this command? It should be possible to do the same from GUI...

    Maybe you are using it in some kind of way that was not predicted by us at the development stage.

    Alternatively, you can just put a setChannel call in your script and set channel to 1, it will work in a very similiar way... or maybe even better, if that's TuyaMCU device
    Helpful post? Buy me a coffee.
  • #3 20896946
    Exkilla
    Level 2  

    The final startup command was something like:

    backlog SetStartValue 1 1; startDriver NTP; ntp_setServer 217.147.223.78; ntp_timeZoneOfs 2; startDriver BL0942; SetupEnergyStats 1 60 5;

    But the problem is that even if I now rewrite OpenBK firmware with clean OBK settings - device hangs. Relay works only if I flash original firmware which I dumped before flashing OpenBK.
  • ADVERTISEMENT
  • Helpful post
    #4 20896962
    p.kaczmarek2
    Moderator Smart Home
    Which flashing tool are you using to write firmware?

    Our flasher has option to clear command line, I think.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #5 20896988
    Exkilla
    Level 2  

    I use "BK7231Flasher". Command line is clear but the device doesn't boot with OpenBK.
  • Helpful post
    #6 20897089
    p.kaczmarek2
    Moderator Smart Home
    Ok, so what does the debug log output on TX2 say?
    Helpful post? Buy me a coffee.
  • #7 20897368
    Exkilla
    Level 2  
    Thanks for the tip. I soldered the wire to TX2 and checked the console output. It turned out that the device was booting. For some reason the pin assignment was simply reset after changing startup command and restart the device.

    For now, I have another problem. I set these pins settings:

      "pins": {
        "9": "LED;1",
        "15": "WifiLED;1",
        "17": "Btn_Tgl_All;1",
        "24": "BridgeFWD;1",
        "26": "BridgeREV;1"
      },

    If I press "Toggle 1" button in the web-interface - I hear click and relay changes the state. But if I press the button on the device - nothing happens. Flag 41(Ignore all button events) isn't active. What can be wrong?
  • ADVERTISEMENT
  • #8 20897584
    p.kaczmarek2
    Moderator Smart Home
    Is there some information in log when you press the button on the device?
    Helpful post? Buy me a coffee.
  • #10 20906463
    Exkilla
    Level 2  

    I checked "src" of firmware. "Btn_Tgl_All" works with relays only. But we have type "Bridge".

    void CHANNEL_DoSpecialToggleAll() {
    	int anyEnabled, i;
    	anyEnabled = 0;
    	for (i = 0; i < CHANNEL_MAX; i++) {
    		if (CHANNEL_IsPowerRelayChannel(i) == false)
    			continue;
    		if (g_channelValues[i] > 0) {
    			anyEnabled = true;
    		}
    	}
    	for (i = 0; i < CHANNEL_MAX; i++) {
    		if (CHANNEL_IsPowerRelayChannel(i)) {
    			CHANNEL_Set(i, !anyEnabled, 0);
    		}
    	}
    }

    bool CHANNEL_IsPowerRelayChannel(int ch) {
    	int i;
    	for (i = 0; i < PLATFORM_GPIO_MAX; i++) {
    		if (g_cfg.pins.channels[i] == ch) {
    			int role = g_cfg.pins.roles[i];
    			// NOTE: do not include Battery relay
    			if (role == IOR_Relay || role == IOR_Relay_n) {
    				return true;
    			}
    		}
    	}
    	return false;
    }

    Maybe need to replace line in the function "CHANNEL_IsPowerRelayChannel" from:
    if (role == IOR_Relay || role == IOR_Relay_n) {
    to:
    if (role == IOR_Relay || role == IOR_Relay_n || role == IOR_BridgeForward || role == IOR_BridgeReverse) {

    Is it correct?

    P.S. We can't just change the type to "Relay" because device is getting very hot (mentioned in another topic about this device). Bistable relay is used.
  • #11 20906548
    p.kaczmarek2
    Moderator Smart Home
    That's very good finding, I've applied your fix. Please update and retry.
    Helpful post? Buy me a coffee.
  • #12 20906660
    Exkilla
    Level 2  
    It works fine now! Thanks! =)

Topic summary

✨ The discussion revolves around issues faced with the TOB9-63M WiFi Smart Switch after adding the "SetStartValue 1 1;" command to the startup script while using the OpenBK firmware. The device freezes upon restart, and re-flashing the firmware does not resolve the issue, while the original Tuya firmware works fine. Users suggest checking the full script and using alternative commands. The author later discovers that the pin assignments reset after changing the startup command. Despite setting the pins correctly, the physical button on the device does not respond, leading to further investigation into the firmware's handling of button events. A proposed fix involves modifying the firmware code to recognize the device's bridge role, which ultimately resolves the issue.

FAQ

TL;DR: In Jan 2024, a firmware fix added Bridge toggle support; "Please update and retry." If OpenBK appears frozen after SetStartValue, verify pins and check TX2 logs. [Elektroda, p.kaczmarek2, post #20906548]

Why it matters: This FAQ helps OpenBK users on BK7231N TOB9-63M resolve boot issues and restore button control after startup changes.

Quick Facts

Why does my TOB9-63M seem to freeze after adding SetStartValue to startup?

It often still boots, but the pin assignment can reset after a startup command change. That leaves controls unassigned, so the UI appears dead. Confirm activity over TX2, then reapply pin roles to restore control. Reconfigure LED, button, and bridge coil pins if they cleared. [Elektroda, Exkilla, post #20897368]

How can I recover if OpenBK won’t boot after a startup script change?

Use the project flasher’s option to clear the command line, then reboot. If the board still misbehaves, reflash OpenBK and reconfigure pins from scratch. This removes a bad startup command that can block normal initialization. [Elektroda, p.kaczmarek2, post #20896962]

How do I capture OpenBK debug logs on this device?

Use the TX2 UART output to see boot and button events. "Ok, so what does the debug log output on TX2 say?" Follow that hint: attach a USB‑UART to TX2, open a console, and power cycle to read logs. 1) Connect TX2. 2) Open serial console. 3) Reboot and observe. [Elektroda, p.kaczmarek2, post #20897089]

Why doesn’t the physical button toggle even though the web Toggle works?

Earlier builds only toggled Relay roles, so Btn_Tgl_All ignored Bridge coils. The maintainer merged a fix to include BridgeForward/Reverse. Update to a newer build and retest. "Please update and retry." After updating, button toggling works with bistable relays. [Elektroda, p.kaczmarek2, post #20906548]

What pin roles should I assign for a bistable relay on TOB9-63M?

Map the coils to BridgeFWD and BridgeREV, and the front button to Btn_Tgl_All. Example mapping seen: LED on pin 9, WifiLED on 15, Btn_Tgl_All on 17, BridgeFWD on 24, BridgeREV on 26. With the fix, Btn_Tgl_All will toggle the bridge channels. [Elektroda, Exkilla, post #20897368]

Is it safe to map a bistable relay as a standard Relay?

No. The device uses a latching (bistable) relay. Mapping it as a normal Relay can drive a coil continuously and cause heating. Keep roles as BridgeForward/BridgeReverse for safe operation. [Elektroda, Exkilla, post #20906463]

Can I avoid SetStartValue and still set power state on boot?

Yes. Use a script line with setChannel to initialize the desired state, or configure this via the GUI. The maintainer recommended setChannel as a simpler, safer alternative to SetStartValue. [Elektroda, p.kaczmarek2, post #20896320]

Which OpenBK build contains the Bridge toggle fix for the button?

A fix was applied by the maintainer in mid‑January 2024. Update to a newer OpenBK build than that date to include Btn_Tgl_All support for Bridge roles. [Elektroda, p.kaczmarek2, post #20906548]

What do these log lines mean: Button_OnInitialPressDown and key_short_press?

They indicate the firmware detected a valid button event. The sample shows GEN:17, meaning channel 17 received a short press. If nothing toggles afterward, your mapping or toggle logic is wrong. Update firmware or correct pin roles. [Elektroda, Exkilla, post #20904666]

My device looks bricked, but stock Tuya firmware works. What does that indicate?

Hardware is fine. Your OpenBK configuration is mis-set or incompatible. Restore OpenBK with clean settings, then correctly remap pins. You can also keep Tuya stock if you prefer stability. [Elektroda, Exkilla, post #20895551]

What tool should I use to flash or reset a BK7231N device?

BK7231Flasher successfully wrote OpenBK in this case. If the device still fails after flashing, revisit your configuration or restore your Tuya backup to regain function. [Elektroda, Exkilla, post #20896988]

How should I configure NTP and energy stats on OpenBK for this device?

An example backlog sets NTP server 217.147.223.78, timezone offset 2, starts BL0942, then SetupEnergyStats 1 60 5. The 60 denotes a 60‑second energy statistics window. Adjust these to your region and reporting needs. [Elektroda, Exkilla, post #20896946]

Edge case: It boots but the UI seems dead. How can I confirm and fix it?

Connect to TX2 and check the console. If logs show normal boot, your pins likely reset. Reassign LED, button, and Bridge roles via console or web once reachable. The device should resume normal control. [Elektroda, Exkilla, post #20897368]
ADVERTISEMENT