Off-line equipment time dynamic correction system based on internet of things bluetooth communication

By optimizing IoT Bluetooth communication and dynamic correction algorithms, the problem of time drift in the offline state of IoT devices has been solved, which improves time accuracy and ensures the stability of device functions. It is suitable for devices such as Bluetooth locks, smart locks and IoT sensors.

CN122395710APending Publication Date: 2026-07-14GUANGDONG JIANLANG HIBES INTELLIGENT TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
GUANGDONG JIANLANG HIBES INTELLIGENT TECH CO LTD
Filing Date
2026-04-17
Publication Date
2026-07-14

AI Technical Summary

Technical Problem

Existing IoT devices suffer from accumulated errors due to time drift when offline, which fails to meet national standards. Furthermore, traditional online synchronization solutions fail when the network is disconnected, affecting device security and functional stability.

Method used

An offline device time dynamic correction system based on IoT Bluetooth communication is adopted. The system synchronizes and calibrates time with external devices through the Bluetooth communication module. Combined with the local RTC module and correction algorithm module, the system optimizes time correction using dynamic correction factors and mathematical models to improve time accuracy in offline mode.

Benefits of technology

It enables dynamic correction of time accuracy when the device is offline, gradually eliminating crystal oscillator drift error, meeting national standards, improving device function stability and security, and is suitable for a variety of IoT devices without increasing hardware costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122395710A_ABST
    Figure CN122395710A_ABST
Patent Text Reader

Abstract

The application belongs to the technical field of Bluetooth and microcontroller, and particularly relates to an offline equipment time dynamic correction system based on Bluetooth communication of Internet of Things. The application provides an offline equipment time dynamic correction system based on Bluetooth communication of Internet of Things, which comprises an Internet of Things Bluetooth equipment, a local RTC module, a Bluetooth communication module, a data storage module and a correction algorithm module; the system is used for realizing dynamic correction of equipment time in an offline state. The application breaks through the traditional time calibration mode which depends on online synchronization, and the equipment does not need to be connected to the network in real time. After calibration is triggered through Bluetooth communication, the time drift can be continuously corrected in the offline state based on a dynamic correction factor, and the problem of time precision in a long-time offline scene is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of Bluetooth and microcontroller technology, specifically relating to an offline device time dynamic correction system based on IoT Bluetooth communication. Background Technology

[0002] With the development of IoT technology, smart locks and other devices have been widely used in homestays, long-term rental apartments, office buildings, and other scenarios. Core functions such as temporary password unlocking, visitor reservation, automatic deadbolt locking, and holiday access control policies all rely on accurate time references. Relevant national standards clearly require that the 24-hour timing error of networked electronic anti-theft locks must be ≤5 seconds, and the time accuracy of internet locks must meet the standard of 24-hour ±5-second error.

[0003] Existing technologies have significant drawbacks: On the one hand, non-networked IoT devices such as Bluetooth locks cannot synchronize time online in real time and rely entirely on local RTC modules for timing. However, the 32.768K crystal oscillators used in RTC modules have inherent drift characteristics and significant individual differences, resulting in time errors of several seconds to several minutes per day. After long-term offline operation, the accumulated error can reach several hours, causing problems such as temporary password expiration and reservation rejection. On the other hand, even networked smart locks may fail to synchronize network time due to network outages, power failures, or network anomalies. Local time drift can also lead to industry pain points such as security policy failure, accidental triggering of scheduled tasks, and confusion in audit and evidence collection timelines.

[0004] Traditional time calibration solutions often rely on online synchronization mechanisms, using the Network Time Protocol (NTP) to obtain time from cloud-based atomic clocks for calibration. However, this approach becomes completely ineffective when the device is offline or disconnected from the network. Some devices rely solely on improving the accuracy of the hardware crystal oscillator to reduce errors, which not only increases hardware costs but also fails to eliminate the tendency for errors to accumulate and spread, thus failing to meet the accuracy requirements for long-term offline scenarios. Summary of the Invention

