logo elektroda
logo elektroda
X
logo elektroda

How do I free the PJ-MGW1103 energy meter from the cloud and connect it to Home Assistant?

p.kaczmarek2 7134 40

TL;DR LABEL_AI_GENERATED

  • The PJ-MGW1103 Tuya energy meter is opened, reverse-engineered, and freed from the cloud by flashing OpenBeken for Home Assistant integration.
  • It uses a TuyaMCU design with a BK7231N CB2S WiFi module, a BL0942 meter chip, and a separate STC 381-TSSOP20 MCU over UART.
  • The unit costs about PLN120 and exposes dpIDs 18, 19, and 20 for current, power, and voltage, mapped to OBK channels.
  • After flashing and an autoexec.bat script, Home Assistant discovers it locally, and measurements work without the Tuya cloud.
  • Without default WiFi state 0x04, the LED stays red or flashing and the meter refuses to report readings.
AI summary based on the discussion. May contain errors.
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
Listen:
  • Check SEL pin for UART mode and SCLK_BPS baud setting

    #31 21548085
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14791
    Help: 659
    Rate: 12937
    Almost, there is one more step needed - you need to check SEL pin state to see if it's set to UART or SPI. Change it if needed.
    Table showing pin configuration and functions of the BL0942 IC, with highlighted SEL and SCLK_BPS pin descriptions.
    Quote:

    7 SEL UART/SPI mode selection (0: UART 1: SPI), internal pull-down resistance,
    connected to GND is 0 level (UART), connected directly to VDD is high level (SPI)

    You also need to pay attention to SCLK_BPS:
    Quote:

    8 SCLK_BPS Serial Clock input for SPI. If using UART, this pin is used to config baud rate of
    UART
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • Cracked BL0942 input resistor and capacitor found

    #32 21548717
    ghimpe--
    Level 10  
    Posts: 8
    Rate: 3
    Last night I tried your firmware and the device still showed weird readings so I proceed to a proper visual inspection of the PCB, using the microscope this time. It didn't take long until I found the culprit: resistor and capacitor on one input of the BL0942 is cracked. It's possible I somehow cracked them when I first open the device to flash it. Embarrassing, never happened to me until now...

    I will try to replace these components and see if the calibration is still accurate. It's a shame I don't have 0402 smd components in my inventory

    At least I am happy I found out why it was behaving like this... it drove me crazy not understanding why...

    Thank you very much for your time and support and for the whole "open beken project", it's amazing!
  • ADVERTISEMENT
  • #33 21549570
    ghimpe--
    Level 10  
    Posts: 8
    Rate: 3
    Just to confirm, I have replaced the broken components and the device is working great now!
    And for reference the resistors are 470R and capacitors are 68nF - (on the input pins 2 and 3 of the BL4092)
  • #34 21549615
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14791
    Help: 659
    Rate: 12937
    That's good to know, I didn't consider that. So now it also works good with OBK?
    Helpful post? Buy me a coffee.
  • #35 21549619
    ghimpe--
    Level 10  
    Posts: 8
    Rate: 3
    Yes, now it works good with open beken.

    Added after 9 [minutes]:

    Yes, now it works good with open beken.
  • ADVERTISEMENT
  • WB2S drop-in compatibility and Tuya MCU query issue

    #36 21840940
    scattering
    Level 3  
    Posts: 3
    Dont know if i can ask this here but:

    - I had this device die on me.
    - Removed the CB2S and tried to make a back up alwasy giving the same error of CRC mismatch with differente values.
    - Since it was bad, i assumed it was corrupted and flashed anyways. The flash is correctly verified, but it doesnt get too hot when plugged and it never created the AP.

    - I had an used WB2S (from a bulb). I could back it up and flash it and it creates the AP.
    - The thing is while it get sent the startdriver tuyaMCU command it doesnt give info back.

    Should/would the WB2S work as a drop-in module? (the original P24 and P26 on CB2S are now PWM4 and PWM5 in WB2S)
    If it should, do i need to rewire the pins from the PWM4 and PWM5 to other pads or can it be just configured from the web app?
    Which command should i use for seeing the info that i get from the device? currently the "tuyaMcu_sendQueryState" says OK but doesnt show anything back, same with "uartSendHex 55AA0008000007"
  • Direct BL0942-to-CB2S UART wiring and Tasmota setup

    #37 21852100
    scattering
    Level 3  
    Posts: 3
    Well, i went for it. I'll leave this here in case it's useful to anybody. Since i had no communication with the Tuya MCU chip (U6 empty space near the RX pad at the end of the black wire) and soldered the BL0942 directly to the CB2S (Tx -> Rx and viceversa), through the test pads in the board as pictured:

    Close-up of a PCB with an IC and soldered red and black wires

    As startup command, i used (I assume this is the same as autoexec.bat(?)):

    startDriver BL0942
    PowerSave 1

    SetupEnergyStats 1
    EnergyCntSample 1

    and has been working OK through MQTT on home assistant. It has quite more entities than what i remember from the Tuya App:

    “Sensores” panel showing readings: 226 V voltage, 50 Hz frequency, other values at 0

    Since it worked as is, i assume the BL0942 it's configured in uart mode by default.
  • ADVERTISEMENT
  • #39 21852115
    insmod
    Level 31  
    Posts: 1432
    Help: 168
    Rate: 455
    >>21852105
    Wasn't this BL0937 problem?
    How would it cause trouble for BL0942, considering it uses UART?

    And BL0937 problem on BK+powersave was fixed quite a while ago.
  • Plan to test meter accuracy in series with another device

    #40 21852127
    scattering
    Level 3  
    Posts: 3
    >>21852105

    Thanks, i had no idea.

    Indeed there's some info online. Since i'm not actively using it right now and it's not totally clear if it causes issues or not (both insmod comment as info online mentioning newer firmware or even hardware issues) i'll put it in series with another device and check if the measurements are consistent or not (ofc that would just describe how my specific unit ebhaves but it's better than nothing).
  • #41 21852272
    DeDaMrAz
    Level 23  
    Posts: 621
    Help: 34
    Rate: 130
    insmod wrote:
    Wasn't this BL0937 problem?
    How would it cause trouble for BL0942, considering it uses UART?

    And BL0937 problem on BK+powersave was fixed quite a while ago.


    My bad then, I had outdated info, I apologize.
Listen:

Topic summary

LABEL_AI_GENERATED
Discussion about freeing a Tuya-based PJ-MGW1103 / TO-Q-SY2-JWT energy meter from the cloud and integrating it with Home Assistant using OpenBeken. The device uses a TuyaMCU architecture with a BK7231N CBU module and a separate MCU communicating over UART, with metering handled by a BL0942 chip. The thread covers flashing OpenBeken, preserving Tuya configuration, mapping GPIO roles, handling a bistable relay with pulse control, and using autoexec.bat and TuyaMCU drivers. Later troubleshooting showed incorrect current/power readings were caused not by firmware but by damaged PCB components on the BL0942 input path; replacing a cracked 470R resistor and 68 nF capacitor restored correct operation under OpenBeken. Additional posts discuss direct BL0942 wiring after removing the Tuya MCU, SEL pin UART/SPI mode, and using MQTT/Home Assistant entities.
AI summary based on the discussion. May contain errors.
ADVERTISEMENT