logo elektroda
logo elektroda
X
logo elektroda

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

flobuljeedom 18696 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):
  • #31 20924028
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14589
    Help: 654
    Rate: 12611
    @miegapele do you have any drivers running, etc? PowerSave? Anything?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #32 20925348
    miegapele
    Level 16  
    Posts: 173
    Help: 15
    Rate: 29
    It's standard bl602 socket with bl0937 driver and mqtt, PowerSave was not enabled, nothing else. Added/removed logging for OTA/delaysat various places, did not make a difference, still update is inconsistent.
  • #33 20925372
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14589
    Help: 654
    Rate: 12611
    If you are willing to investigate the issue futher, I would suggest getting version from the January 2023 and checking if it also works in unreliable manner:
    Screenshot of commit history in a repository, showing changes made on February 2 and January 22, 2023.
    I introduced BL602 in January 2023 and as far as I remember it worked well. So, I would suggest you to flash the Feb 2023 build and try to narrow down when it began to break.... but take care, keep your UART ready, if you are not sure, then don't do it, I don't want you to brick your device or something.

    EDIT:wait, that BL0937 driver does a lot of interrupts, have you tried to OTA without BL0937??
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #34 20926491
    miegapele
    Level 16  
    Posts: 173
    Help: 15
    Rate: 29
    I will try to test that over the weekend
  • #35 20932072
    miegapele
    Level 16  
    Posts: 173
    Help: 15
    Rate: 29
    Older version maybe helps with flashing, but still not bullet proof. I tried 15.455 and then installing 17.419, worked better, but still sometimes failed. And 15.455 was even bigger than now. I'll try to implement ota_progress functions, maybe that will help.
  • #36 20932561
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14589
    Help: 654
    Rate: 12611
    So what has changed? There isn't much that can affect OTA, is there?

    Are we doing some more calculations in the background that I am not aware of? Or did we change something related to WiFi?

    Here is our SDK repo, btw:
    https://github.com/openshwprojects/OpenBL602
    Not much changes here either...

    I've got one BL602 (or LF?) strip from @divadiow some time ago, I will do some testing on my side once I get some time
    Helpful post? Buy me a coffee.
  • #37 20944817
    flobuljeedom
    Level 8  
    Posts: 17
    Help: 1
    Rate: 116
    Something strange happens when I set "SetupEnergyStats".
    The outlet does not respond at all after the time set in SetupEnergyStat: Mqtt disconnected, no ip ping, and the button doesn't work at all.
    If I set "SetupEnergyStats 1 60 60", it freeze after 59 seconds.
    If I set "SetupEnergyStats 1 70 60", it freeze after 69 seconds...

    Here is the last log before it freezes:
    Code: Text
    Log in, to see the code
  • ADVERTISEMENT
  • #38 20944841
    miegapele
    Level 16  
    Posts: 173
    Help: 15
    Rate: 29
    Made a fix for OTA issues. It was slow erase which caused issues for http connection, once I changed so that it erases in chunks, it now works very well. see here.
  • #39 20945523
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14589
    Help: 654
    Rate: 12611
    @flobuljeedom does it happen every time? Maybe it's a flash vars problem?

    @miegapele very good job, I am unable to test it on my side at the moment but I think I will just merge it anyway, the fix makes sense
    Helpful post? Buy me a coffee.
  • #40 20946008
    flobuljeedom
    Level 8  
    Posts: 17
    Help: 1
    Rate: 116
    @p.kaczmarek2
    I placed the command setupenergystart on startup commandfield, so each time it boots, the device freezes after the delay. And I have to unplug it.
    If I remove setupenergystart from startup command, the device doesn’t freeze.
    If I enter a unique command setupenergystart 1 60 60, then the device freezes 59 seconds later.
    What could I do with flash vars to help out?
  • #41 20963204
    flobuljeedom
    Level 8  
    Posts: 17
    Help: 1
    Rate: 116
    This socket stopped working after some time: no ping, no AP, no MQTT, and the side button refuses to work either.

    I have 5 sockets freshly flashed plugged and working fine for a few days.
    And then today, I had to unplug them and re-plug them to make them work again.
    Anyone else noticed the same issue?
  • #42 20963640
    miegapele
    Level 16  
    Posts: 173
    Help: 15
    Rate: 29
    All 5 crashed at the same time? Could it be that something was sent via matt which was not handled well?
  • #43 20964147
    flobuljeedom
    Level 8  
    Posts: 17
    Help: 1
    Rate: 116
    They freezed on different hours the same day.
    From 9AM to 2PM the same day.
    Each uptime when they stoped working: 39940, 42000, 155780, 122800)
  • #44 20964450
    miegapele
    Level 16  
    Posts: 173
    Help: 15
    Rate: 29
    I have not seen such issues but I only have one socket and experimented a lot. So I don't know what to tell.
  • #45 20964462
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14589
    Help: 654
    Rate: 12611
    I would suggest to first start observing the heap size.

    Futhermore, we may need to enable watchdog on BL602 in the same manner as we did on BK7231.
    Helpful post? Buy me a coffee.
  • #46 20972269
    flobuljeedom
    Level 8  
    Posts: 17
    Help: 1
    Rate: 116
    Devices worked fine for days, until today, one just gets unresponsive.
    This is the last values it send in Mqtt:
    - uptime 488104
    - freeheap 105400
    - Build on Feb 9 2024 16:36:16 version 1.17.457
  • #47 20973554
    flobuljeedom
    Level 8  
    Posts: 17
    Help: 1
    Rate: 116
    >>20964462
    If I'm correct, enabling watchdog allows the device to reconnect to wifi when connection is lost.
    The side button (to activate the relay) should work either way.

    But that is not the case here, I think.
    The device is completely inoperative: the side button doesn't work at all.
    If the LED/relay was active, the relay/LED stays active.
  • #48 20974305
    miegapele
    Level 16  
    Posts: 173
    Help: 15
    Rate: 29
    Watchdog is intended to restart device if it crashes. So it seems it should help your case. But it's not implemented yet.
  • #49 20974528
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14589
    Help: 654
    Rate: 12611
    I was referring to the MCU watchdog, hardware one. There is also an OBK mechanism called "IP Ping watchdog" but it's something else totally.

    We need to look into BL602 watchdog.

    Added after 2 [hours] 10 [minutes]:

    Some related search results:
    https://github.com/search?q=repo%3Aopenshwprojects%2FOpenBL602%20WATCHDOG&type=code

    I can see a function - WDT_Disable - but where is enable?

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

    https://github.com/openshwprojects/OpenBL602/...components/joylink_adapter/example/test.c#L44
    Helpful post? Buy me a coffee.
  • #50 21004198
    Raufaser
    Level 10  
    Posts: 47
    Help: 3
    Rate: 16
    I think i got the same socket:
    White smart plug with power button on a white wall. Image of a smart plug packaging and device with a voltage range of 100-250V.

    I have some high res pics of the internals:
    Close-up of a circuit board with electronic components. Close-up of a circuit board labeled SM-028_V1.3, showing electronic components. Close-up of a printed circuit board of an electronic device.

    I took the pin configuration as described in the first post. It works until now.

    This device is not in the device list when filtering for BL602. Maybe something is missing?
  • #51 21014474
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14589
    Help: 654
    Rate: 12611
    Why do you think it's missing? How to replicate the problem?
    This thread is listed in devices.json:
    A JSON code snippet with information about the Smart Socket 20A device.
    Or are you referring to other model?
    Screenshot of an IoT device list featuring a highlighted Tuya smart socket.
    See: https://openbekeniot.github.io/webapp/devicesList.html
    Helpful post? Buy me a coffee.
  • #52 21025349
    zdzihu123
    Level 11  
    Posts: 11
    Rate: 1
    I have similar BL602/BL0937 (module: SM-028_V1.3) RMC021 20A smart socket and also am facing freezing issue. It stops responding after some time (sometimes 15 min, sometimes 2-3h). When it's frozen I cannot access web gui, no ping, button not working.

    Build on Mar 28 2024 15:26:36 version 1.17.523
    Short name: RMC021, Chipset BL602

    I am going to test it with BL0937 driver disabled. Please point me to next troubleshooting steps.
  • #53 21025367
    miegapele
    Level 16  
    Posts: 173
    Help: 15
    Rate: 29
    What drivers do you have. I had it running for few weeks without issue, with bl0937 and mqtt. Maybe it receives a lot of mqtt traffic from something? There is reports rhat crashes bl602 bulbs.
    I can look to add watchdog.
  • #54 21025378
    zdzihu123
    Level 11  
    Posts: 11
    Rate: 1
    I didn't mess with configs to avoid issues, so it's pretty vanilla (pretty much flashed the firmware and set gpios):

    Drivers: startDriver BL0937; startDriver NTP; startDriver SSDP

    {
      "vendor": "eWeLink",
      "bDetailed": "0",
      "name": "eWeLink Smart WiFi Socket 20A",
      "model": "RMC021",
      "chip": "BL602",
      "board": "SM-028_V1.3",
      "flags": "1024",
      "keywords": [
        "BL602",
        "socket",
        "BL0937"
      ],
      "pins": {
        "2": "Rel;1",
        "3": "BL0937CF1;0",
        "14": "BL0937CF;0",
        "20": "LED_n;1",
        "21": "BL0937SEL;0",
        "22": "Btn;1"
      },
      "image": "https://obrazki.elektroda.pl/8095216400_1711786208.jpg",
      "wiki": "https://www.elektroda.com/rtvforum/topic4020634.html"
    }


    It's not connected to HA, no mqqt traffic in network (for now I have only 1 or 2 standalone smart plugs connected to wifi, no HA connected to this wifi network).

    Electronic module of a smart WiFi socket with discrete components on a red circuit board. Close-up of the internal electronic components of an eWeLink smart plug on a red PCB with the designation SM-028_V1.3. Close-up of a red circuit board interior with various electronic components.
  • #55 21025388
    miegapele
    Level 16  
    Posts: 173
    Help: 15
    Rate: 29
    Could you try without ssdp driver? ssdp generates quite a lot of traffic, might be some problems with that part.
  • #56 21025394
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14589
    Help: 654
    Rate: 12611
    I think the first thing we need is Watchdog. It will solve all consequences of the potential freeze.
    https://github.com/search?q=repo%3Aopenshwprojects%2FOpenBL602%20watchdog&type=code
    We already have reboot reason on BL602:
    Screenshot from Visual Studio showing source code for the BL602 platform.
    It seems the most promising WDT code is here:
    https://github.com/openshwprojects/OpenBL602/...a28/components/hal_drv/bl602_hal/bl_wdt.c#L35
    Code: C / C++
    Log in, to see the code

    Max timer is (65535/16) - about 4095
    So basically, first call:
    
    bl_wdt_init(1000);
    

    In the:
    and then, in driver quick tick (I guess?) call:
    
    bl_wdt_feed();
    
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #57 21025413
    miegapele
    Level 16  
    Posts: 173
    Help: 15
    Rate: 29
    Yes, we could add watchdog driver, looks very simple to do
  • #58 21025426
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14589
    Help: 654
    Rate: 12611
    @miegapele shall I create a PR to build binaries for testing or would you like to do that?
    Helpful post? Buy me a coffee.
  • #59 21025430
    miegapele
    Level 16  
    Posts: 173
    Help: 15
    Rate: 29
    Please do, I can only do that in the evening
  • #60 21025444
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14589
    Help: 654
    Rate: 12611
    Sure, here is my first attempt, let's see if it builds, I guess I will need to add header:
    https://github.com/openshwprojects/OpenBK7231T_App/pull/1158
    Please review it @miegapele , how do we even test that? Is there someone with UART flasher hooked up to BL602? This may be risky for your device if not working correctly.
    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