logo elektroda
logo elektroda
X
logo elektroda

How to Implement a Clock in OpenBeken Devices Without Using NTP Protocol

max4elektroda 4581 95
ADVERTISEMENT
  • #31 21046561
    divadiow
    Level 35  
    fresh flash. nothing set. will set to powersave 0 to be sure. is powersave on by default on W600?

    Added after 5 [minutes]:

    no matter. powersave 0

    Screenshot displaying device information with the W600 chipset.
  • ADVERTISEMENT
  • #32 21046574
    p.kaczmarek2
    Moderator Smart Home
    Currently powersave is never on by default, but I am considering enabling it.
    Helpful post? Buy me a coffee.
  • #33 21046836
    max4elektroda
    Level 21  
    @divadiow thanks for your "long term" tests and especially the new input on W600!

    divadiow wrote:
    I have a W600 now. Sadly, it's not happy very quickly

    Seems this platform is using another tick rate like Beken platforms.

    Hopefully I finally got it right now (factor "portTICK_RATE_MS" should be present on all platforms, equals to 2 on Beken and W600/W800 and 1 for LN882H and BL602).
    Now the code is:
    TickType_t actTick=portTICK_RATE_MS*xTaskGetTickCount();

    so I think I'm counting ms now on all platforms.
  • Helpful post
    #34 21046878
    divadiow
    Level 35  
    Screenshot of a system interface displaying device information.

    🤩

    Added after 8 [hours] 6 [minutes]:

    Screenshot with device information, showing date, time, and software version details.

    Added after 7 [hours] 45 [minutes]:

    @max4elektroda do all platforms need flashing again for a fresh round using latest changes?
  • #35 21051969
    max4elektroda
    Level 21  
    It would be great if you could confirm its still working right on Beken (OpenBK7231T/N) and BL602 after my recent change (I did the tests for LN882H here).
    I just finished the first try on a configurable daylight saving time in my local code, but it need some cleanup to include it.
    After this I think it should be ready to include, but there is still some work to do to separate the generic clock functions from ntp-driver to a general "clock-driver".

    And up to now I only managed to build an image to use "#define" for the javascript code with some "handcrafted" code like this in "new_http.c":
    
    
    #if ENABLE_LOCAL_CLOCK
    #define PMNTP "<some 'gulped' JS code here>"
    #else
    #define PMNTP ""
    #endif
    //region_start pageScript
    const char pageScript[] = "<script type='text/javascript'>var [...](++onlineFor)"PMNTP"}function onLoad()[...];</script>";
    //region_end pageScript
    
  • #36 21053508
    p.kaczmarek2
    Moderator Smart Home
    This is exactly what I wanted, thank you! This is beginning to look very professional, i hope we can merge it soon. Very good job on supporting other platforms as well.
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #39 21061947
    divadiow
    Level 35  
    BL602 died again. the rest seem like a success though? LN jumped ahead slightly? Maybe not enough to care about.
    Screenshot showing information about various devices and a system clock.
  • #40 21062117
    max4elektroda
    Level 21  

    Thank you so much for your tests @divadiow, the clocks are all in the expected range of precision.
    That should work for all cases of calculating "daily values" and even work for most of the switching purposes, when it doesn't matter if the clock differs one minute after a month.
    Maybe in the future we can even add kind of a correction factor to add/subtract a second every xxx seconds ...
    From my side, these tests are successful and don't need to be continued.
    What's currently untested is the case of "overflow" of the tick counter, but it will happen only every 50 days...
    So thanks again for your support, it helped a lot!
  • ADVERTISEMENT
  • #42 21063405
    max4elektroda
    Level 21  

    So, after the test is before the (next) test, so if you (or other brave guys) are willing to take another try:

    I just finished a universal daylight saving handling, heavily relying on the Tasmota code:

    You are no longer bound to the settings during compilation, but can set DST freely.
    So if this could be tested on other platforms with some other configuration tests, that would be great.
    I attached a file with all the DST settings on Tasmota DST page "rewritten" for my approach.


    And I would appreciate if @p.kaczmarek2 could have a look at the PR, too, especially on the change to "new_pins.h":
    I added a uint64 to config to be able to save the clock settings (at least, I tried ;-), not sure if padding is needed and if my calculation is right)

    In the meantime, I did some tests about xTicks overflow by defining a 16-bit TickType_t locally and could verify (on my LH882H) that this works as intended (with 16-bit the overflow is after 1 minute and some seconds, not every 50 days as with 32-bit counter).

    So, if the tests are successful, I can disable some "chatty" information, disable the functions tested and then I would expect it ready for merging...
  • #43 21064685
    p.kaczmarek2
    Moderator Smart Home
    The new_pins.h config change look okay, but if you want to be sure, just try flashing built binaries to any BK7231 or other device. So far your changes are looking good, keep it up!
    Helpful post? Buy me a coffee.
  • Helpful post
    #44 21064882
    divadiow
    Level 35  
    well, they all flash and set timer from browser OK as before

    Screenshot with information about multiple devices, their online status, and system time.

    I also set PC time to next daylight savings change and saw it go back an hour and switch to GMT from BST. Only watched it on BK7231T though. Do you want all? Is that part of the test required?

    Screenshot showing software version and device time information.

    Added after 4 [minutes]:



  • ADVERTISEMENT
  • #45 21064958
    omniron
    Level 11  
    Now that our balcony unit is working again (thanks to p.kaczmarek2), I'm really looking forward to implement a silent NTP update for rickbronson great sunrise/set function.

    This is what I have

    // Turn off/on Balcony by Sunrise/rise
    PowerSave 1
    startDriver ntp
    ntp_timeZoneOfs -8
    ntp_setLatlong 44.002130 -123.091473
    removeClockEvent 12
    removeClockEvent 13
    waitFor NTPState 1
    addClockEvent sunrise 0x7f 12 POWER2 OFF
    addClockEvent sunset 0x7f 13 POWER2 ON

    But in order for the above to work I must allow internet access for the NTP update, hope I can avoid that with your fine clock implementation.
    Thank you guys, really great work here!!
  • #46 21065169
    max4elektroda
    Level 21  

    That should be possible in the future. ATM the split of general time functions like sunrise/sunset and timed events are somehow "glued" to ntp.
    Splitting this will need to add additional source files to every platform (but I can try to give you a "preview" if I know your platform).
    There still is one drawback: every loss of power will need setting of the clock.
    This can be done easily from another device but needs some "process" like another device checks the clock of the module regularly and then sets it via http, if unset.
    Or (it's just a hacked proof of concept which would need some deeper testing) if the beken device can reach an http server (e.g router) sending a "date:" header, you can let the device get its time from a locally reachable webserver.

    Added after 11 [minutes]:

    And again a big thanks to @divadiow for your tests. I think this proves its working o.k. now.
    I will try to prepare the PR for merging, mainly set all #defines to 0 in obk_config.h
  • #47 21611170
    max4elektroda
    Level 21  
    I just opened PR#1729, which is actually in sync with main (since many files are involved, the PRs regulary have merge conflicts after some time).
    I would really like some feedback, maybe someone can take the time to dig into changes and give feedback.
  • #48 21611193
    p.kaczmarek2
    Moderator Smart Home
    Interesting, first of all:
    - any breaking changes?
    - how much binary increase and is it optional or mandatory?

    Added after 2 [minutes]:

    So you basically split clock from NTP (as title said), so it means it's now easier/more clearer to integrate CR2032-backed RTC module via I2C? Hm
    Helpful post? Buy me a coffee.
  • #49 21611382
    max4elektroda
    Level 21  
    p.kaczmarek2 wrote:
    Interesting, first of all:
    - any breaking changes?
    - how much binary increase and is it optional or mandatory?

    I didn't find any breaking changes, but actual PR needs some more testing.
    Actually I have to find out, what changed - last PR was "usually" smaller (for all builds using NTP) but this is increasing size significantly and I need to check why. I have an idea, but need to check.

    p.kaczmarek2 wrote:
    So you basically split clock from NTP (as title said), so it means it's now easier/more clearer to integrate CR2032-backed RTC module via I2C? Hm

    To be honest, I didn't see CR2032 code, but in fact, that should be quite easy to add any source providing time.
    I did e.g. a quick hack to set clock by NEO6M, just as a proof of concept.
  • #50 21611390
    p.kaczmarek2
    Moderator Smart Home
    CR2032 is a battery, I had a whole family of RTC modules in mind, but to give a sample, DS3231 is popular:
    How to Implement a Clock in OpenBeken Devices Without Using NTP Protocol
    Helpful post? Buy me a coffee.
  • #51 21611408
    max4elektroda
    Level 21  
    p.kaczmarek2 wrote:
    CR2032 is a battery,

    Oh, sure, just was in another "context" ;-)

    Is there some code just now for these in OBK (or in an PR)?

    Just curious ...
  • #53 21632647
    max4elektroda
    Level 21  
    Won't promise anything @omniron but just ordered some modules to try.

    We have some other i2c devices, so base is already there.
    We'll still need this or a similar change to OBK to enable clock functionality without NTP.
  • #54 21633540
    omniron
    Level 11  
    Thank you @max4elektroda
    I use the ones you pictured and the smaller one from my mod.
    The smaller fits barely in existing smart units, but meanwhile there are even smaller RTC boards with the DS3231.

    Would be great to have an RTC working since some of smart things are in a remote location with no internet.
    Except when I'm there and I make a hotspot
    Power outages are fequent, messing up the timing etc.

    Hope you can get it going and maybe @p.kaczmarek2 can help with OBK integration?

    Thanks!!
  • #55 21633562
    max4elektroda
    Level 21  
    What chip is your plug using?
    Btw, just for a situation like yours, I have drafted a solution to use a cheap GPS as time source.
    But for use with a plug this is no optimal solution since usually the pins are on life potential, not good to access without optical isolation...
    Also, deep in my box of things to do: I once ordered a DCF77 module, never found the time to work with it.
    It should be doable if I got it right, "only" need to measure signals for 1 and 0 every second over one minute and decode them.

    Added after 10 [minutes]:

    Ah, I forgot you mentioned tasmota, so I expect some ESP32 variant or ESP8266?

    Added after 7 [hours] 33 [minutes]:

    If you like, you can test my first try here:

    https://github.com/MaxineMuster/OpenBK7231T_App/actions/runs/16915983611

    For now it will only display the time on main screen:


    OpenESP32 interface screen showing DS3231 time and system status

    startdriver DS3231 <CLK-Pin> <DATA-Pin>
       e.g. startdriver DS3231 32 33
    Commands:
    
    DS3231_GetTime
    DS3231_GetEpoch
    
    
    DS3231_SetTime <hours> <minutes> <seconds> <date> <month> <year>
    DS3231_SetEpoch <epoch time>


    Added after 6 [hours] 48 [minutes]:

    Updated driver start.

    https://github.com/MaxineMuster/OpenBK7231T_App/actions/runs/16947283141

    Now you can add an optional "sync" parameter:

    startdriver DS3231 <CLK-Pin> <DATA-Pin> <optional sync>

    sync values: 0: do nothing 1: set devicetime to RTC on startup 2: set devicetime to RTC regulary (making RTC clock source)

    to set RTC you can e.g. use on a Linux device

    wget "http://<ip.of.your.plug>/cmd_tool?cmd=DS3231_SetEpoch $(date +%s)"

    @p.kaczmarek2 is there any chance to indicate a driver can't start?

    E.g. if not all required pins are set ...
    If I got it right, even then OBK will always assume driver started after calling initFunc.

    If I didn't miss something, maybe we should change that?
    We could
    - make startdriver function "bool" instead of void
    - add "number of required arguments" to driver_t
    - or add a global var, which could be set to "error" during Driver_Init, so no need to change anything but only checking this before setting driver to "running"
  • #56 21634305
    p.kaczmarek2
    Moderator Smart Home
    I would really like to have that driver in main, please help me merge it when it's ready. Currently I am doing OTA clearup - moving platform specific things to HAL.

    My idea for error signaling is a bit different - I've been thinking that maybe we should have some kind of "errors buffer", something with API like:
    Code: C / C++
    Log in, to see the code

    and keep like, idk, last 10 errors in single linked list, and display them on main page, so they can't be missed. That would reside outside of the web app log which is in a ring buffer and gets lost easily.

    Stiill, if you want to edit driver start, hm... maybe make Driver init function return cmdResult_t ?
    Helpful post? Buy me a coffee.
  • #57 21634310
    max4elektroda
    Level 21  
    Startup command run for driver ds3231 with parameters 32 33 2





    Added after 18 [minutes]:

    p.kaczmarek2 wrote:
    I would really like to have that driver in main, please help me merge it when it's ready.

    The "problem" is, if you could accept the big change of "NTP centered" to a "device clock".
    Its of no real use if it can only display the time on main page but should set the clock if there's no other possible source.
    Without the PR we would need to start NTP and let DS3231 somehow "fake" ntp and manipulate g_ntpTime.

    I would be glad if our loyal supporter @divadiow would assist testing the PR.
    Main question would be: Is NTP working as before, in all possible aspects.

    And lastly, we will need some idea of the "leading" clock, if there are several possible sources.
    But this might also be easy, by letting the user decide about this.

    Regarding errors: let's put that away now, and keep it in mind for later.
    It was just I stumbled over what to do if pins are not given - and we might have that with drivers started with pins as arguments or pins from pin_roles.
    drv_main can't know the prerequisites for every driver, so it might be good to somehow catch the case it's not successfully started in the future.

    Will continue next days, will call it a day for now.

    Added after 4 [minutes]:

    p.kaczmarek2 wrote:
    Stiill, if you want to edit driver start, hm... maybe make Driver init function return cmdResult_t ?


    Yes, that might be an idea, let me take a look next days, if this is possible change for all drivers...
  • #58 21634379
    p.kaczmarek2
    Moderator Smart Home
    What is the state of the time PR, does it increase memory footprint much?
    Helpful post? Buy me a coffee.
  • #59 21634555
    max4elektroda
    Level 21  
    PR from my tests is working fine, I couldn't find anything broken.

    Size is a bit difficult:

    I have two approaches: First to save some space I made a version with an own "time.h" replacement for many functions.
    This is quite effective for several platformse.g. BL602, where the resulting firmware is much smaller but there are also some with size increases more than 1k, top TR6260 with +1,2k where I don't really see, why. Maybe I somehow managed to unintentionally include parts of NTP there??

    EDIT:
    resolved merge conflicts. These are the actual values, I think I'll have to double check, if I disabled something in the first ones to realize this reduction in size (-12k for sensors builds), but I can't find something on the first view:

    diff --git a/src/obk_config.h b/src/obk_config.h
    index b55c669a7b..4d5e4450c8 100644
    --- a/src/obk_config.h
    +++ b/src/obk_config.h
    @@ -73,7 +73,7 @@
     #define ENABLE_MQTT                        1
     #define ENABLE_TASMOTADEVICEGROUPS            1
     #define ENABLE_NTP                        1
    -// #define ENABLE_NTP_DST                  1
    +//#define ENABLE_CLOCK_DST                  1
     #define ENABLE_DRIVER_BL0937               1
     #define ENABLE_DRIVER_DHT                  1
     #define ENABLE_TASMOTA_JSON                  1
    @@ -97,6 +97,8 @@
     #define ENABLE_DRIVER_DS1820               1
     #define ENABLE_DRIVER_DHT                  1
     #define ENABLE_NTP                        1
    +#define ENABLE_CLOCK_DST                  1
    +#define ENABLE_CLOCK_PMNTP                  1
     #define ENABLE_DRIVER_BMPI2C               1
     #define ENABLE_DRIVER_CHT83XX               1
     #define ENABLE_I2C                        1
    @@ -128,7 +130,7 @@
     #define ENABLE_TASMOTADEVICEGROUPS            1
     #define ENABLE_LITTLEFS                     1
     #define ENABLE_NTP                        1
    -#define ENABLE_NTP_DST                     1
    +#define ENABLE_CLOCK_DST                     1
     #define ENABLE_DRIVER_LED                  1
     #define ENABLE_DRIVER_BL0937               1
     #define ENABLE_DRIVER_BL0942               1
    @@ -152,7 +154,7 @@
     #define ENABLE_DRIVER_PT6523               1
     #define ENABLE_DRIVER_MAX6675               1
     #define ENABLE_DRIVER_TEXTSCROLLER            1
    -#define ENABLE_NTP_SUNRISE_SUNSET            1
    +#define ENABLE_CLOCK_SUNRISE_SUNSET            1
     // parse things like $CH1 or $hour etc
     #define ENABLE_EXPAND_CONSTANT               1
     #define ENABLE_DRIVER_DHT                  1
    @@ -187,7 +189,7 @@
     #define ENABLE_TASMOTADEVICEGROUPS            1
     #define ENABLE_LITTLEFS                     1
     #define ENABLE_NTP                        1
    -// #define ENABLE_NTP_DST                  1
    +// #define ENABLE_CLOCK_DST                  1
     #define ENABLE_CALENDAR_EVENTS               1
     #define ENABLE_DRIVER_LED                  1
     #define ENABLE_DRIVER_BL0937               1
    @@ -223,7 +225,7 @@
     #define ENABLE_TASMOTADEVICEGROUPS            1
     #define ENABLE_LITTLEFS                     1
     #define ENABLE_NTP                        1
    -// #define ENABLE_NTP_DST                  1
    +// #define ENABLE_CLOCK_DST                  1
     #define ENABLE_NTP_SUNRISE_SUNSET            1
     #define ENABLE_DRIVER_LED                  1
     #define ENABLE_DRIVER_BL0937               1
    @@ -253,6 +255,7 @@
     #define ENABLE_DRIVER_SM16703P               1
     #define ENABLE_DRIVER_PIXELANIM               1
     #define ENABLE_DRIVER_SM15155E               1
    +
     #endif
     // parse things like $CH1 or $hour etc
     #define ENABLE_EXPAND_CONSTANT               1
    @@ -333,7 +336,7 @@
     #define ENABLE_MQTT                        1
     #define ENABLE_TASMOTADEVICEGROUPS            1
     #define ENABLE_NTP                        1
    -//#define ENABLE_NTP_DST                  1
    +//#define ENABLE_CLOCK_DST                  1
     #define ENABLE_DRIVER_BL0937               1
     #define ENABLE_DRIVER_LED                   1
     #define ENABLE_DRIVER_WEMO                  1
    @@ -360,7 +363,7 @@
     #define ENABLE_MQTT                        1
     #define ENABLE_I2C                        1
     #define ENABLE_NTP                        1
    -//#define ENABLE_NTP_DST                  1
    +//#define ENABLE_CLOCK_DST                  1
     #define ENABLE_DRIVER_LED                  1
     #define ENABLE_DRIVER_TUYAMCU               1
     #define ENABLE_LITTLEFS                     1
    


    Spoiler:

    
    Size +/-    Filename                                                       1.18.154   1729_merge_803dd2fb5130
    -12016      OpenBK7231T_XX_sensors.bin                                       763129                     751113
    -12008      OpenBK7231N_XX_sensors.bin                                       794177                     782169
    -11760      OpenW800_XX.fls                                                  694236                     682476
    -11744      OpenBK7231N_XX.bin                                               802065                     790321
    -11728      OpenBK7231T_XX.bin                                               769513                     757785
    -7388       OpenW800_XX_ota.img                                              415724                     408336
    -6928       OpenBK7231N_UG_XX_sensors.bin                                    496880                     489952
    -6928       OpenBK7231N_XX_sensors.rbl                                       496848                     489920
    -6864       OpenBK7231T_UG_XX_sensors.bin                                    474128                     467264
    -6864       OpenBK7231T_XX_sensors.rbl                                       474096                     467232
    -6832       OpenBK7252_XX.rbl                                                529936                     523104
    -6720       OpenBK7231N_ALT_XX.rbl                                           511056                     504336
    -6576       OpenBK7231N_UG_XX.bin                                            503744                     497168
    -6576       OpenBK7231N_XX.rbl                                               503712                     497136
    -6464       OpenBK7238_XX.rbl                                                510288                     503824
    -6416       OpenBK7231U_XX.rbl                                               522944                     516528
    -6384       OpenBK7231T_ALT_XX.rbl                                           522544                     516160
    -6336       OpenBK7231T_UG_XX.bin                                            479296                     472960
    -6336       OpenBK7231T_XX.rbl                                               479264                     472928
    -6000       OpenBK7252N_XX.rbl                                               515504                     509504
    -5936       OpenLN882H_XX.bin                                                761676                     755740
    -3599       OpenLN882H_XX_OTA.bin                                            430746                     427147
    -1600       OpenBL602_XX_berry.bin                                           922400                     920800
    -1600       OpenBL602_XX_berry_OTA.bin                                       926496                     924896
    -1600       OpenBL602_XX.bin                                                 797384                     795784
    -1600       OpenBL602_XX_OTA.bin                                             801488                     799888
    -1528       OpenBK7238_XX_irRemoteESP.bin                                    859961                     858433
    -1392       OpenBK7231N_XX_powerMetering.bin                                 783861                     782469
    -1392       OpenBK7231T_XX_powerMetering.bin                                 753181                     751789
    -1104       OpenBK7238_XX_irRemoteESP.rbl                                    570464                     569360
    -1088       OpenBK7231N_UG_XX_powerMetering.bin                              504480                     503392
    -1088       OpenBK7231N_XX_powerMetering.rbl                                 504448                     503360
    -1008       OpenBL602_XX_OTA.bin.xz                                          442832                     441824
    -1008       OpenBL602_XX_OTA.bin.xz.ota                                      443344                     442336
    -1000       OpenBK7231N_XX_irRemoteESP.bin                                   901101                     900101
    -1000       OpenBK7231T_XX_irRemoteESP.bin                                   876453                     875453
    -1000       OpenBL602_XX_berry_OTA.bin.xz                                    510632                     509632
    -1000       OpenBL602_XX_berry_OTA.bin.xz.ota                                511144                     510144
    -992        OpenBK7231T_UG_XX_powerMetering.bin                              482160                     481168
    -992        OpenBK7231T_XX_powerMetering.rbl                                 482128                     481136
    -944        OpenBK7231T_UG_XX_irRemoteESP.bin                                547216                     546272
    -944        OpenBK7231T_XX_irRemoteESP.rbl                                   547184                     546240
    -832        OpenBK7238_XX_berry.rbl                                          574304                     573472
    -736        OpenBK7231N_XX_berry.bin                                         905153                     904417
    -712        OpenBK7231T_XX_berry.bin                                         872609                     871897
    -624        OpenBK7231N_UG_XX_irRemoteESP.bin                                565328                     564704
    -624        OpenBK7231N_XX_irRemoteESP.rbl                                   565296                     564672
    -576        OpenBK7231N_UG_XX_berry.bin                                      568144                     567568
    -576        OpenBK7231N_XX_berry.rbl                                         568112                     567536
    -480        OpenBK7231T_UG_XX_berry.bin                                      544592                     544112
    -480        OpenBK7231T_XX_berry.rbl                                         544560                     544080
    -368        OpenBK7231N_UG_XX_tuyaMCU.bin                                    502480                     502112
    -368        OpenBK7231N_XX_tuyaMCU.rbl                                       502448                     502080
    -320        OpenBK7231T_XX_tuyaMCU.bin                                       751413                     751093
    -312        OpenBK7231N_XX_tuyaMCU.bin                                       780733                     780421
    -192        OpenBK7231T_UG_XX_tuyaMCU.bin                                    480960                     480768
    -192        OpenBK7231T_XX_tuyaMCU.rbl                                       480928                     480736
    -16         OpenW600_XX.fls                                                  549352                     549336
    0           OpenBK7231M_ALT_QIO_XX.bin                                      1253376                    1253376
    0           OpenBK7231M_QIO_XX.bin                                          1220464                    1220464
    0           OpenBK7231N_ALT_QIO_XX.bin                                      1253376                    1253376
    0           OpenBK7231N_ALT_UA_XX.bin                                       1183744                    1183744
    0           OpenBK7231N_QIO_XX_berry.bin                                    1220464                    1220464
    0           OpenBK7231N_QIO_XX.bin                                          1220464                    1220464
    0           OpenBK7231N_QIO_XX_irRemoteESP.bin                              1220464                    1220464
    0           OpenBK7231N_QIO_XX_powerMetering.bin                            1220464                    1220464
    0           OpenBK7231N_QIO_XX_sensors.bin                                  1220464                    1220464
    0           OpenBK7231N_QIO_XX_tuyaMCU.bin                                  1220464                    1220464
    0           OpenBK7231N_UA_XX_berry.bin                                     1150832                    1150832
    0           OpenBK7231N_UA_XX.bin                                           1150832                    1150832
    0           OpenBK7231N_UA_XX_irRemoteESP.bin                               1150832                    1150832
    0           OpenBK7231N_UA_XX_powerMetering.bin                             1150832                    1150832
    0           OpenBK7231N_UA_XX_sensors.bin                                   1150832                    1150832
    0           OpenBK7231N_UA_XX_tuyaMCU.bin                                   1150832                    1150832
    0           OpenBK7231T_ALT_QIO_XX.bin                                      1253376                    1253376
    0           OpenBK7231T_ALT_UA_XX.bin                                       1183744                    1183744
    0           OpenBK7231T_QIO_XX_berry.bin                                    1048576                    1048576
    0           OpenBK7231T_QIO_XX.bin                                          1048576                    1048576
    0           OpenBK7231T_QIO_XX_irRemoteESP.bin                              1048576                    1048576
    0           OpenBK7231T_QIO_XX_powerMetering.bin                            1048576                    1048576
    0           OpenBK7231T_QIO_XX_sensors.bin                                  1048576                    1048576
    0           OpenBK7231T_QIO_XX_tuyaMCU.bin                                  1048576                    1048576
    0           OpenBK7231T_UA_XX_berry.bin                                      978944                     978944
    0           OpenBK7231T_UA_XX.bin                                            978944                     978944
    0           OpenBK7231T_UA_XX_irRemoteESP.bin                                978944                     978944
    0           OpenBK7231T_UA_XX_powerMetering.bin                              978944                     978944
    0           OpenBK7231T_UA_XX_sensors.bin                                    978944                     978944
    0           OpenBK7231T_UA_XX_tuyaMCU.bin                                    978944                     978944
    0           OpenBK7231U_QIO_XX.bin                                          1253376                    1253376
    0           OpenBK7231U_UA_XX.bin                                           1183744                    1183744
    0           OpenBK7238_QIO_XX_berry.bin                                     1253376                    1253376
    0           OpenBK7238_QIO_XX.bin                                           1253376                    1253376
    0           OpenBK7238_QIO_XX_irRemoteESP.bin                               1253376                    1253376
    0           OpenBK7238_UA_XX_berry.bin                                      1183744                    1183744
    0           OpenBK7238_UA_XX.bin                                            1183744                    1183744
    0           OpenBK7238_UA_XX_irRemoteESP.bin                                1183744                    1183744
    0           OpenBK7252N_QIO_XX.bin                                          1253376                    1253376
    0           OpenBK7252N_UA_XX.bin                                           1183744                    1183744
    0           OpenBK7252_QIO_XX.bin                                           1253376                    1253376
    0           OpenBK7252_Tuya_QIO_XX.bin                                      1253376                    1253376
    0           OpenBK7252_Tuya_UA_XX.bin                                       1183744                    1183744
    0           OpenBK7252_UA_XX.bin                                            1183744                    1183744
    0           OpenRTL8720D_XX.bin                                             1044480                    1044480
    0           OpenRTL8720D_XX_ota.img                                         1019936                    1019936
    0           OpenRTL87X0C_XX.bin                                              950276                     950276
    0           OpenRTL87X0C_XX_ota.img                                          884740                     884740
    0           OpenXR809_XX.img                                                 921384                     921384
    0           OpenXR872_XX.img                                                 798552                     798552
    144         OpenW600_XX_gz.img                                               334824                     334968
    480         OpenESP32S3_XX_4M.factory.bin                                   1063888                    1064368
    480         OpenESP32S3_XX_4M.img                                            998352                     998832
    496         OpenESP32S2_XX_4M.factory.bin                                   1037936                    1038432
    496         OpenESP32S2_XX_4M.img                                            972400                     972896
    496         OpenESP32_XX_4M.factory.bin                                     1063952                    1064448
    496         OpenESP32_XX_4M.img                                              998416                     998912
    536         OpenXR806_XX_ota.img                                             494232                     494768
    544         OpenESP32C2_XX_2M.factory.bin                                    911312                     911856
    544         OpenESP32C2_XX_2M.img                                            845776                     846320
    548         OpenRTL8710A_XX.bin                                              780076                     780624
    548         OpenRTL8710A_XX_ota.img                                          735024                     735572
    551         OpenECR6600_XX_ota.img                                           526833                     527384
    552         OpenECR6600_XX.bin                                               981397                     981949
    552         OpenRTL8710B_XX.bin                                              627076                     627628
    560         OpenESP32C2_XX_4M.factory.bin                                   1039344                    1039904
    560         OpenESP32C2_XX_4M.img                                            973808                     974368
    560         OpenESP32C3_XX_2M.factory.bin                                   1017424                    1017984
    560         OpenESP32C3_XX_2M.img                                            951888                     952448
    560         OpenESP32C3_XX_4M.factory.bin                                   1145360                    1145920
    560         OpenESP32C3_XX_4M.img                                           1079824                    1080384
    560         OpenESP32C5_XX_4M.factory.bin                                   1232720                    1233280
    560         OpenESP32C5_XX_4M.img                                           1167184                    1167744
    560         OpenESP32C61_XX_4M.factory.bin                                  1177632                    1178192
    560         OpenESP32C61_XX_4M.img                                          1112096                    1112656
    560         OpenESP32C6_XX_4M.factory.bin                                   1240912                    1241472
    560         OpenESP32C6_XX_4M.img                                           1175376                    1175936
    576         OpenRTL8720E_XX.bin                                             1401504                    1402080
    576         OpenRTL8720E_XX_ota.img                                         1319616                    1320192
    576         OpenXR872_XX_ota.img                                             446340                     446916
    826         obkSimulator_XX.zip                                             2462873                    2463699
    832         OpenESP8266_1MB_XX.factory.bin                                   814512                     815344
    832         OpenESP8266_2MB_XX.factory.bin                                   814512                     815344
    832         OpenESP8266_XX.img                                               748976                     749808
    960         OpenRTL8721DA_XX.bin                                            1522368                    1523328
    960         OpenRTL8721DA_XX_ota.img                                        1440480                    1441440
    1024        OpenXR806_XX.img                                                 868192                     869216
    1104        OpenRTL8710B_XX_ota.img                                         1254160                    1255264
    1268        OpenTR6260_XX.bin                                                654160                     655428
    




    So I made a second variant, without this separate time.h "replacement" code.

    This is usually bigger up to +600 bytes for most, and again two "special" ones (E6000 +1,1k and TR6260 +2k).
    This is with all have the basic clock enabled, which can be set via "clock_setTime".

    Spoiler:

    
    Size +/-    Filename                                                       1.18.154     _NTP_WIP_2320765352bf
    0           OpenBK7231M_ALT_QIO_XX.bin                                      1253376                    1253376
    0           OpenBK7231M_QIO_XX.bin                                          1220464                    1220464
    0           OpenBK7231N_ALT_QIO_XX.bin                                      1253376                    1253376
    0           OpenBK7231N_ALT_UA_XX.bin                                       1183744                    1183744
    0           OpenBK7231N_QIO_XX_berry.bin                                    1220464                    1220464
    0           OpenBK7231N_QIO_XX.bin                                          1220464                    1220464
    0           OpenBK7231N_QIO_XX_irRemoteESP.bin                              1220464                    1220464
    0           OpenBK7231N_QIO_XX_powerMetering.bin                            1220464                    1220464
    0           OpenBK7231N_QIO_XX_sensors.bin                                  1220464                    1220464
    0           OpenBK7231N_QIO_XX_tuyaMCU.bin                                  1220464                    1220464
    0           OpenBK7231N_UA_XX_berry.bin                                     1150832                    1150832
    0           OpenBK7231N_UA_XX.bin                                           1150832                    1150832
    0           OpenBK7231N_UA_XX_irRemoteESP.bin                               1150832                    1150832
    0           OpenBK7231N_UA_XX_powerMetering.bin                             1150832                    1150832
    0           OpenBK7231N_UA_XX_sensors.bin                                   1150832                    1150832
    0           OpenBK7231N_UA_XX_tuyaMCU.bin                                   1150832                    1150832
    0           OpenBK7231T_ALT_QIO_XX.bin                                      1253376                    1253376
    0           OpenBK7231T_ALT_UA_XX.bin                                       1183744                    1183744
    0           OpenBK7231T_QIO_XX_berry.bin                                    1048576                    1048576
    0           OpenBK7231T_QIO_XX.bin                                          1048576                    1048576
    0           OpenBK7231T_QIO_XX_irRemoteESP.bin                              1048576                    1048576
    0           OpenBK7231T_QIO_XX_powerMetering.bin                            1048576                    1048576
    0           OpenBK7231T_QIO_XX_sensors.bin                                  1048576                    1048576
    0           OpenBK7231T_QIO_XX_tuyaMCU.bin                                  1048576                    1048576
    0           OpenBK7231T_UA_XX_berry.bin                                      978944                     978944
    0           OpenBK7231T_UA_XX.bin                                            978944                     978944
    0           OpenBK7231T_UA_XX_irRemoteESP.bin                                978944                     978944
    0           OpenBK7231T_UA_XX_powerMetering.bin                              978944                     978944
    0           OpenBK7231T_UA_XX_sensors.bin                                    978944                     978944
    0           OpenBK7231T_UA_XX_tuyaMCU.bin                                    978944                     978944
    0           OpenBK7231U_QIO_XX.bin                                          1253376                    1253376
    0           OpenBK7231U_UA_XX.bin                                           1183744                    1183744
    0           OpenBK7238_QIO_XX_berry.bin                                     1253376                    1253376
    0           OpenBK7238_QIO_XX.bin                                           1253376                    1253376
    0           OpenBK7238_QIO_XX_irRemoteESP.bin                               1253376                    1253376
    0           OpenBK7238_UA_XX_berry.bin                                      1183744                    1183744
    0           OpenBK7238_UA_XX.bin                                            1183744                    1183744
    0           OpenBK7238_UA_XX_irRemoteESP.bin                                1183744                    1183744
    0           OpenBK7252N_QIO_XX.bin                                          1253376                    1253376
    0           OpenBK7252N_UA_XX.bin                                           1183744                    1183744
    0           OpenBK7252_QIO_XX.bin                                           1253376                    1253376
    0           OpenBK7252_Tuya_QIO_XX.bin                                      1253376                    1253376
    0           OpenBK7252_Tuya_UA_XX.bin                                       1183744                    1183744
    0           OpenBK7252_UA_XX.bin                                            1183744                    1183744
    0           OpenRTL8720D_XX.bin                                             1044480                    1044480
    0           OpenRTL8720D_XX_ota.img                                         1019936                    1019936
    0           OpenXR806_XX.img                                                 868192                     868192
    0           OpenXR809_XX.img                                                 921384                     921384
    0           OpenXR872_XX.img                                                 798552                     798552
    112         OpenBK7238_XX_berry.rbl                                          574304                     574416
    128         OpenRTL87X0C_XX.bin                                              950276                     950404
    128         OpenRTL87X0C_XX_ota.img                                          884740                     884868
    136         OpenBL602_XX_OTA.bin.xz                                          442832                     442968
    136         OpenBL602_XX_OTA.bin.xz.ota                                      443344                     443480
    144         OpenXR806_XX_ota.img                                             494232                     494376
    172         OpenW600_XX_gz.img                                               334824                     334996
    176         OpenBK7252_XX.rbl                                                529936                     530112
    176         OpenBL602_XX_berry_OTA.bin.xz                                    510632                     510808
    176         OpenBL602_XX_berry_OTA.bin.xz.ota                                511144                     511320
    192         OpenBK7231T_ALT_XX.rbl                                           522544                     522736
    192         OpenBK7231T_UG_XX_berry.bin                                      544592                     544784
    192         OpenBK7231T_XX_berry.rbl                                         544560                     544752
    192         OpenBK7238_XX.rbl                                                510288                     510480
    208         OpenBK7231N_ALT_XX.rbl                                           511056                     511264
    208         OpenESP32_XX_4M.factory.bin                                     1063952                    1064160
    208         OpenESP32_XX_4M.img                                              998416                     998624
    224         OpenBK7231N_UG_XX_berry.bin                                      568144                     568368
    224         OpenBK7231N_UG_XX.bin                                            503744                     503968
    224         OpenBK7231N_UG_XX_powerMetering.bin                              504480                     504704
    224         OpenBK7231N_XX_berry.rbl                                         568112                     568336
    224         OpenBK7231N_XX_powerMetering.rbl                                 504448                     504672
    224         OpenBK7231N_XX.rbl                                               503712                     503936
    224         OpenBK7231U_XX.rbl                                               522944                     523168
    224         OpenBK7252N_XX.rbl                                               515504                     515728
    224         OpenESP32S2_XX_4M.factory.bin                                   1037936                    1038160
    224         OpenESP32S2_XX_4M.img                                            972400                     972624
    240         OpenBK7231T_UG_XX.bin                                            479296                     479536
    240         OpenBK7231T_XX.rbl                                               479264                     479504
    240         OpenECR6600_XX_ota.img                                           526833                     527073
    240         OpenESP32S3_XX_4M.factory.bin                                   1063888                    1064128
    240         OpenESP32S3_XX_4M.img                                            998352                     998592
    256         OpenESP32C2_XX_2M.factory.bin                                    911312                     911568
    256         OpenESP32C2_XX_2M.img                                            845776                     846032
    256         OpenESP32C2_XX_4M.factory.bin                                   1039344                    1039600
    256         OpenESP32C2_XX_4M.img                                            973808                     974064
    256         OpenESP32C3_XX_4M.factory.bin                                   1145360                    1145616
    256         OpenESP32C3_XX_4M.img                                           1079824                    1080080
    256         OpenESP32C61_XX_4M.factory.bin                                  1177632                    1177888
    256         OpenESP32C61_XX_4M.img                                          1112096                    1112352
    256         OpenESP32C6_XX_4M.factory.bin                                   1240912                    1241168
    256         OpenESP32C6_XX_4M.img                                           1175376                    1175632
    272         OpenBK7238_XX_irRemoteESP.rbl                                    570464                     570736
    272         OpenBL602_XX_OTA.bin                                             801488                     801760
    272         OpenESP32C3_XX_2M.factory.bin                                   1017424                    1017696
    272         OpenESP32C3_XX_2M.img                                            951888                     952160
    272         OpenESP32C5_XX_4M.factory.bin                                   1232720                    1232992
    272         OpenESP32C5_XX_4M.img                                           1167184                    1167456
    280         OpenBL602_XX_berry.bin                                           922400                     922680
    280         OpenBL602_XX.bin                                                 797384                     797664
    288         OpenBK7231N_UG_XX_tuyaMCU.bin                                    502480                     502768
    288         OpenBK7231N_XX_tuyaMCU.rbl                                       502448                     502736
    288         OpenBK7231T_UG_XX_irRemoteESP.bin                                547216                     547504
    288         OpenBK7231T_UG_XX_powerMetering.bin                              482160                     482448
    288         OpenBK7231T_XX_irRemoteESP.rbl                                   547184                     547472
    288         OpenBK7231T_XX_powerMetering.rbl                                 482128                     482416
    288         OpenBL602_XX_berry_OTA.bin                                       926496                     926784
    288         OpenRTL8710A_XX.bin                                              780076                     780364
    288         OpenRTL8710A_XX_ota.img                                          735024                     735312
    288         OpenRTL8720E_XX.bin                                             1401504                    1401792
    288         OpenRTL8720E_XX_ota.img                                         1319616                    1319904
    288         OpenW600_XX.fls                                                  549352                     549640
    292         OpenXR872_XX_ota.img                                             446340                     446632
    304         OpenBK7231T_UG_XX_sensors.bin                                    474128                     474432
    304         OpenBK7231T_XX_sensors.rbl                                       474096                     474400
    312         OpenRTL8710B_XX.bin                                              627076                     627388
    317         obkSimulator_XX.zip                                             2462873                    2463190
    320         OpenBK7231N_UG_XX_irRemoteESP.bin                                565328                     565648
    320         OpenBK7231N_XX_irRemoteESP.rbl                                   565296                     565616
    320         OpenLN882H_XX.bin                                                761676                     761996
    336         OpenBK7231N_UG_XX_sensors.bin                                    496880                     497216
    336         OpenBK7231N_XX.bin                                               802065                     802401
    336         OpenBK7231N_XX_sensors.rbl                                       496848                     497184
    360         OpenBK7231N_XX_berry.bin                                         905153                     905513
    368         OpenBK7231T_XX.bin                                               769513                     769881
    368         OpenBK7231T_XX_powerMetering.bin                                 753181                     753549
    376         OpenBK7231N_XX_powerMetering.bin                                 783861                     784237
    392         OpenBK7231T_XX_berry.bin                                         872609                     873001
    416         OpenBK7231T_UG_XX_tuyaMCU.bin                                    480960                     481376
    416         OpenBK7231T_XX_tuyaMCU.rbl                                       480928                     481344
    416         OpenESP8266_1MB_XX.factory.bin                                   814512                     814928
    416         OpenESP8266_2MB_XX.factory.bin                                   814512                     814928
    416         OpenESP8266_XX.img                                               748976                     749392
    540         OpenBK7238_XX_irRemoteESP.bin                                    859961                     860501
    576         OpenBK7231N_XX_irRemoteESP.bin                                   901101                     901677
    576         OpenBK7231T_XX_sensors.bin                                       763129                     763705
    576         OpenBK7231T_XX_tuyaMCU.bin                                       751413                     751989
    584         OpenBK7231N_XX_sensors.bin                                       794177                     794761
    584         OpenBK7231N_XX_tuyaMCU.bin                                       780733                     781317
    584         OpenBK7231T_XX_irRemoteESP.bin                                   876453                     877037
    608         OpenRTL8721DA_XX.bin                                            1522368                    1522976
    608         OpenRTL8721DA_XX_ota.img                                        1440480                    1441088
    624         OpenRTL8710B_XX_ota.img                                         1254160                    1254784
    643         OpenLN882H_XX_OTA.bin                                            430746                     431389
    1156        OpenECR6600_XX.bin                                               981397                     982553
    2144        OpenTR6260_XX.bin                                                654160                     656304
    2272        OpenW800_XX_ota.img                                              415724                     417996
    4184        OpenW800_XX.fls                                                  694236                     698420
    




    For both list of sizes:
    Ignore W800 here, it was my main target where dis- and enabled all those fancy clock possibilities for testing...
  • #60 21634884
    omniron
    Level 11  
    max4elektroda wrote:
    Ah, I forgot you mentioned tasmota, so I expect some ESP32 variant or ESP8266?


    I used the RTC in a ESP8266 Tasmota plug
    https://templates.blakadder.com/kmc_4.html
    Best quality plugs I ever got, Tasmota and power monitoring and work to this day.

    Unfortunately later KMC 4s came with tuya chips and were really cheaply built, bad capacitors and bad design in general like most tuya stuff.

    I don't have that particular RTC unit in reach, but can mod another unit for testing.
    Trying to locate it's schematic to see which pins I used for SDA and SCL.

    GPS boards are much larger and won't fit in most existing smart units.

    So excited for your integration of RTC module into Tasmota or tuya.
    Here is a newer RTC implementaion for Tasmota, never used it, had an older trial from years ago.
    https://tasmota.github.io/docs/DS3231/#tasmota-settings_1
    That plus the option to query the RTC unit by other smart devices as a replacement for NTP will make it possible to be truly disconnected from the internet.
    Thanks again!

Topic summary

The discussion revolves around implementing a local clock in OpenBeken devices without relying on the NTP protocol. The initial approach involved using a variable to track the time since startup, allowing for time calculations based on elapsed seconds. While this method lacks the accuracy provided by NTP, it offers advantages such as independence from network connectivity and reduced resource requirements. Participants provided feedback on code structure, suggested improvements for compatibility, and discussed the potential for using real-time clocks (RTC) for enhanced accuracy. Testing across various platforms, including LN882H, BL602, and W600, was conducted to evaluate the clock's performance and reliability. The conversation also touched on daylight saving time adjustments and the possibility of remote clock synchronization.
Summary generated by the language model.
ADVERTISEMENT