logo elektroda
logo elektroda
X
logo elektroda

Tuya/Smart relay that remembers the schedule after WiFi network loss

p.kaczmarek2 7995 14
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • Tuya/Smart relay that remembers the schedule after WiFi network loss .
    Hello my dears. .
    Here I will present an unusual Tuya relay that (unlike many others) is able to remember and execute its work schedule even if the WiFi connection is lost. This is something new, as the Tuya/SmartLife devices I've tested previously relied entirely on the manufacturer's cloud and didn't even timer locally. The product in this theme is different - as the manufacturer itself emphasises several times. Will it work in practice? Let's find out.

    Purchase product .
    I found the product under " SINOTIMER TM609 Home Smart 18mm 1P WiFi Remote APP Control Circuit Breaker Timing Switch Staircase Timer Din Rail Universal 110V 220V AC Input " for around £100. Below is a screenshot of the offer:
    Tuya/Smart relay that remembers the schedule after WiFi network loss .
    The product features:
    - compatibility with the Tuya/SmartLife app available on Android and iOS, connection via WiFi network
    - the short-circuit relay is not connected to the mains, so that, for example, a 24 V device can be controlled
    - operation from 100 to 240V AC 50/60Hz
    - 16A relay
    - dimensions 70*86*18mm
    - mounting on DIN 35mm rail
    - possibility of connecting an additional momentary pushbutton (apart from the one on the housing) to switch the status of the relay
    - possibility to set a timer and an operating schedule (on/off at a given time), where these settings are remembered and executed even if the WiFi network is lost (the controller module inside remembers these settings and the current time and tries to execute them even if there is no internet)
    Promotional graphics:
    Tuya/Smart relay that remembers the schedule after WiFi network loss .
    Tuya/Smart relay that remembers the schedule after WiFi network loss .
    Tuya/Smart relay that remembers the schedule after WiFi network loss .
    Tuya/Smart relay that remembers the schedule after WiFi network loss .
    Connection - please note that the shorted contact is not hardwired to 230V (as is the case with some Sonoff and similar), which is also a plus.
    Tuya/Smart relay that remembers the schedule after WiFi network loss .
    Tuya/Smart relay that remembers the schedule after WiFi network loss .
    Tuya/Smart relay that remembers the schedule after WiFi network loss .

    Shipping, contents of set .
    I placed the order on 2022-01-01, the package arrived on the 5th of January. Very fast, still considering the New Year and Sunday (it fell on the 2nd). Hand delivery.
    Tuya/Smart relay that remembers the schedule after WiFi network loss .
    Tuya/Smart relay that remembers the schedule after WiFi network loss .
    In the instructions, the manufacturer emphasises that this product has the ability to remember the schedule even if the WiFi network is absent ( "If the product is disconnected from the network, the timer retains all programs set up by Mobile App and works according to the set programs" ):
    Tuya/Smart relay that remembers the schedule after WiFi network loss Tuya/Smart relay that remembers the schedule after WiFi network loss .
    NOTE - this product remembers its working schedule and executes it without WiFi, but of course it will not execute without WiFi automation/scenarios like "turn on light when motion sensor detects presence" etc. etc. A WiFi network is already required for this.

    Pairing with Tuya application .
    As standard with no problems. I used the iPhone app this time. The product is under the "Energy" tab:
    Tuya/Smart relay that remembers the schedule after WiFi network loss Tuya/Smart relay that remembers the schedule after WiFi network loss Tuya/Smart relay that remembers the schedule after WiFi network loss .
    Tuya/Smart relay that remembers the schedule after WiFi network loss Tuya/Smart relay that remembers the schedule after WiFi network loss .
    Tuya/Smart relay that remembers the schedule after WiFi network loss Tuya/Smart relay that remembers the schedule after WiFi network loss Tuya/Smart relay that remembers the schedule after WiFi network loss .
    Interface in the application:
    Tuya/Smart relay that remembers the schedule after WiFi network loss Tuya/Smart relay that remembers the schedule after WiFi network loss Tuya/Smart relay that remembers the schedule after WiFi network loss

    Does it actually hold the schedule after WiFi is turned off? .
    I tested this several times, both with the Countdown option (i.e. "turn off in 10 minutes" etc) and the Schedule option ("Turn light on Fridays at 7pm").
    For the test, I switched the router off the power, depriving the whole house of internet (as well as depriving the LAN).
    4:33am - let's set the schedule to 4:40am and turn the router off:
    Tuya/Smart relay that remembers the schedule after WiFi network loss .
    NOTE - the state of the relay is determined by "Switch:O n", i.e. it will turn it on. This "Toggle" (switch) on the application GUI is from turning on the action execution itself.
    O 4:40:
    Tuya/Smart relay that remembers the schedule after WiFi network loss .
    It works! Several tests show that the product does indeed remember the schedule without WiFi access.
    The topic is interesting in that I found information about it on Tuya's FAQ:
    https://support.tuya.com/en/help/_detail/K9d1qifd5qtcp
    Tuya/Smart relay that remembers the schedule after WiFi network loss
    I post Tuya's official position above. In a nutshell, there are two implementations of timer handling, one local, one cloud-based and it depends on the specific device that is being used. Couldn't they have done it better?

    Does the product hold the previous state when power is lost? .
    I was already about to give a positive verdict, but was still tempted to check something else....
    What happens when the relay is off and we cut the power to it and restore it after a period of time?


    .
    The product remembers the state before power was lost, but the light flashes for a while. At first I thought there was a relay shorted by default, but not.... so there must be an unwanted high state on the relay output for a while during ESP booting, and probably before it boots (or before it reads the previous setting from memory) this moment passes and the light flashes....

    Can this controller be controlled by a phone on the same WiFi network when the WiFi itself has no internet access? .
    The mobile phone was disconnected from WiFi. I then disconnected the main internet cable from the router (WAN), disabled mobile data on the phone and connected it to the same WiFi as the subject device was.
    The device was detected by the phone and could be controlled.

    Interior TM609 .
    Opening this case is quite difficult and problematic. You have to undermine several catches, plus you have to be careful which side you undermine from, because essentially the housing is in three parts (right, left, and the "centre" screw terminals):
    Tuya/Smart relay that remembers the schedule after WiFi network loss .
    Tuya/Smart relay that remembers the schedule after WiFi network loss .
    There are two plates inside:
    Tuya/Smart relay that remembers the schedule after WiFi network loss Tuya/Smart relay that remembers the schedule after WiFi network loss .
    The module from the middle is the TYWE2S (ESP8266), but with access to the RX/TX there is a little trouble (you would have to solder to the small pads), the IO0 in general is on the case only:
    Tuya/Smart relay that remembers the schedule after WiFi network loss .
    Tuya/Smart relay that remembers the schedule after WiFi network loss .
    There is a varistor on the input, you can also see an MB10S rectifier bridge, SM7055-12 transformerless power supply circuit (12V):
    Tuya/Smart relay that remembers the schedule after WiFi network loss .
    Tuya/Smart relay that remembers the schedule after WiFi network loss .
    This small transistor Y1 (ss8050) switches the relay, this is what controls the ESP. The relay is 12V:
    Tuya/Smart relay that remembers the schedule after WiFi network loss .
    The SM7055-12 chip gives us 12V, but the ESP8266 needs 3.3V. The voltage is converted here by an MC34063A in a step-down converter configuration (no ordinary LDO):
    Tuya/Smart relay that remembers the schedule after WiFi network loss .
    Tuya/Smart relay that remembers the schedule after WiFi network loss .
    so there are three wires going to the board from the ESP8266, ground, 3.3V and the signal to the base of the relay switching transistor.
    Below is a short sketch of the connections I made when analysing the board:
    Tuya/Smart relay that remembers the schedule after WiFi network loss .
    These two chokes coded 471 (470µH) have different roles - one is from MC34063A, the other from SM7055.

    Tasmota compatibility .
    Tasmota is an alternative, open-source batch for the ESP8266 allowing independence from the manufacturer's servers, compatible with products such as the one in the topic. Often when doing reviews I try to upload it and specify how it needs to be configured, but here I don't need to do that as the TM609 is already shown as tested and supported by Tasmota:
    https://templates.blakadder.com/sinotimer_TM609.html
    Tuya/Smart relay that remembers the schedule after WiFi network loss .
    Pin roles (pin 12 is relay) confirmed, I checked with a multimeter (there is of course still a base resistor between pin 12 and the base of the transistor).
    Template tasmots:
    
    {"NAME":"Sinotimer TM60","GPIO":[0,0,0,0,0,52,0,0,21,9,0,0,0],"FLAG":0,"BASE":18}
    
    .
    If you want to upload Tasmota to this device, I also recommend trying Tuya-convert:
    https://github.com/ct-Open-Source/tuya-convert
    My Polish-language tutorial: https://www.elektroda.pl/rtvforum/topic3769864.html


    Summary .
    This product is considerably more expensive than ordinary Sonoffs and their clones and its price is only somewhat justified. It does indeed remember and execute the schedule even in the situation of a complete WiFi network outage, which is a very big plus, as at one time I tested some SmartLife or there eWeLink outlets and there was no such possibility there. The schedule setting was there, of course, but it only worked when WiFi was available. I'm just wondering why this isn't available in other products of this type? Or maybe the manufacturers have already updated their software and a simple "Tuya Smart Switch" can do this too?
    Apart from that, the TM609's strengths are the possibility to connect an additional button to control the relay "manually" and the isolation of the relay output from the network (so you can switch e.g. the. 24V).
    Inside, the circuit is based on the SM7055 (12V supply for the relay), the MC34063A (generates 3.3V for the ESP) and the TYWE2S (ESP8266). I attach the SM7055 datasheet note (the other circuits have already appeared on the forum).

    Cool? Ranking DIY
    Helpful post? Buy me a coffee.
    About Author
    p.kaczmarek2
    Moderator Smart Home
    Offline 
    p.kaczmarek2 wrote 12754 posts with rating 10584, helped 593 times. Been with us since 2014 year.
  • ADVERTISEMENT
  • #2 19805562
    ditomek
    Level 22  
    if the device keeps track of the schedule without access to the cloud, how does it handle the countdown?
  • #3 19805571
    krzbor
    Level 28  
    An interesting circuit, but something doesn't sit right with me - if it works properly when the voltage returns, it must have some sort of RTC. Permanent state saving is also a problem - ESP doesn't have an EEPROM, and saving the state in FLASH is a rather poor idea due to the limited number of writes of the same block. I'm also surprised by the "relay shorted by default" - does the circuit use a relay with NC contacts?
  • #4 19805583
    p.kaczmarek2
    Moderator Smart Home
    ditomek wrote:
    as the device watches the schedule without access to the cloud how does it handle the countdown time?
    .
    It must be counting it down on the ESP (with little accuracy as there is no watch quartz inside). Then when WiFi comes back it probably syncs.

    Maybe this +-30 seconds accuracy message is also coming from here....

    krzbor wrote:
    I'm also puzzled by the "relay shorted by default" - does the circuit use a relay with NC contacts?
    .
    I guess it is with NO contacts though (it says so on the packaging), in which case the flashing of the light I observed on startup is a software issue.... on ESP booting, probably pin 12 is temporarily high.


    EDIT:
    krzbor wrote:
    if it works properly after voltage return, it must have some RTC.
    .
    Here you mean loss of power during "local timing"? That is, when both WiFi and power go down unfortunate (for a while)? Then there is no way to count down and it is already lost, which is in line with the quoted information from Tuya's FAQ: the sentence from "However, if the device has a power failure..."
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #5 19805621
    Anonymous
    Level 1  
  • ADVERTISEMENT
  • #6 19805654
    p.kaczmarek2
    Moderator Smart Home
    spec220 wrote:
    .
    does it also time out after a power failure?


    Same question as @krzbor asked - the answer is no, the device only manages when there is no WiFi for a while (or thereabouts, no internet) but the power must be on all the time. If you unfortunate lose both WiFi and power, the "time is lost".
    Tuya/Smart relay that remembers the schedule after WiFi network loss .
    Of course, making a device that could handle and in such a situation would also be possible, you would have to put in there e.g. an RTCC on I2C of the DS1307 type with a battery, but that would probably increase the cost of the product already.... but if you know of any Tuya products with RTCC on board then let me know.
    Helpful post? Buy me a coffee.
  • #7 19805674
    Anonymous
    Level 1  
  • #8 19805682
    krzbor
    Level 28  
    p.kaczmarek2 wrote:
    Must be counting it down on ESP (with little accuracy as there is no watch quartz inside). Then when WiFi comes back it probably syncs.
    .
    Every ESP has a quartz (though rather a generator with a quartz). Wi-Fi requires good timing parameters.
    Here is an example of the ESP-01:
    Tuya/Smart relay that remembers the schedule after WiFi network loss .
    And here is an example of the ESP-12:
    Tuya/Smart relay that remembers the schedule after WiFi network loss .
    You can't see the quartz, because it's probably under the TYWE2S sheet (as in the ESP-12.
  • #9 19805702
    p.kaczmarek2
    Moderator Smart Home
    krzbor wrote:
    p.kaczmarek2 wrote:
    Must be counting it down on the ESP (with little accuracy as there is no quartz inside watch ). Then when WiFi comes back it will probably sync.
    .
    Each ESP has a quartz (though rather a generator with a quartz).
    .

    Oy, we misunderstood here. Watch quartz (bold in quote mine) = 32.768kHz, used for precision timing in RTCC. This "32.768kHz" value was not chosen quite arbitrarily.

    And that every ESP has a 40MHz or other quartz resonator has been known for a long time.

    Read this:
    https://electronics.stackexchange.com/questio...e-32-768-khz-crystals-in-most-circuits/177845
    Quote:
    .
    The frequency of a real time clock varies with the application. The frequency 32768 Hz (32.768 KHz) is commonly used, because it is a power of 2 (215) value. And, you can get a precise 1 second period (1 Hz frequency) by using a 15 stage binary counter.
    .
    For this reason I wrote about the low precision of timekeeping without a quartz clock - 32.768kHz.
    Helpful post? Buy me a coffee.
  • #10 19805722
    Anonymous
    Level 1  
  • ADVERTISEMENT
  • #11 19805728
    krzbor
    Level 28  
    If the ESP has a resonator, the timing accuracy will be high. It does not need a separate watch quartz - it only needs a resonator to measure time.
  • #12 19805885
    p.kaczmarek2
    Moderator Smart Home
    It depends what you mean by "high accuracy", there is various information on the internet about the inaccuracy of timekeeping on the ESP:
    Quote:
    .
    Time keeping on the ESP8266 is technically quite challenging. Despite being named RTC, the RTC is not really a Real Time Clock in the normal sense of the word. While it does keep a counter ticking while the module is sleeping, the accuracy with which it does so is highly dependent on the temperature of the chip. Said temperature changes significantly between when the chip is running and when it is sleeping, meaning that any calibration performed while the chip is active becomes useless mere moments after the chip has gone to sleep. As such, calibration values need to be deduced across sleep cycles in order to enable accurate time keeping. This is one of the things this module does.
    .
    Quote:
    .
    A sample of modules shows that the actual clock rate is temperature dependent, but is normally within 5ppm of the nominal rate. This translates to around 15 seconds per month.

    https://nodemcu.readthedocs.io/en/release/modules/rtctime/
    Of course, this is assuming it works analogously in Tuya.

    Except that in the case of switching on a light or something, even 30 seconds doesn't make a difference, so there's no problem. I just wouldn't implement an offline timer on this one, so to speak, because it would drift away after prolonged use.
    Helpful post? Buy me a coffee.
  • #13 19806402
    krzbor
    Level 28  
    The RTC you write about is used "while the module is sleeping" and is used for wake-up. During normal operation (as in this case), the time is timed exactly. In Arduino, for example, we have the millis() function, which returns the time since the program was started (in milliseconds). This is accurate time from a quartz resonator with an accuracy of about 10ppm - better than most watch quartzes.
  • #14 19822972
    andur82
    Level 1  
    Hello.
    I read many of this module have changed microcontroller and was not ESP8266 anymore. Can you give the link to buy the same so it can be used with your instructions?
    Thanks
  • #15 19823019
    p.kaczmarek2
    Moderator Smart Home
    andur82 wrote:
    Hello.
    I read many of this module have changed microcontroller and was not ESP8266 anymore. Can you give the link to buy the same so it can be used with your instructions?
    Thanks
    .

    Which of them have changed microcontroller? By any chance, are they now WBS2-based (or similiar)? I would like to get one for teardown.

    You can see where I bought my one on the screenshot in the first post, but I will also PM you a link. I placed my order on 01-01-2022.
    Helpful post? Buy me a coffee.

Topic summary

The discussion centers on a Tuya-compatible smart relay, specifically the SINOTIMER TM609, which claims to retain and execute its timing schedule locally during WiFi outages, unlike typical Tuya/SmartLife devices that rely solely on cloud-based scheduling. The device uses an ESP microcontroller (likely ESP8266 or ESP-12 with TYWE2S module) to maintain timing via its internal quartz resonator, providing moderate accuracy without a dedicated 32.768 kHz real-time clock (RTC) crystal. The relay does not preserve timing through power loss; if both WiFi and power fail, the schedule is lost. The timing is managed by the ESP’s internal clock and syncs with the cloud when WiFi is restored. The relay contacts are normally open (NO), despite some initial observations of relay behavior on startup. The absence of an external RTC with battery backup limits precision and persistence of timing during power outages. Suggestions include adding an I2C RTC module like the DS1307 with battery backup for improved reliability, though this would increase cost. The device is considered suitable for smart home applications but not for professional automation systems due to these limitations. Some users noted the possibility of microcontroller changes in newer versions, potentially to WBS2-based chips. The discussion also clarifies the difference between the ESP’s quartz resonator used for timing and a dedicated watch crystal for precise RTC functions.
Summary generated by the language model.
ADVERTISEMENT