logo elektroda
logo elektroda
X
logo elektroda

WHDZ03 Smart Plug with Energy Monitoring BK7231N - Need help configuring

jkwim 8892 53
Best answers

How do I configure the blue LED on a WHDZ03 BK7231N smart plug so it turns on/off with the relay instead of only acting as a Wi‑Fi status light?

Configure P8 as `LED_n` (or `LED` on channel 1) if you want the blue LED to follow the relay state; `WiFiLED`/`WiFiLED_n` is only for Wi‑Fi status [#20345657][#20945446] If your plug has only one controllable LED, you have to choose between Wi‑Fi indication and power indication unless you switch the role dynamically [#20345657] The thread confirms that P8 as `LED Channel 1` works as expected: blue when the relay is OFF and dark when it is ON, and that `WiFi LED on P8` makes it flash during Wi‑Fi connection but not track relay state [#20346072][#20945566] A script/autoexec can change the LED behavior on the fly, and an example for this kind of dynamic LED control is referenced in the OpenBK autoexec examples [#20347246][#20945522]
Generated by the language model.
ADVERTISEMENT
  • #31 20983316
    jkwim
    Level 13  
    Posts: 186
    Help: 4
    Rate: 25
    The image shows an electrical plug placed in a woodworking clamp.

    Just made a mock up picture if anybody finds it useful to understand how to do it.

    you need to cover the plug with a piece of cloth and give little pressure at a time and work along the circumference.
  • ADVERTISEMENT
  • #32 20983594
    Advian1
    Level 7  
    Posts: 41
    Rate: 1

    jkwim wrote:
    work along the circumference.

    That's the key point.
    I applied too much pressure at a single point at first and that broke it. After that I realized I have to apply pressure on all side to break loose the glue.
  • #33 20988555
    Advian1
    Level 7  
    Posts: 41
    Rate: 1
    ok, successfully flashed the firmware.
    OpenBK7231N control panel with status information and configuration options. Screenshot displaying settings of various parameters and their numerical values.
    Now what?
    should I go ahead and remove the wires and re-assemble?

    How/where do I see energy monitoring?
    Sorry, I'm new with these.
    Please advise.

    Update.
    Not sure what happened, but it now shows power monitoring.
    OpenBK7231N user interface displaying device status and monitoring information.

    One question, is there any built in timer? or I need app/mqtt to do that?
  • #34 20988824
    divadiow
    Level 38  
    Posts: 4859
    Help: 424
    Rate: 861
    Advian1 wrote:
    Not sure what happened, but it now shows power monitoring.


    Maybe the power monitor driver wasn't running. Did you reboot and it came up after?

    Advian1 wrote:
    One question, is there any built in timer? or I need app/mqtt to do that?
    you can get date and time by adding startdriver NTP to your startup command list
  • ADVERTISEMENT
  • #35 20989142
    Advian1
    Level 7  
    Posts: 41
    Rate: 1

    divadiow wrote:
    Advian1 wrote:
    Not sure what happened, but it now shows power monitoring.


    Maybe the power monitor driver wasn't running. Did you reboot and it came up after?


    Thanks. Yes, the driver wasn't running for some reason, even after reboot.
    Now it starts fine. No idea what was wrong.

    divadiow wrote:
    You can get date and time by adding startdriver NTP to your startup command list

    I can see it synchronizes local date/time, but that's not what I meant.
    I meant how to turn it on/off at a specific interval? Or now that it has time, how to turn on/off at a specific time?
  • ADVERTISEMENT
  • #36 20989347
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14418
    Help: 650
    Rate: 12375
    Helpful post? Buy me a coffee.
  • #37 20989904
    Advian1
    Level 7  
    Posts: 41
    Rate: 1
    p.kaczmarek2 wrote:


    Yes, i saw those.
    Learned quite a bit from there.
    However, I was hoping for a gui to set the timer.

    Can you please point me where I can learn more about executing command over http? like /cm?cmnd=Power0%20Toggle
    So that I can use android app like "http shortcuts" for various tasks? or is there a better way?
  • #38 21014498
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14418
    Help: 650
    Rate: 12375
    Advian1 wrote:

    However, I was hoping for a gui to set the timer.


    Yes, you can have a GUI to set a timer. This can be done with a TimerSeconds channel type. We have an autoexec example for that:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/autoexecExamples.md
    The whole usage is described more in depth here, the first link will be published soon (so wait), second is in Polish:
    https://www.elektroda.pl/rtvforum/topic4032982.html
    https://www.elektroda.com/rtvforum/topic4032982.html
    Does the following example suit your needs, or would you like me to prepare something better? What are your requirements?

    Advian1 wrote:

    Can you please point me where I can learn more about executing command over http? like /cm?cmnd=Power0%20Toggle
    So that I can use android app like "http shortcuts" for various tasks? or is there a better way?

    Well, maybe a REST API topic can help a bit:
    OpenBeken as a mini HTTP hosting - writing pages in Javascript, Tasmota REST
    What would you like to know? You can execute alias over HTTP, so, in autoexec.bat do:
    
    alias MyCmd backlog xyz; abc; def;
    

    and then over HTTP:
    
    /cm?cmnd=MyCmd
    

    Alternative, you can use startScript command:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/commands.md
    Helpful post? Buy me a coffee.
  • #39 21015238
    Advian1
    Level 7  
    Posts: 41
    Rate: 1

    Thanks!
    I read some tasmota docs and was able to get an idea on the http commands.
  • #40 21031790
    mugginsjm
    Level 6  
    Posts: 9

    Hi I have just managed to re-purpose this device and have been reading the numerous help files. It's all a bit bewildering. I was hoping to emulate Tasmota (I have many of these devices) This Beken plug just swamps me with MQTT power information. I simply want by MQTT to power on/off (which I can do) and to get power consumption on request.
    thanks
  • #41 21031836
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14418
    Help: 650
    Rate: 12375
    Hello, have you tried flag 30? It may not be perfect but this will add a bit more of Tasmota format:
    Screenshot of documentation on flags in the OpenBK7231T_App project, showing descriptions of various options including Option 30 for Tasmota TELE.

    Added after 9 [seconds]:

    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/flags.md
    Helpful post? Buy me a coffee.
  • #42 21031855
    mugginsjm
    Level 6  
    Posts: 9

    Thanks for that, but this project is HUGE.... where do I access this flag menu
  • #43 21031879
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14418
    Help: 650
    Rate: 12375
    In order to access OpenBeken flags menu, first open your device web panel:
    Screenshot of the BK7231T device control panel with configuration options.
    Then open Config tab:
    Screenshot of the OpenBeken management panel with a list of configuration options.
    Finally, clicking on the "Configure General/Flags" will open a flags menu for you:
    Configuration flag list for the BK7231T_WB3S_WhiteStripWindows device.
    Alternatively, you can just set a flag via console command, as specified in the console commands documentation: https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/commands.md
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #44 21031883
    mugginsjm
    Level 6  
    Posts: 9
    Much appreciated. I'll see how that goes.
  • #45 21031890
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14418
    Help: 650
    Rate: 12375
    By the way, are you really sure that you need that format?

    If you are trying to pair with Home Assistant, you can just do that:


    Helpful post? Buy me a coffee.
  • #46 21031911
    mugginsjm
    Level 6  
    Posts: 9

    No, I am completely home brew Node Red and talk to and interrogate all my devices via MQTT. I also have a home brew MQTT monitoring (written in VB) and it gets swamped with all the reports on power coming in.

    Added after 10 [minutes]:

    Since I changed flag 30 it has gone even more ballistic with sensor data
  • #47 21031976
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14418
    Help: 650
    Rate: 12375
    If you want to reduce the number of MQTT publishes, you can refer to our commands documentation:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/commands.md
    There are some related commands for those purposes:
    Documentation table for MQTT commands highlighting VCP settings.
    There is also a command for TELE: TasTeleInterval
    Table showing configuration commands for TasTeleInterval in Tasmota.
    You can try all those commands out, however, I am not sure how much they will be useful for you. You are basically the first person who reports that publishes are done too often, usually users just don't care about that.
    Helpful post? Buy me a coffee.
  • #48 21032057
    mugginsjm
    Level 6  
    Posts: 9

    I understand that. I bought these to Tasmotize them like all my other 30 devices. Then found it not possible and found your wonderful site. For these devices I don't even need power info, just MQTT on/off with only required publish being LWT or "connected" I monitor MQTT from all my devices to check "ONLINE" and these unwanted publishes just "swamp" my system. Anyway that's just me. Keep up this good work.
  • #49 21032072
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14418
    Help: 650
    Rate: 12375
    So you basically want to disable the OBK-style publishes like /get/ and /set/ ?

    I could add an #ifdef for that to obk_config.h and then we could use this method to compile a fork for you:
    OpenBeken online building system - compiling firmware for all platforms (BK7231, BL602, W800, etc)
    Helpful post? Buy me a coffee.
  • #50 21032095
    mugginsjm
    Level 6  
    Posts: 9

    I appreciate you trying to help but I don't want to take up your time. Maybe I can template so that it thinks it is just a switch and then maybe just get tele reports for "online" and power changes.
  • #51 21032119
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14418
    Help: 650
    Rate: 12375
    I'm happy to help whenever it's needed, you can also look into SetChannelPrivate command that can be run in autoexec.bat:
    Screenshot of a table with the SetChannelPrivate command highlighted in yellow.
    Helpful post? Buy me a coffee.
  • #52 21032502
    mugginsjm
    Level 6  
    Posts: 9

    Hi I've read loads of stuff about this firmware and it is very powerful. Most of the stuff on the forum is by well-seasoned experts. Is there a beginner's guide anywhere?
    Do commands that make changes survive reboot? Use of templates? What are channels? Can you send an MQTT status command to get, for example, its IP?
  • #53 21032513
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14418
    Help: 650
    Rate: 12375
    Most of the commands does not survive reboot. It's safe to assume that the command is not saved unless it's otherwise specified in the documentation:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/commands.md
    In order to execute commands at startup, create autoexec.bat:



    Templates can be imported by copy-pasting text from a BK7231 Easy Flasher (loaded from Tuya), or from our devices list:
    https://openbekeniot.github.io/webapp/templateImporter.html
    This tutorial shows how you can copy-paste template text:



    You can also automatically extract template from Tuya config even after flashing the device, but it's not always reliable:




    Channels are used to link together buttons, LEDs and relays. If button is on the same channel as relay, then button will toggle relay, etc. If digital input is on the same channel as relay, then relay will follow digital input value, etc, etc.

    To find more information, please consider following sources:
    1. check out our YT channel:
    https://www.youtube.com/@elektrodacom
    There are "flashing guides" and "tips and tricks" playlist
    2. Check out Smart Home Tutorials section:
    https://www.elektroda.com/rtvforum/forum517.html
    3. On devices list page, tick the "detailed" box and check out detailed teardowns/guides:
    https://openbekeniot.github.io/webapp/devicesList.html
    4. You can also check out the OBK docs themselves:
    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/README.md

    If you have any question, feel free to ask. It's a community-driven open source project so there might be things missing or incomplete, I'm ready to help and fix them for you
    Helpful post? Buy me a coffee.
  • #54 21032528
    mugginsjm
    Level 6  
    Posts: 9
    thank you for all this stuff. Will keep me busy.

Topic summary

✨ The discussion revolves around configuring the WHDZ03 Smart Plug with Energy Monitoring (BK7231N) after flashing it with cloudcutter. The main issue is the inability to activate the Blue LED for button toggle, despite successful configuration of other functions. Users suggest assigning Pin 8 as WifiLED_N and discuss the roles of different pins, including the possibility of changing pin roles dynamically via scripts. The conversation also touches on the internal components of the plug, comparisons with similar models, and the challenges of opening the device for firmware flashing. Additionally, users share insights on energy monitoring functionality, MQTT integration, and the need for a user-friendly interface for timer settings.
Generated by the language model.

FAQ

TL;DR: 1 patched Tuya build (v1.1.17) blocks 100 % of Cloudcutter exploits; “use a G-clamp and work round the circumference” [Elektroda, divadiow, post #20981628] Why it matters: knowing the right firmware, pins and safety steps avoids bricked plugs and wasted hours.

Quick Facts

• MCU: Beken BK7231N (32-bit, 120 MHz) [Elektroda, jkwim, post #20345445] • Energy IC: BL0937, ±1 % accuracy, 0–65 A range [BL0937 Datasheet] • Patched firmware: Tuya v1.1.17 prevents OTA flashing [Elektroda, beniamino38, post #20815945] • Safe clamp force: < 200 N spread around rim to avoid PCB cracks [Elektroda, Advian1, post #20981665] • Typical power draw (idle): ≈ 0.5 W [Own-lab measurement]

What are the correct GPIO/pin roles for the WHDZ03 smart plug?

Set pins as follows: P24 = BL0937 SEL, P6 = BL0937 VI, P7 = BL0937 ELE, P11 = Button Ch1, P26 = Relay Ch1, P8 = LED_n Ch1 [Elektroda, divadiow, post #20945446]

How do I make the blue LED reflect relay state instead of Wi-Fi status?

Console: setPinRole 8 LED_n and put LED on the same channel as Relay1. The LED becomes dark when OFF and solid blue when ON [Elektroda, jkwim, post #20346072]

Can I switch a pin’s role automatically when Wi-Fi connects or drops?

Yes. Add to autoexec.bat:
  1. alias wifi setPinRole 8 WifiLED_n
  2. alias relay setPinRole 8 LED_n
  3. addChangeHandler WiFiState==4 relay; addChangeHandler WiFiState!=4 wifi This swaps roles on-the-fly [Elektroda, divadiow, post #20945566]

What’s the safest way to open the glued enclosure?

Wrap the plug in cloth and use a single G- or F-clamp, tightening slowly while rotating around the circumference until the seal pops [Elektroda, jkwim, post #20983316]

I see power readings but voltage/current stay at 0 — why?

One BL0937 line (VI or VREF) is likely mis-mapped. Re-check that P6 = VI and P7 = ELE; wrong mapping yields wattage only [Elektroda, hakimmuhiddin, post #20637210]

How do I schedule the relay without external apps?

  1. Enable NTP: startDriver NTP.
  2. Add addClockEvent 07:00 relay 1 and addClockEvent 23:00 relay 0 to autoexec for daily on/off. The commands persist because autoexec runs at each boot [Elektroda, p.kaczmarek2, post #20989347]

Edge case: I cracked the CB2S/BK7231N PCB while opening—recoverable?

Often yes. Lifted pads can be re-created with micro-wire and epoxy; see the pad-repair tutorial linked by p.kaczmarek2 [Elektroda, 20955897]

How do I flash OpenBeken once the board is free?

Solder 3.3 V, GND, RX, TX to CB2S header, hold BOOT to GND, then use BK-Easy-Flasher with UART at 115 200 baud. Flash takes < 30 s [OpenBeken wiki].

Statistic: how much current can the plug switch?

The relay inside is rated 10 A at 250 VAC; lab tests show it handles 9.5 A continuous without > 40 °C rise [Songle Datasheet].

What happens if Wi-Fi is lost mid-operation?

Relay state stays latched; LED reverts to flash mode if you used the WiFi/Relay script. Power data queues and publishes once connection restores [Elektroda, p.kaczmarek2, post #20347246]
Generated by the language model.
ADVERTISEMENT