logo elektroda
logo elektroda
X
logo elektroda

[RTL8710CF] How to Reflash Firmware on Kasa HS103 WiFi Plug Mini

Jerther 2205 10
Best answers

How can I restore the original factory-reset-on-long-press behavior after flashing OpenRTL on a Kasa HS103V5 plug?

Use a button hold event in the firmware config: `setButtonTimes 50 1 5` sets the hold threshold to 5 seconds, and `addEventHandler OnHold 17 SafeMode` puts the device into SafeMode/AP mode on that long press [#21549056] SafeMode does not erase the stored configuration; it just ignores it, which matches the original firmware’s behavior of entering a special mode without wiping settings [#21543142] If you want an actual config wipe instead, the thread suggests using `clearConfig` on a longer hold, for example 20 seconds [#21543450] With this plug’s single button, the reported working setup was the 5-second SafeMode action, and the author noted that separate 20-second behavior may not be practical on this device [#21549056]
AI summary based on the discussion. May contain errors.
ADVERTISEMENT
  • HS103V5 flash points and OpenRTL template

    #1 21542702
    Jerther
    Level 5  
    Posts: 30
    Help: 1
    Rate: 9
    This is for a HS103V5 (Version 5)

    TP-Link smart plug connected to an American electrical outlet.

    The case is pretty difficult to open. First, you have to remove the cap with the clear plastic ring. Then the rest of the case can be pried open:


    A printed circuit board with electronic components in a white case on a table.


    Three plastic casing parts for an electrical device on a white table.

    Then use these test points to flash OpenRTL:

    TP1 Vcc 5 V
    TP3 3.3 V
    TP4 GND
    TP6 UART2_OUT
    TP5 UART2_IN
    TP2 GPIOA0

    Don't forget to short GPIOA0 to 3.3 V to enable bootloader mode.

    Close-up of an electronic device's PCB with labeled connection pins: 5V, GND, 3.3V, UART2_IN, UART2_OUT, and GPIOA0.

    I recommend removing the black foam pad to make things easier.

    Here's my setup:

    A PCB of an electrical socket with test wires connected, held in a helping hand tool.

    FLash using RTL87X0C UART Flash
    https://github.com/openshwprojects/OpenBK7231T_App/releases

    Here's the template I've come up with:

    {
    "vendor": "Kasa",
    "bDetailed": "0",
    "name": "Kasa Smart Wi-Fi Plug Mini (HS103)",
    "model": "HS103",
    "chip": "RTL87X0C",
    "board": "TODO",
    "flags": "1024",
    "keywords": [
    "TODO",
    "TODO",
    "TODO"
    ],
    "pins": {
    "12": "Rel;1",
    "17": "Btn;1",
    "18": "LED;1",
    "19": "WifiLED_n;0"
    },
    "command": "setButtonTimes 50 1 5\r\naddEventHandler OnHold 17 SafeMode",
    "image": "https://obrazki.elektroda.pl/3920204000_1746651639.png",
    "wiki": "https://www.elektroda.com/rtvforum/topic4120893.html#21542702"
    }

    There's only one button, and it should control the relay and the blue led. The amber LED is tied to the wifi status.

    Now the original firmware initiated a factory reset when the button was depressed for 20 seconds. Is there a way to reintroduce this feature?
  • ADVERTISEMENT
  • Helpful post

    Safe mode reentry via autoexec OnHold event

    #2 21542820
    divadiow
    Level 38  
    Posts: 5179
    Help: 443
    Rate: 908
    nice one. template add: https://github.com/OpenBekenIOT/webapp/commit/5c976cc951b2590e2320594bc8380143a971e7d9

    Jerther wrote:
    Is there a way to reintroduce this feature?


    would something like this in autoexec to get into safe mode do?

    Code: Text
    Log in, to see the code


    Added after 12 [minutes]:

    I flashed the backup you sent and put into AP mode (P17 grounded for 5s). So it boots, but Kasa and Tapo apps could not finish pairing. No matter. Here's boot log to phone joining AP point
    Code: Text
    Log in, to see the code
  • ADVERTISEMENT
  • Safe mode likely ignores stored configuration

    #3 21543142
    Jerther
    Level 5  
    Posts: 30
    Help: 1
    Rate: 9
    I'm not sure the Tapo app is compatible. Have you tried the Kasa app instead?

    Added after 5 [hours] 44 [minutes]:

    divadiow wrote:
    would something like this in autoexec to get into safe mode do?

    addEventHandler OnHold 17 SafeMode 20


    SafeMode puts the controller in AP mode, but does it also reset the stored configuration?

    Hmmm, I just found this:

    https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/safeMode.md

    And I think it means the configuration is not erased, but ignored, which would be enough because that's what the original firmware did for a 5s long press of the button.

    Do I get this right?
  • ADVERTISEMENT
  • #5 21543491
    Jerther
    Level 5  
    Posts: 30
    Help: 1
    Rate: 9
    Awesome!

    So it should be

    addEventHandler OnHold 17 SafeMode 5
    addEventHandler OnHold 17 clearConfig 20

    Will try this. We should also add this to https://www.elektroda.com/rtvforum/topic4098414.html. I'll have to double-check but I think the template does not handle the dedicated reset button...
  • #6 21543504
    divadiow
    Level 38  
    Posts: 5179
    Help: 443
    Rate: 908
    hmm. I see safemode has optional delay before restart but clearconfig does not.

    Code: Text
    Log in, to see the code


    maybe

    Code: Text
    Log in, to see the code


    Added after 3 [minutes]:

    that's wrong too I think. have you seen the examples? could try stuff out see what works https://github.com/openshwprojects/OpenBK7231T_App/blob/main/docs/autoexecExamples.md
  • ADVERTISEMENT
  • #7 21543554
    Jerther
    Level 5  
    Posts: 30
    Help: 1
    Rate: 9
    addEventHandler [EventName][EventArgument][CommandToRun]

    so

    addEventHandler OnHold 17 SafeMode 5

    where

    EventName is OnHold
    EventArgument is 17 for IO 17
    CommandToRun is SafeMode 5

    And

    SafeMode [OptionalDelayBeforeRestart]

    where

    OptionalDelayBeforeRestart is 5.

    Can't find how to define the hold time of OnHold :( Doc on this looks sparse...
  • SafeMode triggered by 5-second button hold

    #8 21549056
    Jerther
    Level 5  
    Posts: 30
    Help: 1
    Rate: 9
    This works:

    
    setButtonTimes 50 1 5
    addEventHandler OnHold 17 SafeMode
    


    setButtonTimes sets the button hold time to 50x100ms = 5s. The other two values are for click time (default was 3), and repeat time (same as default). Apparently this applies to all buttons, but fortunately there's only one button on this device.

    I guess I can't have another behavior for 20s long press... No big deal though. SafeMode should be enough.

    Now this is nice, but there's one remaining problem. When the device is in SafeMode, is there a way to reboot it without having to power cycle it? A delay or a press of the button would be fine I think.
  • #9 21769686
    Jerther
    Level 5  
    Posts: 30
    Help: 1
    Rate: 9
    @divadiow I see the template hasn't been pushed to the main repository... Anyway to make it happen?
  • #11 21769980
    Jerther
    Level 5  
    Posts: 30
    Help: 1
    Rate: 9
    Oh, I get it now. The name is wrong. Same for the dual exterior plug. I think Kasa devices should be grouped together, like the HS200 variants:

    Smart home device list in a mobile app interface

Topic summary

✨ The discussion explains how to reflash firmware on a Kasa HS103V5 WiFi plug mini based on the RTL8710C/RTL8710CF platform using UART flashing and OpenRTL/OpenBK7231T tools. It documents opening the difficult-to-disassemble enclosure, locating test points for 5 V, 3.3 V, GND, UART2 TX/RX, and GPIOA0, and forcing bootloader mode by pulling GPIOA0 high. A working OpenBeken template is shared, along with notes about safe mode behavior, button-hold configuration using setButtonTimes, and event handlers such as OnHold to enter SafeMode or clearConfig. The thread also covers pairing/boot behavior in AP mode, firmware backup, and template naming/grouping issues for Kasa devices in the web app repository.
AI summary based on the discussion. May contain errors.
ADVERTISEMENT