logo elektroda
logo elektroda
X
logo elektroda

[TYWE2S/ESP8226] Smart plug with RGBW backlight MOKO TX-DE02 and USB charger

p.kaczmarek2 2127 3

TL;DR

  • The MOKO TX-DE02 / YX-DE02 smart plug combines relay control, two 5V 2.1A USB ports, and RGBW backlight LEDs in one Wi‑Fi socket.
  • Inside, it uses a TYWE2S module with exposed GPIO0 and a PCB pin map for the relay, button, and separate R, G, B, and W LED channels.
  • A four-pack cost $28, or about $7 each.
  • Flashing uses esptool.py with 3.3V, GND, RX, TX, and GPIO0 tied low at boot, followed by a power-cycle to start the new firmware.
  • Tasmota’s Maxcio DE02 template makes the plug’s relay and RGBW lighting work, but the USB ports stay uncontrolled and there is no energy meter.
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
📢 Listen (AI):
  • [TYWE2S/ESP8226] Smart plug with RGBW backlight MOKO TX-DE02 and USB charger
    Hello, I will present here the interior and configuration of Tasmota for a rather unusual WiFi-controlled plug/socket with backlight composed of RGBW diodes. As a standard, we will free the nest from the cloud and prepare it to work with HA. The plug described here offers basically three functions: relay control via the application, two USB ports (unfortunately without control) 5V 2.1A and effective backlight (RGB and W). This topic, like the previous one, was created in cooperation with my friend @DeDaMrAz.

    The product was purchased in a stationary store in Serbia. One package was purchased, here a four-pack, for $28 (about $7 each):
    [TYWE2S/ESP8226] Smart plug with RGBW backlight MOKO TX-DE02 and USB charger [TYWE2S/ESP8226] Smart plug with RGBW backlight MOKO TX-DE02 and USB charger
    Contents:
    [TYWE2S/ESP8226] Smart plug with RGBW backlight MOKO TX-DE02 and USB charger
    At the bottom of the plug is the model name - YX-DE02:
    [TYWE2S/ESP8226] Smart plug with RGBW backlight MOKO TX-DE02 and USB charger [TYWE2S/ESP8226] Smart plug with RGBW backlight MOKO TX-DE02 and USB charger
    You have to use force to get inside. You should pry the cover and then unfortunately you need to desolder the pins of the socket i.e. flux and braid are necessary.
    [TYWE2S/ESP8226] Smart plug with RGBW backlight MOKO TX-DE02 and USB charger [TYWE2S/ESP8226] Smart plug with RGBW backlight MOKO TX-DE02 and USB charger
    The plugin has a characteristic backlight, consisting of four RGB LEDs:
    [TYWE2S/ESP8226] Smart plug with RGBW backlight MOKO TX-DE02 and USB charger
    The product uses TYWE2S:
    [TYWE2S/ESP8226] Smart plug with RGBW backlight MOKO TX-DE02 and USB charger [TYWE2S/ESP8226] Smart plug with RGBW backlight MOKO TX-DE02 and USB charger
    It is not 100% ordinary TYWE2S, but it has standard pins. GPIO0 is available on the back of the module:
    [TYWE2S/ESP8226] Smart plug with RGBW backlight MOKO TX-DE02 and USB charger
    [TYWE2S/ESP8226] Smart plug with RGBW backlight MOKO TX-DE02 and USB charger
    Here are the pinouts of the TYWE2S:
    [TYWE2S/ESP8226] Smart plug with RGBW backlight MOKO TX-DE02 and USB charger

    A brief PCB analysis shows the following GPIO ESP roles:
    IO5 - LED strip W (PWM??)
    IO4 - LED status
    RX-Relay
    IO13 - LED strip G (PWM??)
    TX - Btn
    IO12 - LED strip R (PWM??)
    IO14 - LED strip B (PWM??)
    So we have 4 LED colors, RGB and W, separately white.

    The batch can be uploaded via esptool.py . There are various methods, but I only solder 3.3V, GND, RX, TX and GPIO0 to ground (bootloader mode), then connect the power supply (so that GPIO0 is grounded at boot time) and use esptool. Then, for the firmware to start, you need to disconnect GPIO0 from ground and perform a power off/on cycle.

    Tasmota setup
    The Tasmota configuration of this device is available on the web:
    https://templates.blakadder.com/maxcio_YX-DE02.html
    So there's nothing to mess around with.
    [TYWE2S/ESP8226] Smart plug with RGBW backlight MOKO TX-DE02 and USB charger
    We upload the template:
    
    {"NAME":"Maxcio DE02","GPIO":[0,17,0,21,56,22,0,0,37,38,39,0,0],"FLAG":0,"BASE":18}
    

    And everything works:
    [TYWE2S/ESP8226] Smart plug with RGBW backlight MOKO TX-DE02 and USB charger
    [TYWE2S/ESP8226] Smart plug with RGBW backlight MOKO TX-DE02 and USB charger
    The buttons visible on the panel are used to control the RGB LED, separately the white lighting and the relay.

    LED effects
    This time tested with the manufacturer's application. First firing:
    [TYWE2S/ESP8226] Smart plug with RGBW backlight MOKO TX-DE02 and USB charger
    View in the application:
    [TYWE2S/ESP8226] Smart plug with RGBW backlight MOKO TX-DE02 and USB charger
    [TYWE2S/ESP8226] Smart plug with RGBW backlight MOKO TX-DE02 and USB charger
    [TYWE2S/ESP8226] Smart plug with RGBW backlight MOKO TX-DE02 and USB charger
    The application has full control of the socket and LEDs.

    Summary
    Thank you to my colleague @DeDaMrAz for another opportunity to jointly (on my part remotely) change the product firmware. Colleague @DeDaMrAz also began to be very active in working on OpenBeken which is also commendable. This plug, in turn, will serve us, among others. for tests Tasmota Devices Groups for pairing OBK with Tasmota.
    As for the product itself - it is the first smart plug z RGBW backlight I haven't seen anything like that. This is new to me, but does it have any use?
    It is also a pity that we do not have on / off control over the USB ports, but this is what the manufacturer has already decided.
    If the product had an energy meter (usually BL0942 or BL0937), it could be nicely scripted so that, for example, the color reflects the power consumed by the connected device at a given moment, but without it, these colored LEDs are probably just wasted ...
    I attach a backup of the ESP batch.
    Attachments:
    • RGB MOKO TX-DE02.zip (321.16 KB) You must be logged in to download this attachment.

    Cool? Ranking DIY
    Helpful post? Buy me a coffee.
    About Author
    p.kaczmarek2
    Moderator Smart Home
    Offline 
    p.kaczmarek2 wrote 14221 posts with rating 12114, helped 647 times. Been with us since 2014 year.
  • ADVERTISEMENT
  • #2 20580508
    jkwim
    Level 13  
    RGB Smart Plugs have been around for a while.

    I use few Tasmota devices as indicator devices from MQTT network. That is I can change the color of the LED ring based on status of some other device connected to the MQTT network. Nice pieces of IoT devices. They can also be used as night lamps with timer operation.


    [TYWE2S/ESP8226] Smart plug with RGBW backlight MOKO TX-DE02 and USB charger
  • ADVERTISEMENT
  • #3 20580567
    p.kaczmarek2
    Moderator Smart Home
    So there is a RGB + power meter version, as I can see on your screenshot. Nice! Is it possible to script Tasmota to make somehow colour go gradually with current power consumption? Colder colours for low consumption and warmer for higher? That would be a nice effect.
    Helpful post? Buy me a coffee.
  • #4 20581843
    jkwim
    Level 13  
    I am using UK plugs. They don't come with energy monitoring.

    However there should not be a problem to write a script to change color on power values.