[0005] To address the aforementioned problems, this invention provides an offline device time dynamic correction system based on IoT Bluetooth communication, comprising an IoT Bluetooth device, a local RTC module, a Bluetooth communication module, a data storage module, and a correction algorithm module; the system is used to dynamically correct the device time in an offline state, including the following steps: Step 1: Time Initialization: After the device is powered on or reset, the local RTC module initializes the time to the preset reference value and sets the default time zone; Step 2, Initial Time Calibration: When the Bluetooth communication module successfully connects to the external Bluetooth device, it receives the calibration time and corresponding time zone information sent from the cloud, compares the current time and time zone of the local RTC module with the sent information, and if they are inconsistent, it resets all logic algorithms and calibrates the local time using the sent information. Step 3, Second and subsequent time calibrations: Each time the Bluetooth communication module successfully synchronizes and calibrates the time, the time interval between the current calibration and the previous calibration is calculated. When the interval is not less than the preset threshold CAL_TH_S, the local time is calibrated and the dynamic correction factor is calculated. When the interval is less than the threshold CAL_TH_S, only the local time is calibrated and the dynamic correction factor is not calculated. The calculated dynamic correction factor is logically judged, and a decision is made on whether to store the correction factor based on the judgment result. Step 4, Offline Time Correction: When reading the local time later, calculate the interval between the current time and the last compensation time. When the interval meets the preset conditions, calculate the compensation value based on the stored dynamic correction factor, correct the local time with the compensation value, and write it into the RTC module to take effect. Step 5: Correction Factor Smoothing Optimization: As the number of calibrations increases, the data storage module accumulates effective correction data. The correction algorithm module uses a preset mathematical model to process the effective correction data, smoothing the dynamic correction factor and gradually improving the time correction accuracy.

[0006] Preferably, the preset mathematical model is selected from any one of the following: arithmetic mean method, exponential moving average method, median filtering, linear least squares method, or Kalman filtering.

[0007] Preferably, the system further includes an anomaly handling module. When the device experiences an abnormal reset or power-on / off, the time of the local RTC module is automatically reset, and the system re-executes the time initialization and subsequent calibration process.

[0008] Preferably, when the time zone information sent from the cloud is inconsistent with the local default time zone, the system initializes the local time, clears all stored correction data, and re-executes the time initialization and subsequent calibration process.

[0009] Preferably, the sign of the dynamic correction factor is used to indicate the direction of the deviation between the local time and the standard time; a positive value indicates that the local time is ahead, and a negative value indicates that the local time is behind.

[0010] Preferably, the external Bluetooth device is a mobile phone. After the Bluetooth communication module successfully connects with the mobile phone via Bluetooth, it obtains the calibration time and time zone information sent from the cloud through the mobile phone.

[0011] Preferably, when performing logical judgment on the dynamic correction factor, if the absolute value of the correction factor is less than or equal to the preset threshold ERROR_TH_S, the correction factor is discarded and the previously stored correction factor is reused; if the absolute value of the correction factor is greater than ERROR_TH_S and less than or equal to the preset threshold DIFF_TH_S, an exception log is recorded and the correction factor is retained; otherwise, the correction factor is stored normally.

[0012] Preferably, in the offline time correction, if the interval between the current time and the last compensation time is negative or less than the dynamic correction factor, the current compensation is deemed invalid and no correction operation is performed.

[0013] Preferably, the correction algorithm module uses a circular buffer to process valid correction data. When the accumulated amount of valid correction data is updated, the oldest stored data is discarded and replaced with the latest valid correction data.

