logo elektroda
logo elektroda
X
logo elektroda

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

flobuljeedom 
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 16 posts with rating 83 , 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]

%}