logo elektroda
logo elektroda
X
logo elektroda

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

flobuljeedom  117 18036 Cool? (+5)
📢 Listen (AI):

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.
I bought a Smart Plug from Aliexpress: https://fr.aliexpress.com/item/1005005790622741
They are named Aubess on the website, but not on the packaging or on the socket.

Smart plug and its packaging from AliExpress. Smart plug and its packaging on a dark surface.

Easy to open with pliers.
Dismantled Smart Plug with visible circuit board.

Contains an SM-028_V1.3 with a BL602L02 chip.
Close-up of SM-028_V1.3 circuit board in a smart plug with two metal prongs.
And BL0937.
Close-up of the interior of a smart plug showing the circuit board and electronic components.

I soldered cables in the back of the SM-028_V1.3 between:
SM-028_V1.3 RX -> FTDI232L TX
SM-028_V1.3 TX -> FTDI232L RX
SM-028_V1.3 3V3 -> FTDI232L VCC (on 3V3)
SM-028_V1.3 GND -> FTDI232L GND
SM-028_V1.3 BT -> to a 10Kohm to VCC

And flashed it with Bouffalo Lab Dev Cube
Firmware flashing interface of Bouffalo Lab Dev Cube software

Then I disconnected all wires, remounted the socket, and put it on the plug.
And TADA! I entered my SSID and password and rebooted it.

Smart plug application interface on computer screen

I checked the circuit wiring on the PCB between BL0937 and BL602:
BL0937 CF1 -> BL602 GPIO3
BL0937 CF -> BL602 GPIO14
BL0937 SEL -> BL602 GPIO21
LED -> BL602 GPIO20
Relay -> BL602 GPIO2
Button -> BL602 GPIO17

(don't bother yet to check the LED and button) => TODO

But once configured, nothing showed up in the Web app (all values are zero)
Screenshot of OpenBL602 user interface displaying power data.

Current working template :
Code: JSON
Log in, to see the code

I saw some discussions about the BL0937 driver on BL602 not working because of HAL interrupt falling edge counter.
Is it already implemented?

About Author
flobuljeedom wrote 17 posts with rating 116 , helped 1 times. Live in city Paris. Been with us since 2023 year.

Comments

p.kaczmarek2 12 Dec 2023 18:27

Sadly the interrupt counter for BL0937 is still missing. I think there is an unfinished version: https://github.com/openshwprojects/OpenBK7231T_App/pull/862 Btw, can you also post a template for this... [Read more]

flobuljeedom 12 Dec 2023 18:35

I just updated the post with template and finals BL602 GPIO. [Read more]

flobuljeedom 28 Dec 2023 09:41

Thanks for the info. I tried correcting it, but I am not competent enough in C to include those changes. [Read more]

miegapele 20 Jan 2024 13:59

Got what looks like very similar socket, only button is on other pin, managed to solder and flash ( only destroyed one). Trying to add bl0937 support [Read more]

p.kaczmarek2 20 Jan 2024 14:08

I saw a PR, but is it working? I don't even have that kind of socket to check. Hmm [Read more]

miegapele 20 Jan 2024 14:10

No it's not, doesn't even compile, but I got builds working on my fork, so trying to make it work [Read more]

p.kaczmarek2 20 Jan 2024 15:13

It seems you are getting errors like: /home/runner/work/OpenBK7231T_App/OpenBK7231T_App/sdk/OpenBL602/customer_app/bl602_sharedApp/bl602_sharedApp/shared/src/driver/drv_bl0937.c:155:9:... [Read more]

miegapele 20 Jan 2024 16:20

Yes added that to try, but nothing happens, values always zero. No sure what else to try, could it be that some pin mapping is required like in W600? [Read more]

p.kaczmarek2 20 Jan 2024 16:37

Here is pins code for BL602: https://github.com/openshwprojects/OpenBK7231T_App/blob/main/src/hal/bl602/hal_pins_bl602.c From what I can see, there are no pin mappings there. So, are you sure that... [Read more]

miegapele 20 Jan 2024 16:48

bl_gpio_enable_input should already be called from the driver via HAL_PIN_Setup_Input_Pullup (GPIO_HLW_CF1); [Read more]

p.kaczmarek2 20 Jan 2024 17:23

Wait a minute. I had a report that during last few updates OTA has broken. Is BL602 OTA working for you? It would mean that we need to reduce BL602 binary again. [Read more]

miegapele 20 Jan 2024 17:31

It is working, but seems not 100% reliably. Sometimes I got starting OTA... and nothing happened, but after few retries it worked. This is with builds from my branch. [Read more]

p.kaczmarek2 20 Jan 2024 17:46

Can you print the values of variables increased in the interrupt? Are they really not changing? Have you set correct GPIO for the CF and CFI pins? Are variables set as volatile? [Read more]

miegapele 20 Jan 2024 18:32

Actually made some progress with latest try. Now getting some values at least :) https://obrazki.elektroda.pl/6884445200_1705771798_thumb.jpg So hopefully it's now just wrong pins somewhere. Will... [Read more]

p.kaczmarek2 20 Jan 2024 18:43

I suspect it;'s caused by too large flash binary, but I am not sure. I will try to reduce the size by stripping features that are not useful on BL602: https://github.com/openshwprojects/OpenBK7231T_App/pull/1044 Can... [Read more]

miegapele 20 Jan 2024 21:31

Good news, got it working. Now there is two things to solve here, I think these long sdk includes should not be here, it should be moved to HAL layer I think. However, not sure how interrupt stuff for... [Read more]

p.kaczmarek2 21 Jan 2024 09:21

That's very good news, nice job. We have source for register function, it seems to be using a linked list: static gpio_ctx_t *pstgpio_head = NULL; int hal_gpio_register_handler(void *func, int... [Read more]

miegapele 21 Jan 2024 10:31

Is the binary size really the issue here, seems little bit strange, because it should never work if there is not enough space. Now it works sometimes, so maybe actual ram use is the issue? Also, is there... [Read more]

p.kaczmarek2 21 Jan 2024 10:58

I'm just speaking from experience. We had OTA issue back then: https://github.com/openshwprojects/OpenBK7231T_App/issues/745 It was solved by reducing binary size. Do you think the cause may be different... [Read more]

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.
%}