📢 Listen (AI):

FAQ

TL;DR: At $7 each, this TYWE2S-based RGBW smart plug can be flashed with Tasmota in ≈3 minutes and mapped to 7 GPIO functions [Elektroda, p.kaczmarek2, post #20560046] "Desoldering the mains pins is mandatory" [Elektroda, p.kaczmarek2, post #20560046] Plug offers relay + RGBW control but USB ports remain unmanaged. Why it matters: Local firmware frees you from cloud lock-in while adding MQTT, HA and custom LED feedback.

Quick Facts

• Model: Maxcio YX-DE02 / TX-DE02, EU plug [Elektroda, p.kaczmarek2, post #20560046] • Wi-Fi SoC: Tuya TYWE2S (ESP8266 @ 80 MHz) [Elektroda, p.kaczmarek2, post #20560046] • Functions: 1 × relay, 4 × RGBW LEDs, 2 × USB-A 5 V 2.1 A (always on) [Elektroda, p.kaczmarek2, post #20560046] • Typical flash size: 1 MB; Tasmota binary ≈ 640 kB [Tasmota Docs] • Street price: US $28 per four-pack (Serbia, 2023) [Elektroda, p.kaczmarek2, post #20560046]

What hardware does the YX-DE02 smart plug use?

The plug uses a Tuya TYWE2S module (ESP8266 core) soldered to the main PCB. It drives one mechanical relay, four discrete RGBW LEDs, and powers two always-on USB-A ports delivering 5 V 2.1 A [Elektroda, p.kaczmarek2, post #20560046]

Which GPIO pins control the relay and each LED colour?

Default template maps: RX→Relay, IO4→Status LED, IO12→Red, IO13→Green, IO14→Blue, IO5→White, TX→Button [Elektroda, p.kaczmarek2, post #20560046]

How can I open the enclosure safely?

Pry the plastic cover, then desolder the two mains socket pins. Use flux and braid to avoid lifted pads; mains capacitors stay charged, so unplug for 5 minutes first [Elektroda, p.kaczmarek2, post #20560046]

How do I flash Tasmota with esptool.py?

  1. Solder 3.3 V, GND, RX, TX, ground GPIO0.
  2. Power on; run esptool.py write_flash 0x0 tasmota.bin.
  3. Remove GPIO0 from ground and power-cycle to boot firmware [Elektroda, p.kaczmarek2, post #20560046] A 640 kB image writes in ≈30 s at 921 600 baud [Espressif, 2021].

The USB ports are always on; can I switch them?

No. The USB output bypasses the relay and has no dedicated MOSFET, so software control is impossible without hardware rework [Elektroda, p.kaczmarek2, post #20560046]

Can I script Tasmota to color-code power consumption?

Yes. With a metering variant, a Rule can map Power values to LedDimmer or Color commands. Example:

Rule1 ON Energy#Power<20 DO Color 0000FF ENDON ON Energy#Power>200 DO Color FF0000 ENDON
Tasmota supports HSV fades, so gradual transitions work [Tasmota Docs].

Will flashing erase factory calibration?

The plug lacks an energy IC, so no calibration data exists. Relay timing and LED brightness remain unaffected because they rely on hardware, not NV storage [Elektroda, p.kaczmarek2, post #20560046]

How can I integrate the plug with Home Assistant?

After Wi-Fi setup, enable MQTT in Tasmota and add the Discovery prefix. Home Assistant auto-creates switch and light entities. Typical discovery completes within 10 s [Home Assistant Docs].

What are common flashing pitfalls?

Leaving GPIO0 tied low keeps the ESP in bootloader, so the device appears dead after flashing. Removing the ground and power-cycling fixes it [Elektroda, p.kaczmarek2, post #20560046]

Is there a version with energy metering?

Yes. Some RGB plugs aimed at US/UK markets add a BL0942 chip. User photos confirm RGB ring plus metering in one shell [Elektroda, jkwim, post #20580508]

What alternative firmware exists?

OpenBeken supports TYWE2S and offers similar MQTT features with lighter binaries; a project contributor tests it on this hardware [Elektroda, p.kaczmarek2, post #20560046]
ADVERTISEMENT