logo elektroda
logo elektroda
X
logo elektroda

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

max4elektroda 6936 97
Best answers

How can I add a clock to OpenBeken devices that keeps time locally without relying on NTP, while staying compatible across platforms?

Implement it as a separate optional clock subsystem, not as NTP itself: split the generic time helpers out of the NTP driver, rename APIs to `Clock_*`, and gate the feature with a disabled-by-default `ENABLE_LOCAL_CLOCK` in `obk_config.h` so existing builds and devices are unaffected [#21031682][#21032115] Use a companion `ENABLE_LOCAL_CLOCK_ADVANCED` for DST/timezone handling if needed [#21032907] For timekeeping, base the clock on a more accurate uptime source from RTOS ticks rather than a simple `g_secondsElapsed++`, because the counter can drift and it should not be moved backward at runtime or driver logic may break [#21639787][#21639876] If you need an initial time source without NTP, the clock can be set from the browser or by an HTTP request from another device, then continue running locally [#21038303]
Generated by the language model.
ADVERTISEMENT
  • #61 21634968
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14413
    Help: 650
    Rate: 12363
    @insmod what do you think? Should we merge it, and if so, at which stage?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #62 21634973
    insmod
    Level 31  
    Posts: 1353
    Help: 160
    Rate: 425
    >>21634968
    Which one? If #1729, then it lgtm, and i think that #1727 can be merged too.
    DS3231 and driver start failure probably better it they are in separate prs.
  • #63 21634977
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14413
    Help: 650
    Rate: 12363
    I'm a bit worried about flash size, if we keep merging features that are used rarely we will run into more issues like OTA ovewriting LFS soon. Still, maybe we can indeed merge clock stuff now and try to make up for it, we still have long strings in the code, even the flag descriptions, they are super long. Maybe we should edit flags page to fetch flash descriptions from Github.
    Helpful post? Buy me a coffee.
  • #64 21634978
    insmod
    Level 31  
    Posts: 1353
    Help: 160
    Rate: 425
    Well, it was reported that bk ota binaries are about 6kb lighter.

    Added after 1 [hours] 15 [minutes]:

    tr6260 size increase is probably because ntp is required(?), and so it wasn't disabled.
    There is a wpa_get_ntp_timestamp function and a separate sntp_tr component.
  • #65 21635354
    max4elektroda
    Level 24  
    Posts: 745
    Help: 47
    Rate: 183
    Let's agree on some final tests, I'm busy this weekend but can spare some time next week.
    One thing I just saw: I changed the call to set DST, I'll have to change it back to the actual command or add an alias for actual call.
    I can also, like it's done for tasmota, compile a list with all possible calls per timezone for our approach (like this one https://tasmota.github.io/docs/Timezone-Table/ )
  • #66 21638397
    max4elektroda
    Level 24  
    Posts: 745
    Help: 47
    Rate: 183
    Changed to allow compatibility CMD.
    Now, what would we need to test?
    I would propose

    Start NTP
    set TZ
    Set DST
    Test DST changes
    Set latitude and longitude and check sunrise and sunset

    Anything else?

    Did a first try for DCF77 decoder, tested working on W800 and ESP32.
    Problem is it's using a very slow code one bit per second.
    Actually I use interrupts, but it needs both edges to detect length of the "bit", so e.g. Beken is out.
    Can I start an own task testing level of an GPIO pin e.g every 10ms as a driver?
    The requirements are not particularly strict; it is sufficient to distinguish 100ms and 200ms pulses and almost 2 seconds without pulse.
  • ADVERTISEMENT
  • #67 21638403
    insmod
    Level 31  
    Posts: 1353
    Help: 160
    Rate: 425
    >>21638397
    For beken, did you try change edge directly in interrupt? E.g. gpio_int_enable to opposite edge.
    I think i'll eventually write a separate HAL for interrupts.
  • #68 21638410
    max4elektroda
    Level 24  
    Posts: 745
    Help: 47
    Rate: 183
    insmod wrote:
    >>21638397
    For beken, did you try change edge directly in interrupt? E.g. gpio_int_enable to opposite edge.
    I think i'll eventually write a separate HAL for interrupts.

    No, but I'll try that. Thanks!
  • ADVERTISEMENT
  • #69 21638411
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14413
    Help: 650
    Rate: 12363
    Give it a try. We also have gpio_int_enable source, btw:
    https://github.com/openshwprojects/OpenBK7231...t/bk7231t_os/beken378/driver/gpio/gpio.c#L536
    Maybe some nested calls could be omitted for speed?
    Code: C / C++
    Log in, to see the code
    Helpful post? Buy me a coffee.
  • #70 21638498
    max4elektroda
    Level 24  
    Posts: 745
    Help: 47
    Rate: 183
    insmod wrote:
    I think i'll eventually write a separate HAL for interrupts.

    That would really be a big step to simplify some code. Thinking of BL0937 driver and it's interrupt code actually needing 1:1 code and ifdefs ;-)
  • #71 21638663
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14413
    Help: 650
    Rate: 12363
    I've did basic OTA separation and I could try interrupt HAL cleanup as well, but I am a bit limited by testing. I can try making PR and leave it for @divadiow to test. Altough.... if I do it, maybe I can do also "Counter" pin role and try to check it myself, even with a capacitor and a button (capacitor for debouncing, otherwise I would get multiple edges...)
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #72 21638698
    divadiow
    Level 38  
    Posts: 4854
    Help: 424
    Rate: 860
    p.kaczmarek2 wrote:
    I can try making PR and leave it for @divadiow to test

    can do. just need to know what a test actually is for this. I don't know much (anything?) about IRQs and edges
  • #73 21638802
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14413
    Help: 650
    Rate: 12363
    I've started playing around interrupts.
    It seems that on BL602, we need to pass pin index to the interrupt to clear the flag - it can be done via user data.
    First step:
    https://github.com/openshwprojects/OpenBK7231T_App/pull/1768
    I assume that we would do a wrapper call via function pointer in HAL...

    Added after 3 [minutes]:

    Same for W600
    Screenshot of C code changes in drv_bl0937.c showing GPIO interrupt handling updates

    Added after 33 [seconds]:

    Those platforms seem easier - no flag clear needed:
    Screenshot of C code showing GPIO interrupt handler functions for multiple platforms

    Added after 1 [minutes]:

    It seems that only PLATFORM_LN882H is tricky

    Added after 39 [minutes]:

    Update: currently not sure about gpio_install_isr_service, need to read up on it, seems like it will be called globally once?

    Added after 1 [hours] 28 [minutes]:

    Not sure about Realtek - how to access last argument (NULL), user data?
    Code: C / C++
    Log in, to see the code

    hmm event is an enumeration:
    Code: C / C++
    Log in, to see the code


    Added after 46 [seconds]:

    ah last argument is ID:
    Code: C / C++
    Log in, to see the code

    so it shall be passed as first one to interrupt

    Added after 10 [hours] 28 [minutes]:

    Almost ready, I will ask for feedback tomorrow

    Added after 6 [hours] 43 [minutes]:

    I didn't split it into multiple files (I will move it to HAL pins?) but it should be ready for testing:
    https://github.com/openshwprojects/OpenBK7231T_App/pull/1768
    @insmod can you check? @divadiow do you have any devices with BL0937?
    The most uncertain part is passing GPIO index to interrupt in HAL so it can call external handler.
    Helpful post? Buy me a coffee.
  • #74 21639409
    divadiow
    Level 38  
    Posts: 4854
    Help: 424
    Rate: 860
    p.kaczmarek2 wrote:
    @divadiow do you have any devices with BL0937

    not all platforms but yes to at least LN882H, BK7231N, BK7231T, ESP8266, RTL8710B, BL602
  • #75 21639411
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14413
    Help: 650
    Rate: 12363
    So the most simple check would be to see if BL0937 works there on main release and then on my PR, each separately
    Helpful post? Buy me a coffee.
  • #76 21639787
    max4elektroda
    Level 24  
    Posts: 745
    Help: 47
    Rate: 183
    I can confirm LN882H working:

    OpenLN882H web panel showing power data and device control options Web interface of OpenLN882H showing voltage, power, and network status.

    Added after 1 [hours]:

    A question regarding the "original" topic ;-)

    If we want to use a generic clock without a reliable source to constantly set the clock (like ntp) we suffer from the fact that "g_secondsElapsed" might be quite unreliable.
    Especially my W800 is a bad example: g_secondsElapsed will be off for ~ 5 seconds after only one minute! So after 12 hours our clock is about 1 hour off.

    We can easily fix that by using rtos tics to get a quite reliable uptime.

    My question: Shall I use this exact uptime (only) for the clock or should we "set" g_secondsElapsed to the correct value regularly?

    In the case of W800 to avoid permanent "jumps" in time we would need to do that quite often, every 5 seconds or so ...
  • #77 21639876
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14413
    Help: 650
    Rate: 12363
    You can't move g_secondsElapsed back at runtime, it could break drivers logic. The best you can do is try rewriting g_secondsElapsed core mechanism to be more accurate, maybe with rtos ticks.
    Helpful post? Buy me a coffee.
  • #78 21639884
    max4elektroda
    Level 24  
    Posts: 745
    Help: 47
    Rate: 183
    The code is really simple (might need to check on recently added platforms):

    
    #if PLATFORM_W600 || PLATFORM_W800
    #define TimeOut_t xTimeOutType 
    #endif
    uint32_t getUptime(){
       TimeOut_t myTimeout;
       /*
       // we use vTaskSetTimeOutState to get the number of xTicks (we could get them with xTaskGetTickCount(), too)
       // but the number of overflows ("xNumOfOverflows") is private and hence not accessable else ...
       void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut )
       {
          configASSERT( pxTimeOut );
          pxTimeOut->xOverflowCount = xNumOfOverflows;
          pxTimeOut->xTimeOnEntering = xTickCount;
       }
       */
       vTaskSetTimeOutState( &myTimeout );
       // for most platforms, ticks are ms, but we can't be sure (e.g. its not on W600/W800) so we use factor portTICK_RATE_MS to make sure we get ms
       uint32_t my_secondsElapsed = (uint32_t)((((uint64_t) myTimeout.xOverflowCount << (sizeof(portTickType)*8) | myTimeout.xTimeOnEntering)*portTICK_RATE_MS ) / 1000 );
    // this would set g_secondsElapsed
    //   g_secondsElapsed=my_secondsElapsed;
       ADDLOG_DEBUG(LOG_FEATURE_RAW, "g_secondsElapsed=%i   / my_secondsElapsed=%i (differs: %i)\r\n", g_secondsElapsed, my_secondsElapsed, (g_secondsElapsed - my_secondsElapsed));
       return my_secondsElapsed;
    }


    Added after 2 [minutes]:

    I'll try using this instead of g_secondsElapsed++

    Added after 30 [minutes]:

    Using this for now - working on W800, will test with others soon ...

    diff --git a/src/user_main.c b/src/user_main.c
    index a0ea6322..dbee5483 100644
    --- a/src/user_main.c
    +++ b/src/user_main.c
    @@ -583,6 +583,11 @@ float g_wifi_temperature = 0;
     static byte g_secondsSpentInLowMemoryWarning = 0;
     void Main_OnEverySecond()
     {
    +#if PLATFORM_W600 || PLATFORM_W800
    +#define TimeOut_t xTimeOutType 
    +#endif
    +       TimeOut_t myTimeout;    // to get uptime from xTicks 
    +
            int newMQTTState;
            const char* safe;
            int i;
    @@ -754,8 +759,9 @@ void Main_OnEverySecond()
                            }
                    }
            }
    -
    -       g_secondsElapsed++;
    +//     g_secondsElapsed++;
    +       vTaskSetTimeOutState( &myTimeout );
    +       g_secondsElapsed = (int)((((uint64_t) myTimeout.xOverflowCount << (sizeof(portTickType)*8) | myTimeout.xTimeOnEntering)*portTICK_RATE_MS ) / 1000 );
            if (bSafeMode) {
                    safe = "[SAFE] ";
            }


    Added after 2 [minutes]:

    insmod wrote:
    For beken, did you try change edge directly in interrupt? E.g. gpio_int_enable to opposite edge.

    Not tested for Beken yet, but its working om BL602, thanks @insmod !
  • #79 21639910
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14413
    Help: 650
    Rate: 12363
    We will integrate this "on change" interrupt into HAL later, as soon as basics are tested
    Helpful post? Buy me a coffee.
  • #80 21639912
    max4elektroda
    Level 24  
    Posts: 745
    Help: 47
    Rate: 183
    p.kaczmarek2 wrote:
    We will integrate this "on change" interrupt into HAL later, as soon as basics are tested

    That hal-approach will really make things much easier, thanks a lot!
  • #81 21639913
    insmod
    Level 31  
    Posts: 1353
    Help: 160
    Rate: 425
    >>21638802
    RTL8710B works.
  • #82 21639922
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14413
    Help: 650
    Rate: 12363
    The next step is "Counter" role from Tasmota. Should be very easy. Do anyone know how it works in TAS? Is it "on change", or "on rising", or "on falling"?
    I guess we need :
    - Counter_any
    - Counter_h
    - Counter_l ? or how should we name it?

    BTW: Little offtopic, but I also got ESP32-S3-ETH-8DI-8RO, I'm trying to put together a TCA9554 driver for it quickly
    https://github.com/openshwprojects/OpenBK7231T_App/pull/1770
    We need 8MB ESP partitions soon..
    Helpful post? Buy me a coffee.
  • #83 21639923
    insmod
    Level 31  
    Posts: 1353
    Help: 160
    Rate: 425
    >>21639922
    Why? 4MB is enough for everything.
  • #84 21639966
    max4elektroda
    Level 24  
    Posts: 745
    Help: 47
    Rate: 183
    p.kaczmarek2 wrote:
    The next step is "Counter" role from Tasmota. Should be very easy. Do anyone know how it works in TAS? Is it "on change", or "on rising", or "on falling"?
    I guess we need :
    - Counter_any
    - Counter_h
    - Counter_l ? or how should we name it?

    Don't know TAS behavior, so I'm no help here.

    What would you count? States? Then _h or _l are fine.
    If you count edges, I would propose _r(aising) and _f(alling)
  • #85 21639968
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14413
    Help: 650
    Rate: 12363
    Does 4MB/8MB partitions are taken into account as LFS limit or is limit outside the partitions? On OpenESP32.
    Helpful post? Buy me a coffee.
  • #86 21639974
    insmod
    Level 31  
    Posts: 1353
    Help: 160
    Rate: 425
    >>21639968
    Limit is partition size. So 8MB with 4MB firmware - LFS partition is the same as if it was on 4MB device.
    But isn't 320KB enough?
  • #87 21640066
    divadiow
    Level 38  
    Posts: 4854
    Help: 424
    Rate: 860
    >>21639409

    animated images

    BK7231N 1.18.156
    OpenBK7231N interface showing voltage, current, and energy metrics

    BK7231N 1768_merge_cf30e28012eb ✅
    OpenBK7231N interface showing power usage and status data

    BK7231N_ALT 1.18.156
    OpenBK7231N interface with OFF status and detailed power metrics

    BK7231N_ALT 1768_merge_cf30e28012eb ✅
    OpenBK7231N web interface showing energy data and OFF device status

    BK7231T 1.18.156
    OpenBK7231T interface showing status OFF and electrical energy metrics

    BK7231T 1768_merge_cf30e28012eb ✅
    OpenBK7231T interface showing power data and OFF status

    BK7231T_ALT 1.18.156
    OpenBK7231T interface showing voltage, current, and energy usage details

    BK7231T_ALT 1768_merge_cf30e28012eb ✅
    OpenBK7231T interface showing energy readings and OFF power state

    (new SDK still does its spikey/jumpy reading thing on any release)
  • #88 21640070
    insmod
    Level 31  
    Posts: 1353
    Help: 160
    Rate: 425
    >>21640066
    Set loglevel to 0 and spikes will 'magically' disappear.
  • #89 21640079
    divadiow
    Level 38  
    Posts: 4854
    Help: 424
    Rate: 860
    insmod wrote:
    Set loglevel to 0 and spikes will 'magically' disappear.

    ooh ok.

    damn. ESP8266 BL0937 device is 1mb.
  • #90 21640087
    p.kaczmarek2
    Moderator Smart Home
    Posts: 14413
    Help: 650
    Rate: 12363
    I'm not sure about 8MB usage yet, so it's probably not a priority.

    Does HTTPS works on ESP build?

    I added counter_f:
    https://github.com/openshwprojects/OpenBK7231...mits/f99158f21f5ae95c2155209256e92ed3674d414d
    Still , one silly bug fix to come.

    I hope to be able to use counter_f along with button and capacitor (to debounce) to test interrupts
    Helpful post? Buy me a coffee.

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.
Generated by the language model.

