logo elektroda
logo elektroda
X
logo elektroda

[BL602/BL0937] Yet another Smart Socket 20A (but 16A)

flobuljeedom 18693 117

TL;DR

  • An Aubess smart plug from AliExpress uses an SM-028_V1.3 board with a BL602L02 chip and BL0937 power-monitoring IC.
  • The module was flashed with Bouffalo Lab Dev Cube through soldered FTDI232L connections on RX, TX, 3V3, and GND, with BT tied to VCC through 10 kΩ.
  • BL0937 CF1 connects to GPIO3, CF to GPIO14, SEL to GPIO21, LED to GPIO20, relay to GPIO2, and button to GPIO17.
  • Wi‑Fi setup succeeded after flashing, but the web app still shows zero power values, suggesting the BL0937 driver or HAL interrupt handling is still incomplete.
Generated by the language model.
ADVERTISEMENT
📢 Listen (AI):
  • #61 21025455
    miegapele
    Level 16  
    Posts: 173
    Help: 15
    Rate: 29
    I have bl602 with wires soldered, so will be able to test. Probably need some command to trigger infinite loop or something like that for proper testing.
  • ADVERTISEMENT
  • #62 21025472
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14589
    Help: 654
    Rate: 12611
    Helpful post? Buy me a coffee.
  • #63 21025481
    miegapele
    Level 16  
    Posts: 173
    Help: 15
    Rate: 29
    I mean proper test by crashing socket somehow.

    Added after 1 [minutes]:

    Although I remembered one way, calibrating power to zero once made it freeze for me 😂. That also I should fix
  • #64 21025549
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14589
    Help: 654
    Rate: 12611
    I know, I was referring to compilation error.

    I think I can add a "Freeze" driver that will put infinite loops in both "every second timer" and "quick tick". Usage will be:
    
    startDriver Freeze
    
    Helpful post? Buy me a coffee.
  • #65 21025795
    Raufaser
    Level 10  
    Posts: 47
    Help: 3
    Rate: 16
    >>21025444

    I can join testing with a LF686. I am hooking it up to uart at the moment.
  • #66 21025937
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14589
    Help: 654
    Rate: 12611
    Here is PR to download binaries from:
    https://github.com/openshwprojects/OpenBK7231T_App/pull/1158
    It enables watchdog so it should just work. In order to test the watchdog, you need to start the freeze driver that just does:
    Example of source code in the drv_freeze.c file.
    So, once you confirm it just runs, you can do:
    
    startDriver freeze
    

    and it should just reboot with watchdog reason (unless I missed something, @miegapele can double check)
    Helpful post? Buy me a coffee.
  • #67 21025951
    miegapele
    Level 16  
    Posts: 173
    Help: 15
    Rate: 29
    Does not seem to work, unfortunately. It boots, acts all normally, and even OTA works, but the freeze driver freezes everything and no reboot.
    Might be you need to init timer too after all, will test
  • #68 21025971
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14589
    Help: 654
    Rate: 12611
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #69 21025997
    epolet
    Level 6  
    Posts: 12
    Rate: 1
    Hello guys,
    I have such smart socket and successfully uploaded OpenBeken software. I was able to connect to it via web over wifi
    But when I soldered out wires through which it was reprogrammed, assembled it back and put to the socket, I found it doesn't work. Led seemed to sigh and go out. Neither short nor long pressing of button did not help. Soldering up two wires just to CB2S board and connecting to PC brings it to life and to wifi again. So obviously, there some trouble with power on the socket board happened. Strange - it is totally new socket. But ok, as is now.
    I suspect chip between two big capacitors (marked by red question mark on a picture (I took it from previous page, thanks)). But it is impossible to recognize it because of totally unreadable its marking.
    So, maybe anyone could advise me something to bring socket to life? Or, at least, help to recognize that chip.
    Thanks.
    [BL602/BL0937] Yet another Smart Socket 20A (but 16A)
  • #70 21025998
    Raufaser
    Level 10  
    Posts: 47
    Help: 3
    Rate: 16
    After
    startDriver freeze
    I get this on UARL log
    Info:MAIN:Started freeze.
    Info:CMD:[WebApp Cmd-----------------> AABA Request:
        A-MSDU: Permitted
        Block Ack Policy: Immediate Block Ack
        TID: 0
        Number of Buffers: 64
    -----------------> AABA Response:
        A-MSDU: Not Permitted
        Block Ack Policy: Immediate Block Ack
        TID: 0
        Number of Buffers: 8
    -----------------> AABA Request:
        A-MSDU: Permitted
        Block Ack Policy: Immediate Block Ack
        TID: 0
        Number of Buffers: 64
    -----------------> AABA Response:
        A-MSDU: Not Permitted
        Block Ack Policy: Immediate Block Ack
        TID: 0
        Number of Buffers: 8


    Loops infinitely ...

    I don't know if it is important
  • #71 21025999
    miegapele
    Level 16  
    Posts: 173
    Help: 15
    Rate: 29
    I made same change on my branch, seems the same. everything looks frozen, but something still works. I tried forcing disconnection from the wifi, UART log then shows it trying to connect but failing.
    I will try to remove wdt_feed call, seems like something is not correct.
  • #72 21026020
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14589
    Help: 654
    Rate: 12611
    This is suprising @miegapele because wdt_feet is at the end of OnEverySecond call:
    Screenshot of code in Microsoft Visual Studio highlighting the function wdt_feed in the editor.
    So, with infinite loop in driver EverySecond, it should not be reached.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #73 21026021
    Raufaser
    Level 10  
    Posts: 47
    Help: 3
    Rate: 16
    Hi.

    epolet wrote:
    I suspect chip between two big capacitors (marked by red question mark on a picture (I took it from previous page, thanks)). But it is impossible to recognize it because of totally unreadable its marking.


    BP2525

    epolet wrote:
    Soldering up two wires just to CB2S


    There shouldn't be an CB2S in this socket. It should be SM-028_V1.3
  • #74 21026036
    miegapele
    Level 16  
    Posts: 173
    Help: 15
    Rate: 29
    Removing wdt_feet makes it properly boot loop, after it boots in safe mode fine, so maybe worth keeping, it might help with some crashes.
    ALSO that timer init code speeds up time counting by 2 so that part should not be merged.
    there is slightly different time initialization in new sdk, might try that later
  • #75 21026208
    epolet
    Level 6  
    Posts: 12
    Rate: 1
    Raufaser wrote:
    BP2525

    Yep! Thank you.
    I checked it and found it works well - 365V on input and 5.2V on output.
    So the next stop is LM1117. It has 1.8V on input and 0.8V on output.
    Strange. Between BP2525 and LM1117 there is almost nothing.
    According to typical application schematic of BP2525 (let me put it here just in case) the only diode is under suspection
    Application circuit diagram of the BP2525X for power rectification and regulation.
    Ok. Will check it.

    Raufaser wrote:
    There shouldn't be an CB2S in this socket. It should be SM-028_V1.3

    Maybe it is a little bit different version of the socket. It has CB2S :
    CB2S module on a circuit board with visible components. Close-up of a circuit board with a mounted CB2S module marked with RX2, TX2, and a serial number.
  • #76 21026358
    Raufaser
    Level 10  
    Posts: 47
    Help: 3
    Rate: 16
    OK. But then you are either in the wrong thread, or you flashed the wrong firmware.
    CB2S has a BK7231N. This thread is about the BL602. That is a different chip.
  • #77 21026359
    miegapele
    Level 16  
    Posts: 173
    Help: 15
    Rate: 29
    >>21026020
    Yes, strange, I see there is mutex taken on driver code, maybe it runs in parallel somehow if first one is stuck. I wonder how to test this
  • #78 21026489
    zdzihu123
    Level 11  
    Posts: 11
    Rate: 1
    miegapele wrote:
    Could you try without ssdp driver? ssdp generates quite a lot of traffic, might be some problems with that part.

    I tried to run without SSDP driver but no joy. The device froze after circa 11-12 hours. One thing I noticed is that sometimes when it's frozen the button still works and relay can be switched manually. So it's quite inconsistent and there is no repeatable pattern.

    Great work with watchdog everyone. If there are any other troubleshooting steps I could help with, please let me know.
  • #79 21026582
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14589
    Help: 654
    Rate: 12611
    @miegapele can you check is it ok to merge?
    https://github.com/openshwprojects/OpenBK7231T_App/pull/1158
    I disabled extra timer

    @zdzihu123 well, if button is still working then I don't think that watchdog can help much... buttons are handled in the quick tick update. Hmm.
    @miegapele what do you think?
    I've seen similiar issue once or twice. It was caused by a strange TCP socket lock causing memory leak. The free memory amount was going down and memory was not freed. Finally the HTTP server code was not able to alloc new buffers for TCP connections, here:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/src/httpserver/http_tcp_server.c
    If HTTP GET malloc is failing ,then device will not be reachable via HTTP but will still work when you press physical button.
    See this fragment:
    HTTP server code snippet highlighting memory allocation.
    Maybe we could change the server behaviour to be more bulletproof? Maybe we could prealloc, let's say, 4 buffers and keep shuffling them? But that means we will be able to only handle 4 TCP connections at all... removing the "malloc" call per HTTP packet would make HTTP server immune to "malloc returns 0" problem.
    There are of course some problems with that. For example, this code is shared between all platforms (well, except windows simulator), so any change there would require extensive testing. Unless we #ifdef that just for BL602...
    Thoughts?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #80 21027067
    miegapele
    Level 16  
    Posts: 173
    Help: 15
    Rate: 29
    I did a lot of playing with watchdog, and it does work in the end, so should be merged.
    I tested the pull request branch, it works, and OTA after that works too, so should be same to merge.
    Issue was our Freeze driver was too aggressive so that it made even wdt timer not work somehow. I removed infinite loop code from Freeze_RunFrame, and modified to Freeze_OnEverySecond to do some useless calculations in infinite loop, and then it reboots as expected, and after reboot reason is shown as software watchdog.

    As for freezes, I saw one while playing with wifi networks to tests one bug, but that socket runs older version.
    It's also possible to freeze socket by DDOSing it with lots of http requests, but memory does not appear to be an issue to me, as far as I saw it rarely decreased much, something else looks to cause crash.
    Also trying to use ping watchdog might be useful in case physical button works, but socket is not reachable through http. the same trying to disconnect socket from router if it's there. If it recovers, might indicate connection issue
  • #81 21027150
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14589
    Help: 654
    Rate: 12611
    Thank you, sure, so it's merged now:
    https://github.com/openshwprojects/OpenBK7231...mmit/e0f7506bf2455653c51af8b5d19d59c7876ebe42
    Can you submit your new "freeze" functions? Thanks!
    Helpful post? Buy me a coffee.
  • #82 21027185
    zdzihu123
    Level 11  
    Posts: 11
    Rate: 1
    Thank you guys, I installed .528 and will give it a shot tomorrow.

    EDIT: Just out of curiosity, is that amount or events registered by BL0937 (17390 changes in 20 min) normal? Or may it be the source of my problem?
    User interface monitoring energy data with information on skipped changes.
  • #83 21027408
    miegapele
    Level 16  
    Posts: 173
    Help: 15
    Rate: 29
    That counter is fine, it records big numbers
  • #84 21029399
    zdzihu123
    Level 11  
    Posts: 11
    Rate: 1
    miegapele wrote:
    As for freezes, I saw one while playing with wifi networks to tests one bug, but that socket runs older version.
    It's also possible to freeze socket by DDOSing it with lots of http requests, but memory does not appear to be an issue to me, as far as I saw it rarely decreased much, something else looks to cause crash.
    Also trying to use ping watchdog might be useful in case physical button works, but socket is not reachable through http. the same trying to disconnect socket from router if it's there. If it recovers, might indicate connection issue

    As soon as I stopped messing with both settings page and webapp I was able to reach 48 hours uptime (and still counting). All I did was fully reflash the latest fw and stop interacting with the socket.

    If the crash happens again I'll investigate further.
  • #85 21029456
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14589
    Help: 654
    Rate: 12611
    That counter could be hidden, it's mostly only for developers and for testing. It's related to the system of MQTT publish data culling (so the same data is not send too often).
    Helpful post? Buy me a coffee.
  • #86 21030199
    zdzihu123
    Level 11  
    Posts: 11
    Rate: 1
    Today at 05:00 plug was properly restarted by watchdog:

    Quote:
    Reboot reason: BL_RST_SOFTWARE_WATCHDOG


    The only thing that's still off with BL602 seems to be internal temperature reported at 65-71c.
  • #87 21030314
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14589
    Help: 654
    Rate: 12611
    So we have a progress and watchdog works, that's very good! Now we still need to figure out what goes wrong... maybe we can try publishing the free memory size via MQTT to determine whether the issue is related to that?

    @zdzihu123 that internal temperature is not even calibrated, I am not sure if we can use it as a reliable measurement...
    Helpful post? Buy me a coffee.
  • #88 21032468
    flobuljeedom
    Level 8  
    Posts: 17
    Help: 1
    Rate: 116
    Same here : Reboot reason: BL_RST_SOFTWARE_WATCHDOG
    All 5 devices are still available. Nice!
  • #89 21064323
    Raufaser
    Level 10  
    Posts: 47
    Help: 3
    Rate: 16
    @p.kaczmarek2 From time to time the Watchdog triggers a reboot. When it does, the relay switches off. That is pretty annoying. Is there a way to retain the relay state when rebooting the socket?
  • #90 21064535
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14589
    Help: 654
    Rate: 12611
    Have you tried the classic retain approach, just setting -1 start state in Startup tab of OpenBeken?
    Helpful post? Buy me a coffee.
📢 Listen (AI):

Topic summary

✨ The discussion centers on a Smart Plug purchased from AliExpress, identified as an Aubess device with an SM-028_V1.3 board featuring a BL602L02 chip and BL0937 energy metering IC. Users successfully opened and flashed the device using FTDI232L and Bouffalo Lab Dev Cube tools. Challenges include incomplete BL0937 interrupt counter support, pin mapping uncertainties, and unstable OTA firmware updates on the BL602 platform. Various firmware builds and pull requests were tested to improve OTA reliability, including reducing binary size and modifying flash erase procedures. Watchdog timer implementation was a major focus to address device freezes and unresponsiveness, with a watchdog driver added and tested to enable automatic reboot on crashes. Some users reported inconsistent device freezes, sometimes with partial functionality (e.g., button still working), suggesting possible TCP socket or memory leaks. Discussions also covered relay default state on power-up, with solutions involving startup commands or hardware modifications to maintain relay state through reboots. WiFi reception issues were noted, attributed to channel congestion rather than hardware faults. Additional topics included difficulties opening the device casing without damage, and clarifications on device identification to avoid confusion with Zigbee models. The thread also references related devices and firmware versions, with community contributions to device templates and driver improvements. Overall, the conversation highlights ongoing development and troubleshooting efforts to stabilize BL602-based smart sockets with BL0937 metering, improve OTA updates, implement watchdog recovery, and enhance user experience with relay control and device reliability.
Generated by the language model.

FAQ

TL;DR: "All 5 devices are still available" after BL602 software-watchdog support. This FAQ is for BL602/BL0937 smart-plug owners who need one practical answer set for UART flashing, GPIO mapping, zero readings, OTA failures, and freeze recovery on SM-028_V1.3-class sockets. [#21032468]

Why it matters: These plugs can look identical outside but differ in button GPIO, OTA behavior, and crash recovery, so one wrong assumption can leave power metering at 0 or make the socket freeze.

Variant MCU/module Common button GPIO Best flashing path Typical issue in thread
SM-028_V1.3 smart plug BL602L02 17 UART + Bouffalo Dev Cube BL0937 stayed at 0 before interrupt support
RMC021 / similar BL602 plug BL602 / SM-028_V1.3 22 UART + OpenBeken/OpenBL602 Random freezes after minutes or hours
CB2S plug BK7231N Varies Use BK7231N firmware, not BL602 Wrong-thread / wrong-firmware risk
ESP8266 Tuya plug ESP8266 Varies OTA only if exploit works; otherwise UART Tuya-convert patched on older units

Key insight: The turning point was not the pin template alone. BL602 plugs started reporting BL0937 values reliably only after BL602-specific interrupt handling worked, and long-term usability improved further once chunked OTA erase and the software watchdog were added.

Quick Facts

  • The first confirmed SM-028_V1.3 wiring mapped BL0937 CF1 to GPIO3, CF to GPIO14, SEL to GPIO21, relay to GPIO2, LED to GPIO20, and button to GPIO17. [#20856171]
  • A later RMC021 template kept relay on GPIO2, CF1 on GPIO3, CF on GPIO14, LED_n on GPIO20, and SEL on GPIO21, but moved the button to GPIO22. [#21025378]
  • One BL602 OTA log showed the firmware partition at offset 0x000d8000 with size 0x00088000 or 544 Kbytes, while the incoming OTA size shown was 557056 bytes. [#20921739]
  • One power-stage repair check measured about 365 V on the BP2525 input, 5.2 V on its output, then only 1.8 V into LM1117 and 0.8 V out, indicating a board-side power problem rather than firmware alone. [#21026208]

How do I flash an SM-028_V1.3 smart plug with a BL602L02 over UART using an FTDI adapter and Bouffalo Lab Dev Cube?

Wire it as a 3.3 V UART job and boot the BL602 with BT pulled high through 10 kΩ. 1. Solder RX↔TX, TX↔RX, 3V3↔VCC, and GND↔GND between SM-028_V1.3 and the FTDI232L. 2. Connect BT to VCC through a 10 kΩ resistor. 3. Flash with Bouffalo Lab Dev Cube, then disconnect the wires, reassemble the plug, and enter Wi-Fi credentials in the web interface after reboot. [#20856171]

What GPIO template works for the BL602/BL0937 Smart Socket 20A or RMC021 plug, including relay, LED, button, CF, CF1, and SEL pins?

A working RMC021 template uses relay on GPIO2, BL0937 CF1 on GPIO3, CF on GPIO14, LED_n on GPIO20, SEL on GPIO21, and button on GPIO22. The startup command shown was startDriver BL0937; startDriver NTP; startDriver SSDP. That mapping produced working switching and metering on a BL602 socket sold as an eWeLink Smart WiFi Socket 20A with SM-028_V1.3 hardware. [#21025378]

Why do BL0937 readings stay at 0 on a BL602 smart socket even after flashing OpenBeken and setting the pin mapping?

They stay at 0 when BL602 does not count the BL0937 pulse interrupts yet. The thread explicitly states that the BL0937 interrupt counter on BL602 was still missing, so the web app showed only zeroes even after a correct-looking pin map and driver startup. In short, the template alone was not enough before BL602-side interrupt support existed. [#20858308]

What is the BL0937 energy metering chip, and how do its CF, CF1, and SEL pins interact with a BL602 in OpenBeken?

"BL0937" is an energy-metering IC that outputs pulse signals for electrical measurements, using separate logic pins instead of a digital bus. In this plug, CF1 went to GPIO3, CF to GPIO14, and SEL to GPIO21 on the BL602. OpenBeken then used those pulse lines plus the selector line to derive voltage, current, and power data from the socket hardware. [#20856171]

Why was BL0937 support on BL602 initially not working, and what interrupt-related changes were needed to make it report values?

It initially failed because the BL602 driver path was not actually counting incoming BL0937 pulses. The key change was to make the BL602 interrupt handlers fire for CF and CF1 so g_vc_pulses and g_p_pulses increased. The thread also points to BL602 GPIO interrupt setup, including hal_gpio_register_handler(...), and questions whether those handlers were being called at all. [#20919426]

Which button GPIO should I use on these BL602/BL0937 plugs when one board uses GPIO17 and another uses GPIO22?

Use the GPIO that matches your exact PCB revision, and switch to GPIO22 if GPIO17 leaves the button dead. A later user confirmed that after updating to OpenBL602_1.17.756_OTA.bin.xz.ota, the metering values were correct but the physical button still failed until Btn;1 was moved from GPIO17 to GPIO22. That makes GPIO22 the right fix for at least one later Tuya variant. [#21274357]

What is a software watchdog on BL602, and how does it help recover a smart plug that freezes and stops responding to web, ping, and MQTT?

"Software watchdog" is a recovery mechanism that reboots the MCU when normal code stops servicing a timer, giving a frozen device a chance to return without manual power cycling. In the thread, BL602 plugs later restarted with reboot reason BL_RST_SOFTWARE_WATCHDOG, and users reported that this kept previously freezing devices available. It does not cure the root bug, but it changes a hard freeze into an automatic reboot. [#21030199]

How can I make a BL602 smart plug restore the relay state after reboot or power loss using OpenBeken startup settings?

Set the relay start state to -1 in the OpenBeken Startup tab. That is the thread’s recommended retain-style setting for restoring the previous relay state after a reboot. It does not force permanent ON, but it tells the plug to come back in the last known state instead of always defaulting OFF. [#21064535]

Why does a BL602 plug still briefly cut power during a watchdog reboot even when the relay start state is retained?

It cuts power because the relay physically drops during the reboot window. One user measured the interruption as about half a second, and the reply was direct: there is no way to avoid that power interruption during this kind of restart. Retaining the start state restores the relay afterward, but it cannot keep mains continuous while the MCU reboots. [#21065227]

What caused unreliable OTA updates on BL602, and how did chunked flash erase improve OpenBeken OTA flashing stability?

The main OTA problem was slow flash erase blocking the HTTP update flow. A developer reported that once erase changed to chunks, OTA "now works very well." Earlier failures often stalled after receiving and writing a 253-byte chunk, which matched the theory that long erase operations were starving the connection rather than the image simply being too large. [#20944841]

Why does SetupEnergyStats make some BL602 smart sockets freeze exactly after the configured interval, and what should I check to debug it?

It points to a repeatable timer-triggered fault, not a random network issue. One user showed that SetupEnergyStats 1 60 60 froze the device after 59 seconds, while SetupEnergyStats 1 70 60 froze it after 69 seconds. First remove the command from Startup, then run it once manually, and capture the last serial or web log before the exact freeze time. [#20944817]

How can I troubleshoot a BL602 socket that freezes after minutes or hours even with only basic drivers like BL0937, NTP, or SSDP enabled?

Start by changing one variable at a time and watching whether the physical button still works. 1. Check free heap over time. 2. Note whether HTTP dies while the button still toggles the relay. 3. Test with fewer network-facing features to isolate the trigger. The thread suggests a possible TCP/HTTP allocation problem on BL602 when button control still works but the web server no longer answers. [#21026582]

BL602 vs BK7231N or ESP8266 in smart plugs — what differences matter for flashing method, stability, and firmware choice?

The chip family decides the firmware and often the flashing path. A CB2S module is BK7231N, not BL602, so BL602 firmware is the wrong choice for that hardware. ESP8266 plugs are different again; in the same discussion family, patched OTA routes left users needing soldered UART access. Verify the module name first, because identical-looking plugs can belong to completely different firmware ecosystems. [#21026358]

What is SSDP in OpenBeken, and how could SSDP-related traffic contribute to crashes or responsiveness issues on BL602 devices?

"SSDP" is a network discovery protocol that advertises devices on the local LAN, generating repeated multicast traffic during normal operation. In the thread, a developer recommended disabling the SSDP driver first because it "generates quite a lot of traffic," and that traffic was considered a plausible stress point for BL602 stability testing. It was not the only suspected cause, but it was an early isolation step. [#21025388]

What’s the safest way to open Aubess, Elivco, or LSPA9-style smart plugs without destroying the plastic housing before UART flashing?

Use a clamp-style twist method, or a pipe wrench if you do not have clamps. The thread explicitly recommends that approach as simpler and less destructive than random prying. It also notes that LSPA9-family plugs vary a lot in glue strength, so some units open easily while others feel almost plastic-welded. Slow, even force is safer than screwdriver levering. [#21139347]
Generated by the language model.
ADVERTISEMENT