[0014] Preferably, the system is compatible with IoT Bluetooth devices with different hardware characteristics. By accumulating effective calibration data and smoothing and optimizing the dynamic calibration factor, it can offset the drift error of the crystal oscillator in the local RTC module and the time deviation caused by individual differences. Compared with the prior art, the beneficial effects of the present invention are as follows: 1. Achieve offline dynamic correction: Breaking through the traditional time calibration mode that relies on online synchronization, the device does not need to be connected to the Internet in real time. After triggering calibration through Bluetooth communication, it can continuously correct time drift based on dynamic correction factors in the offline state, solving the time accuracy problem in long-term offline scenarios. 2. Accuracy of calibration is improved step by step: Based on the accumulation of big data, the calibration factor is smoothly optimized. The more calibrations are performed and the richer the data is, the closer the calibration factor is to the true error value. The cumulative error over time converges step by step, meeting the requirement of ≤5 seconds for 24-hour timing error as specified in the national standard GB21556-2025. 3. Strong adaptability: By adapting to the crystal oscillator drift characteristics and individual differences of different hardware through dynamic correction factors, it can be applied to a variety of IoT devices such as Bluetooth locks, networked smart locks, and IoT sensors without increasing hardware costs, and has universal value. 4. Enhanced Functional Reliability: Effectively addresses industry pain points such as temporary password expiration due to time errors, reservation rejection, accidental triggering of timed policies, and chaotic audit and evidence collection times, ensuring the stability of core equipment functions and safe use. 5. Low power consumption and high efficiency: It adopts a lightweight mathematical model (such as the arithmetic mean method) and a circular buffer storage mechanism, resulting in extremely low embedded computing power and memory consumption. It is suitable for the resource constraints of IoT devices and is easy to implement in engineering. Attached Figure Description

[0015] Figure 1 This is a system composition block diagram of the present invention; Figure 2 This is a flowchart of the calibration process in this invention; Figure 3 This is a flowchart of the exception handling process in this invention. Detailed Implementation

[0016] Please refer to the attached document. Figure 1 To be continued Figure 3This invention provides an offline device time dynamic correction system based on IoT Bluetooth communication. The system includes an IoT Bluetooth device, a local RTC module, a Bluetooth communication module, a data storage module, and a correction algorithm module. It achieves offline time dynamic correction through the following steps: 1. System Components: IoT Bluetooth Devices: These serve as the primary means of time correction, including devices requiring precise timekeeping such as smart locks and IoT sensors; Local RTC module: Used to record the device's local time, it uses the periodic oscillation of a crystal oscillator to achieve time counting and provides an initial time reference; Bluetooth communication module: used to establish a communication connection with external Bluetooth terminals (such as mobile phones) and receive calibration time and time zone information sent from the cloud; Data storage module: Used to store key data such as calibration history data, dynamic correction factor, last compensation time, and time zone information. A circular buffer is used to update and replace the data. The calibration algorithm module is used for time initialization, calibration factor calculation, offline time compensation, and factor smoothing optimization, and integrates a preset mathematical model to achieve error cancellation.

[0017] Calibration process: (1) Time initialization: When the IoT Bluetooth device is powered on or reset, the local RTC module automatically initializes the time to the preset reference value (such as 2025-01-01 00:00:00) and sets the time zone to the target time zone by default (such as Beijing time in East 8th zone), thus completing the initial state configuration after the system starts.