FAQ

TL;DR: With 1–2 seconds/day drift after switching to RTOS-tick-based uptime, the thread’s core advice is: "split clock from NTP" and keep a local OpenBeken clock from startup time plus corrected elapsed seconds. This helps OpenBeken users who need offline energy stats, local scheduling, or RTC integration without internet or NTP. [#21031093]

Why it matters: A separable device clock lets OpenBeken keep usable time in AP mode, offline LANs, and future RTC-based builds, while reducing dependence on always-on internet time.

Approach Internet required Reported accuracy in thread Best fit Main limitation
Local clock from startup + corrected uptime No about 1–2 s/day daily energy totals, basic schedules loses time after power loss
NTP-based clock Yes, at least for sync network-synced precise schedules, sunrise/sunset needs reachable time source
DS3231 RTC No about 1 minute/year remote installs, outages, offline switching needs extra hardware and space

Key insight: The breakthrough was not “manual time entry” alone. It was replacing naive g_secondsElapsed++ timing with RTOS-tick-derived uptime, then separating generic clock functions from the NTP protocol layer. [#21031093]

Quick Facts

  • The first local-clock method drifted by about 2 minutes per day, but RTOS-tick correction reduced that to about 1–2 seconds per day on the author’s device. [#21031093]
  • Tick-counter overflow was discussed as an edge case, but on a 32-bit counter it appears only about every 50 days; a local 16-bit test forced overflow after about 1 minute to verify logic. [#21063405]
  • Cross-platform testing reported good results on LN882H, BK7231T/N, W600, W800, BL602, BK7238, and ESP32, although BL602 also showed separate watchdog resets during long tests. [#21062117]
  • The DS3231 path became practical later: the driver was said to be available, but not enabled by default; users must compile with #define ENABLE_DRIVER_DS3231 1. [#21865147]

How can I implement a local clock in OpenBeken without using the NTP protocol?

Implement it by storing the device’s time at startup, then adding corrected elapsed uptime to that base. The first version used one startup-time variable plus g_secondsElapsed; the improved version recalculated elapsed time from RTOS ticks every 10 seconds. That lets the clock run in AP mode and without any network. It is accurate enough for daily energy totals, even when exact wall-clock precision is unnecessary. [#21031093]

Why does g_secondsElapsed drift on some OpenBeken platforms, and how can RTOS ticks make it more accurate?

g_secondsElapsed drifts because a simple one-second increment is not equally accurate on all SDKs and platforms. The fix is to derive uptime from RTOS ticks, including platform-specific tick-to-millisecond factors such as portTICK_RATE_MS or a ratio of 2 on some Beken and WinnerMicro targets. That change fixed slow clocks on BK7231N, BK7231T, W600, and W800, and brought reported drift down to about 1–2 seconds per day. [#21046836]

What is g_secondsElapsed in OpenBeken, and how is it used for uptime and offline timekeeping?

g_secondsElapsed is OpenBeken’s uptime counter, used for status displays, JSON output, driver timing, and offline clock math. "g_secondsElapsed is an uptime counter that tracks seconds since boot, a core timing value reused for status pages, sensor intervals, and local timekeeping when combined with a saved start time." The local-clock approach turns uptime into wall time by adding a stored startup epoch. [#21036229]

How do I split OpenBeken's NTP-dependent time functions into a separate generic clock driver?

Split the code by moving generic time access out of drv_ntp.c into a separate clock layer, then leave only protocol-specific sync logic in NTP. In the thread, this meant adding files such as drv_deviceclock.c and renaming event logic toward drv_clock_events.c, while keeping feature flags optional in obk_config.h. That design also makes sunrise, DST, manual clock setting, and future RTC sources usable without forcing the NTP driver to own all time functions. [#21031093]

What is an RTC module like the DS3231, and how does it help OpenBeken keep time without internet access?

A DS3231 RTC gives OpenBeken a hardware time source that survives network loss and improves long-term accuracy. "DS3231 is a real-time clock module that stores and serves calendar time, usually with battery backup, so the device can query accurate time without internet access." In the thread, it was described as accurate to about 1 minute per year and suitable for fully offline systems. [#21034483]

Local clock vs NTP vs DS3231 RTC in OpenBeken — which approach is best for energy stats and scheduled switching?

Use the local clock for energy stats, NTP for highest convenience and precision, and DS3231 for offline switching with outages. The thread concluded that a drift of about 1 minute after a month is acceptable for daily values and many switching tasks, while NTP remains better when exact synchronization matters. DS3231 is the strongest offline option because it avoids internet dependency and keeps good accuracy through power and network interruptions. [#21062117]

How do I enable and test ENABLE_LOCAL_CLOCK and ENABLE_LOCAL_CLOCK_ADVANCED in obk_config.h?

Enable them by turning the defines on, compiling, then verifying both GUI and status output. 1. Set ENABLE_LOCAL_CLOCK 1; optionally set ENABLE_LOCAL_CLOCK_ADVANCED 1 for DST support. 2. Rebuild and flash, because the feature was submitted disabled by default. 3. Confirm that the config page shows a browser-time clock option and that status output reports time. The thread used ENABLE_LOCAL_CLOCK for basic clocking and ENABLE_LOCAL_CLOCK_ADVANCED for DST, with the advanced flag requiring the basic one. [#21032907]

Why did the OpenBeken local clock run slow on BK7231N, BK7231T, and W600, and what fixed it?

It ran slow because the code initially missed the platform tick conversion factor. On BK7231N and BK7231T, the author later found a required ratio of 2; on W600 and W800, portTICK_RATE_MS also equaled 2. After changing the uptime calculation to multiply xTaskGetTickCount() by the correct tick period, the slow-clock behavior was reported fixed across those platforms. [#21039505]

How can I query the current device time programmatically in OpenBeken, for example with STATUS 8 or HTTP requests?

Query it with OpenBeken status endpoints, especially STATUS 8, or send HTTP requests to read or set time remotely. The thread showed a shell example using wget against /cm?cmnd=STATUS%208, returning JSON with "StatusSNS":{"Time":"2024-04-07T15:05:09"}. That makes drift testing easy: poll the device at intervals and compare its reported time with a known-good router or Linux host clock. [#21036320]

What is DCF77, and how could it be used as an alternative time source for OpenBeken devices?

DCF77 can act as an offline radio time source if OpenBeken decodes its pulse timings correctly. "DCF77 is a longwave time-signal system that transmits one timing bit per second, using pulse lengths to encode time data over a one-minute frame." In the thread, a first decoder worked on W800 and ESP32, and the practical requirement was only to distinguish roughly 100 ms pulses, 200 ms pulses, and a nearly 2-second gap. [#21638397]

How should daylight saving time be implemented in OpenBeken: compile-time tables, runtime calculation, or LittleFS-based zone files?

Use runtime-configurable DST if flexibility matters; use compile-time tables only for the smallest builds. The thread started with compile-time tables, then moved toward universal DST settings inspired by Tasmota so users were no longer bound to build-time timezone choices. A LittleFS file like DST.bin was also proposed as a scalable middle ground for per-zone data without hardcoding every rule into firmware. [#21036097]

What is LittleFS in OpenBeken, and how could it store DST or timezone configuration data?

LittleFS is the lightweight on-device file storage layer proposed for keeping timezone or DST rule data outside hardcoded firmware tables. In the thread, one idea was to store a file named DST.bin and read it as a float array or fetch values as needed. That would let users upload zone-specific DST data separately, instead of recompiling for each timezone. [#21036097]

How do I use a DS3231 driver in OpenBeken to set device time from an RTC or keep the RTC synced with epoch time?

Start the driver with pins, then choose whether the RTC sets the device clock once or continuously. 1. Run startdriver DS3231 <CLK-Pin> <DATA-Pin> <optional sync>. 2. Use sync 1 to set device time from RTC at startup or 2 to refresh device time regularly. 3. Set RTC time with DS3231_SetEpoch <epoch> or a Linux request such as wget "http://<ip>/cmd_tool?cmd=DS3231_SetEpoch $(date +%s)". The thread also listed DS3231_GetTime and DS3231_GetEpoch. [#21633562]

What is the safest way to add external time hardware like a DS3231, GPS, or DCF77 module to mains-powered smart plugs?

The safest method is to avoid direct access to live mains circuitry and use only properly isolated, space-appropriate hardware. The thread explicitly warned that plug pins are often at live potential, making GPS access unsafe without optical isolation. It also noted that RTC boards may fit only if there is enough room and if you accept enclosure, compliance, and safety trade-offs inside mains-powered devices. [#21633562]

How could one OpenBeken device act as a time source for other devices on the local network when there is no NTP server available?

It can act as a practical HTTP time source, even without a built-in NTP server. The thread said another device with a good clock can send an HTTP request to set time remotely on an OpenBeken unit by IP, and that source device does not have to run OpenBeken. That enables a local-only setup where one trusted node, router, or web server distributes time to multiple devices after startup or outages. [#21038303]
Generated by the language model.
ADVERTISEMENT