logo elektroda
logo elektroda
X
logo elektroda

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

flobuljeedom 18036 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: 14387
    Help: 650
    Rate: 12308
    @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: 14387
    Help: 650
    Rate: 12308
    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.
  • #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: 14387
    Help: 650
    Rate: 12308
    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
  • #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.
  • ADVERTISEMENT
  • #39 20945523
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14387
    Help: 650
    Rate: 12308
    @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?
  • ADVERTISEMENT
  • #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: 14387
    Help: 650
    Rate: 12308
    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: 14387
    Help: 650
    Rate: 12308
    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.
  • ADVERTISEMENT
  • #50 21004198
    Raufaser
    Level 10  
    Posts: 47
    Help: 3
    Rate: 14
    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: 14387
    Help: 650
    Rate: 12308
    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
    Board Language: polish
    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
    Board Language: polish
    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: 14387
    Help: 650
    Rate: 12308
    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.
  • #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: 14387
    Help: 650
    Rate: 12308
    @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: 14387
    Help: 650
    Rate: 12308
    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: After adding a 1 kHz (≈4095 ms max) hardware watchdog, random freezes dropped by “five sockets still available” to 0 crashes in 7 days [Elektroda, flobuljeedom, post #21032468] “Works like a charm now” [Elektroda, flobuljeedom, post #20923206]

Why it matters: Reliable power-monitoring smart plugs hinge on stable BL602/BL0937 firmware.

Quick Facts

• Rated load: 16 A/3680 W (marketing says 20 A) – measured relay is Songle SRD-05 VDC-SL-C 16 A [Elektroda, flobuljeedom, post #20856171] • Chipset combo: Bouffalo BL602 Wi-Fi MCU + BL0937 energy metering IC [Elektroda, flobuljeedom, post #20856171] • Factory firmware: Tuya v1.3.x; OTA image ≈ 800 kB occupying 544 kB FW slot [Elektroda, miegapele, post #20921739] • Watchdog window: 1 – 4095 ms (32 kHz /4 prescaler) per BL602 HAL [OpenBL602 SDK] • Typical flashing time via UART @ 921 600 bps: < 30 s using Bouffalo Lab DevCube.

Is the BL0937 energy-meter driver fully working on BL602 now?

Yes. Pull-request #1044 merged; CF/CF1/SEL interrupts count correctly after including hal_gpio_register_handler and watchdog feed [Elektroda, p.kaczmarek2, post #20920330]

Why did my socket show zeros after first flash?

Early builds lacked the BL0937 interrupt counter; update to firmware ≥ 1.17.457 or newer OTA "OpenBL602_xxx.bin" and apply correct GPIO template (CF1-3, CF-14, SEL-21) [Elektroda, miegapele, post #20919936]

Which GPIOs are used in the common SM-028 V1.3 board?

2 → Relay, 3 → CF1, 14 → CF, 17 or 22 → Button (variant-dependent), 20 → LED (active-low), 21 → SEL [Elektroda, flobuljeedom, #20856171; Elektoda, andrewbeyou, #21274357].

OTA update fails at 253 bytes – how to fix?

The flash-erase routine blocked the TCP task. Firmware ≥ 1.17.528 erases in 4 kB chunks, eliminating the 253-byte stall [Elektroda, miegapele, post #20944841]

Device still freezes; what next?

Enable hardware watchdog (default from 1.17.528). It reboots on BL_RST_SOFTWARE_WATCHDOG, preserving uptime. Add PingWatchDogEnable 1 to reboot if Wi-Fi drops [Elektroda, zdzihu123, post #21030199]

How can I keep the relay ON after power loss or reboot?

Go to WebApp → Config → Startup and set Channel 1 Start State to –1 (retain last). Or issue POWER ON as Startup Command [Elektroda, p.kaczmarek2, post #20923585]

Physical button stopped working after template load – why?

Your hardware variant routes the button to GPIO 22, not 17. Edit template pins accordingly: "22":"Btn;1" [Elektroda, andrewbeyou, post #21274357]

What causes freeze when using `SetupEnergyStats`?

A bug in stats timer locks the main loop exactly one second before the configured interval. Avoid the command until patch lands; watchdog now recovers automatically [Elektroda, flobuljeedom, post #20944817]

Edge-case: socket reboots, PC loses power for 0.5 s – unavoidable?

Relay is NO; reboot de-energises coil briefly. Hardware fix: replace with NC relay or add RC delay to driver transistor base [Elektroda, omniron, post #21066374]

How do I open the housing without breaking it?

  1. Clamp the body vertically in a pipe-wrench.
  2. Rotate plug prongs with adjustable pliers; the glue weld snaps.
  3. Pry halves with a guitar pick. (Video demo) [Elektroda, miegapele, post #21139347]

Statistic: how many MQTT publishes come from BL0937 driver?

Typical idle socket sends ≈ 17 000 MQTT state messages per 20 minutes if change-filter disabled [Elektroda, zdzihu123, post #21027185] Enable ChangePubCancel 1 to cut traffic by > 90 %."

Can I flash over air if socket uses ESP8266 instead of BL602?

Only if Tuya-convert exploit is unpatched (pre-2020). For firmware ≥ 1.3.18 you must solder UART wires; OTA profiles won’t match [Elektroda, bezzubov, post #21423243]
Generated by the language model.
ADVERTISEMENT