[0018] (2) Initial Time Calibration: When the Bluetooth communication module successfully establishes a connection with an external Bluetooth terminal (such as a user's mobile phone), it obtains the standard calibration time and time zone information sent from the cloud through the terminal. The calibration algorithm module compares the current time and time zone of the local RTC module with the calibration time and time zone sent from the cloud: If the time zones of the two are inconsistent or the time difference is greater than 1 second, all logic algorithms will be reset, and the local RTC module time will be updated with the calibration time and time zone issued by the cloud to complete the first calibration. If the time zones are consistent and the time difference is ≤1 second, the local time will be updated directly with the cloud-calibrated time, without the need to reset the logic algorithm.

[0019] (3) Second and subsequent time calibrations: Whenever the Bluetooth communication module reconnects to the external terminal and successfully synchronizes the cloud calibration time, the following operations are performed: The calibration algorithm module reads the current time of the local RTC module (referred to as the local time) and calls the last compensation time stored in the data storage module to calculate the time interval between the two calibrations (referred to as the calibration interval). If the calibration interval is less than the preset threshold CAL_TH_S, the local time will only be updated with the cloud calibration time, and the dynamic correction factor will not be calculated to avoid insufficient accuracy caused by short-interval calibration. If the calibration interval is not less than the preset threshold CAL_TH_S, the local time is first updated with the cloud calibration time, and then the dynamic correction factor is calculated based on the deviation between the local time and the calibration time and the calibration interval. The positive and negative values ​​of the dynamic correction factor indicate the direction of the time deviation (positive value indicates that the local time is too fast, and negative value indicates that the local time is too slow). Perform logical judgment on the calculated dynamic correction factor: If the absolute value of the correction factor is less than or equal to the preset threshold ERROR_TH_S, the factor is determined to be unreliable, the factor is discarded, the previously stored correction factor is used, and an exception log is recorded. If the absolute value of the correction factor is greater than ERROR_TH_S and less than or equal to the preset threshold DIFF_TH_S, it is determined that the factor is usable but has a minor anomaly. The factor is retained and the anomaly log is recorded. In other cases, the normal factor is stored in the data storage module, and the last compensation time is updated to the current calibration time.

[0020] (4) Offline time correction: After at least one valid dynamic correction factor storage is completed, when the device is offline, the offline correction process is triggered every time the local time is read: The correction algorithm module reads the current time of the local RTC module and the last compensation time in the data storage module, and calculates the time interval between the two (denoted as the compensation interval). If the compensation interval is negative or less than the currently stored dynamic correction factor, the compensation condition is determined to be unmet and the correction process is terminated. If the compensation interval meets the preset conditions, the compensation value is calculated based on the dynamic correction factor. The sign of the compensation value is consistent with the correction factor, reflecting the length of time that needs to be corrected. If the compensation value is not zero, the current local time is corrected using the compensation value, the corrected new time is written to the local RTC module and takes effect, thus completing this offline time compensation.

[0021] (5) Correction factor smoothing optimization: As the number of calibrations increases, the effective correction factor data accumulated by the data storage module gradually increases. The correction algorithm module calls the preset mathematical model to smooth the historical correction factors, so that the correction factors gradually approach the true error value and improve the correction accuracy. The preset mathematical model can be any one of the following: arithmetic mean method, exponential moving average method (EMA), median filtering, linear least squares method or Kalman filtering, and the present invention prefers the arithmetic mean method. When the amount of accumulated effective correction factor data reaches a preset number N, the average value of all factors is calculated using the arithmetic mean method, and the mean value is used to offset random errors. When a new valid correction factor is added, the oldest stored factor data is replaced by a circular buffer to ensure the real-time performance and validity of data storage and to adapt to the memory limitations of embedded devices.

[0022] 3. Abnormal handling: Abnormal situation 1: When the device experiences an abnormal reset or power-on / off due to hardware failure, misoperation, etc., the local RTC module time is automatically reset, the system triggers re-initialization, and the entire calibration process is re-executed from the time initialization step. Abnormal situation 2: When the time zone corresponding to the calibration time issued by the cloud is inconsistent with the time zone stored locally (such as when the device is migrated across time zones), the system initializes the local time, clears all historical calibration data and dynamic correction factors, and restarts the calibration process from the time initialization step.

[0023] To make the technical solution of the present invention clearer and easier to understand, the specific implementation of the present invention will be described in detail below in conjunction with the application scenarios of Bluetooth smart locks.

[0024] System Configuration: In this embodiment, the IoT Bluetooth device is a Bluetooth smart lock. The local RTC module uses a 32.768K crystal oscillator, the Bluetooth communication module supports the Bluetooth 5.0 protocol, the data storage module uses a 1KB circular buffer, and the correction algorithm module integrates the arithmetic mean method as the correction factor smoothing model. The preset parameters are as follows: Initial base time: 2025-01-01 00:00:00; Default time zone: UTC+8 (Eastern Eight Zone); Calibration interval threshold CAL_TH_S: 86400 seconds (1 day); Error threshold ERROR_TH_S: 1 second; Difference threshold DIFF_TH_S: 3 seconds; Effective correction data volume N: 100 records.

[0025] Specific calibration process: 1. Time initialization: After the Bluetooth smart lock is powered on for the first time, the local RTC module automatically initializes the time to 2025-01-01 00:00:00, sets the time zone to East 8, clears the historical data of the data storage module, and the calibration algorithm module enters the calibration state.

[0026] 2. Initial Time Calibration: On December 10, 2025, the user establishes a connection with the smart lock via Bluetooth on their mobile phone. The phone obtains the standard calibration time (2025-12-10 18:00:59, East 8th time zone) from the cloud and sends it to the smart lock. The calibration algorithm module compares the local initial time (2025-01-01 00:00:00) with the calibration time. Although the time zones are the same, the time difference is much greater than 1 second. Therefore, all logical algorithms are reset, and the local RTC module time is updated to 2025-12-10 18:00:59. The data storage module records this calibration time as the initial compensation time.

[0027] 3. Second Time Calibration: On December 18, 2025, the user will connect to the smart lock again via Bluetooth on their mobile phone. The cloud will then send a standard calibration time of 2025-12-18 18:00:00 (UTC+8). The calibration algorithm module will perform the following operations: The current time read from the local RTC module is 2025-12-18 18:00:27, and the last compensation time in the data storage module is 2025-12-10 18:00:59. The calibration interval is calculated to be 8 days (8×24×3600=691200 seconds), and this interval is not less than CAL_TH_S (86400 seconds). The local time was updated to 2025-12-18 18:00:00 using the cloud-calibrated time, and it was determined that the local time was 27 seconds ahead. Calculate the dynamic correction factor: Based on the calibration interval and time deviation, obtain the time length required for each 1-second deviation. The correction factor is positive (indicating that it is too fast) and stored in the data storage module. At the same time, update the last compensation time to 2025-12-18 18:00:00.

[0028] 4. Offline Time Correction: On December 19, 2025, the smart lock is offline. When the user triggers the unlocking operation, the system reads the local time and initiates correction. The current time read from the local RTC module is 2025-12-19 18:00:00, the last compensation time is 2025-12-18 18:00:00, and the compensation interval is calculated to be 86400 seconds (1 day). The compensation interval is positive and not less than the dynamic correction factor, thus satisfying the compensation condition; Based on the dynamic correction factor, the compensation value is calculated, and it is determined that the local time still tends to be faster. The length of time that needs to be compensated is then calculated. The current local time is corrected using the compensation value, and the corrected time is written to the RTC module to ensure the time accuracy during unlocking verification and the temporary password is valid.

[0029] 5. Correction Factor Smoothing Optimization: As users subsequently connect to the smart lock multiple times via Bluetooth, the system accumulates 100 valid correction data points. The correction algorithm module uses the arithmetic mean method to calculate the average of the 100 correction factors as the optimized dynamic correction factor. A circular buffer is used to replace the oldest data with new data. When the smart lock goes offline again, time compensation is performed based on the optimized correction factor, and the error gradually decreases, approaching the national standard requirement of less than 5 seconds per day.

[0030] Example of exception handling: If the smart lock experiences a hardware reset due to an unexpected power outage during use, the local RTC module will automatically reset to the initial reference time after power is restored. The system will then re-execute the time initialization process and perform the first calibration upon the next Bluetooth connection. If the smart lock is transported to the West 5 time zone for use, the cloud will send a time zone of West 5 when the user connects next time, which is inconsistent with the local default East 8 time zone. The system will initialize the local time to the reference value, clear all historical calibration data, and start the calibration process again from the first time.

Claims

1. An offline device time dynamic correction system based on Internet of Things (IoT) Bluetooth communication, characterized in that, The system includes an IoT Bluetooth device, a local RTC module, a Bluetooth communication module, a data storage module, and a correction algorithm module. It is used to dynamically correct the device's time in offline mode, and includes the following steps: Step 1: Time Initialization: After the device is powered on or reset, the local RTC module initializes the time to the preset reference value and sets the default time zone; Step 2, Initial Time Calibration: When the Bluetooth communication module successfully connects to the external Bluetooth device, it receives the calibration time and corresponding time zone information sent from the cloud, compares the current time and time zone of the local RTC module with the sent information, and if they are inconsistent, it resets all logic algorithms and calibrates the local time using the sent information. Step 3, Second and subsequent time calibrations: Each time the Bluetooth communication module successfully synchronizes and calibrates the time, the time interval between the current calibration and the previous calibration is calculated. When the interval is not less than the preset threshold CAL_TH_S, the local time is calibrated and the dynamic correction factor is calculated. When the interval is less than the threshold CAL_TH_S, only the local time is calibrated and the dynamic correction factor is not calculated. The calculated dynamic correction factor is logically judged, and a decision is made on whether to store the correction factor based on the judgment result. Step 4, Offline Time Correction: When reading the local time later, calculate the interval between the current time and the last compensation time. When the interval meets the preset conditions, calculate the compensation value based on the stored dynamic correction factor, correct the local time with the compensation value, and write it into the RTC module to take effect. Step 5: Correction Factor Smoothing Optimization: As the number of calibrations increases, the data storage module accumulates effective correction data. The correction algorithm module uses a preset mathematical model to process the effective correction data, smoothing the dynamic correction factor and gradually improving the time correction accuracy.

2. The offline device time dynamic correction system based on IoT Bluetooth communication according to claim 1, characterized in that, The preset mathematical model is selected from any one of the following: arithmetic mean method, exponential moving average method, median filtering, linear least squares method, or Kalman filtering.

3. The offline device time dynamic correction system based on IoT Bluetooth communication according to claim 1, characterized in that, The system also includes an anomaly handling module. When the device experiences an abnormal reset or power failure, the time of the local RTC module is automatically reset, and the system re-executes the time initialization and subsequent calibration process.

4. The offline device time dynamic correction system based on IoT Bluetooth communication according to claim 1, characterized in that, When the time zone information sent from the cloud is inconsistent with the local default time zone, the system initializes the local time, clears all stored correction data, and re-executes the time initialization and subsequent calibration process.

5. The offline device time dynamic correction system based on IoT Bluetooth communication according to claim 1, characterized in that, The sign of the dynamic correction factor is used to indicate the direction of the deviation between the local time and the standard time. A positive value indicates that the local time is ahead, and a negative value indicates that the local time is behind.

6. The offline device time dynamic correction system based on IoT Bluetooth communication according to claim 1, characterized in that, The external Bluetooth device is a mobile phone. After the Bluetooth communication module successfully connects with the mobile phone via Bluetooth, it obtains the calibration time and time zone information sent from the cloud through the mobile phone.

7. The offline device time dynamic correction system based on IoT Bluetooth communication according to claim 1, characterized in that, When performing logical judgment on the dynamic correction factor, if the absolute value of the correction factor is less than or equal to the preset threshold ERROR_TH_S, the correction factor is discarded and the previously stored correction factor is used; if the absolute value of the correction factor is greater than ERROR_TH_S and less than or equal to the preset threshold DIFF_TH_S, an exception log is recorded and the correction factor is retained; otherwise, the correction factor is stored normally.

8. The offline device time dynamic correction system based on IoT Bluetooth communication according to claim 1, characterized in that, In the offline time correction, if the interval between the current time and the last compensation time is negative or less than the dynamic correction factor, the current compensation is deemed invalid and no correction operation is performed.

9. The offline device time dynamic correction system based on IoT Bluetooth communication according to claim 1, characterized in that, The correction algorithm module uses a circular buffer to process valid correction data. When the amount of accumulated valid correction data is updated, the oldest stored data is discarded and replaced with the latest valid correction data.

10. The offline device time dynamic correction system based on IoT Bluetooth communication according to claim 1, characterized in that, The system is compatible with IoT Bluetooth devices with different hardware characteristics. By accumulating effective calibration data and smoothing and optimizing the dynamic calibration factor, it can offset the drift error of the crystal oscillator in the local RTC module and the time deviation caused by individual differences.