NB-IoT-based intelligent water meter data monitoring system
By decoding the base station signal frame number and associating it with the local clock value, calculating and compensating for clock drift, and dynamically adjusting the sleep interval, the synchronization problem caused by clock drift in smart water meters is solved, achieving long-term reliable operation and data continuity of the equipment.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-22
- Publication Date
- 2026-03-31
AI Technical Summary
Existing smart water meters suffer from accumulated timing errors due to crystal oscillator clock drift, causing the devices to fail to reliably wake up and communicate with the network, entering a "ghost offline" state, which affects the continuity and integrity of water management data.
By decoding the system frame number in the downlink signal of the base station as a network timestamp, associating it with the local clock value, calculating the clock drift rate and compensating for it, and dynamically adjusting the sleep interval, a closed-loop clock calibration and data monitoring cycle is formed to ensure that the device is synchronized with the network time.
This enables long-term reliable operation of smart water meters under low power consumption conditions, avoids silent failures caused by clock drift, and ensures the continuity and integrity of water management data.
Smart Images

Figure CN121558144B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of Internet of Things (IoT) communication technology and metering instrument technology, specifically to a smart water meter data monitoring system based on NB-IoT. Background Technology
[0002] With the widespread application of IoT technology in smart cities, NB-IoT-based smart water meters have become core devices for digital water management. The core design challenge of these devices lies in the fact that to achieve a battery life of 6-10 years, an ultra-low power consumption strategy of deep sleep (such as PSM mode) and periodic wake-up is necessary; while to achieve remote meter reading and monitoring, it is essential to ensure that the device can reliably wake up and communicate with the network at preset times.
[0003] Current technologies generally rely on a local clock provided by a low-cost crystal oscillator inside the water meter to keep track of time and control the sleep cycle. However, over long-term operation, clock drift errors caused by temperature changes and natural aging accumulate, leading to a gradual deviation between the device's internal time and the network standard time. When the deviation exceeds the communication window tolerance, the device will "oversleep" and miss network paging, entering a "ghost offline" state—a state where it cannot be remotely managed, data is interrupted, but the device is not physically damaged. This problem is characterized by its high degree of concealment, its occurrence in large numbers, and its inevitable emergence with increasing service life, making it a fundamental technical bottleneck restricting the long-term reliable operation of massive numbers of IoT terminals. Summary of the Invention
[0004] The purpose of this invention is to provide a smart water meter data monitoring system based on NB-IoT to solve the problems mentioned above.
[0005] The objective of this invention can be achieved through the following technical solutions:
[0006] The NB-IoT-based smart water meter data monitoring system includes:
[0007] The initial time reference establishment module decodes the first system frame number from the downlink wireless signal of the base station as the first network timestamp after the smart water meter successfully connects to the NB-IoT network for the first time and completes the initial data reporting. At the same time, it reads the first count value of the internal clock of the smart water meter as the first local clock value and stores the first network timestamp and the first local clock value as a reference time pair.
[0008] The periodic time information acquisition module, after each subsequent data monitoring and reporting task performed by the smart water meter and after confirming successful reporting, decodes the current system frame number from the downlink wireless signal of the base station as the current network timestamp, and synchronously reads the current count value of the internal clock as the current local clock value. It associates the current network timestamp and the current local clock value to form a time acquisition pair and stores them in the historical time pair queue.
[0009] The clock drift calculation and calibration judgment module calculates the unit time drift rate of the internal clock relative to the network time based on at least two time acquisition pairs stored in the historical time pair queue, and compares the unit time drift rate with a preset drift threshold. When the unit time drift rate exceeds the drift threshold, a calibration enable signal is generated.
[0010] The sleep interval dynamic compensation module, in response to the calibration enable signal, performs reverse compensation calculation on the preset nominal sleep interval based on the drift rate per unit time to obtain the actual sleep interval;
[0011] The closed-loop monitoring execution module configures the actual sleep interval as the duration for the smart water meter to enter sleep mode next time. After the sleep period ends, it wakes up the smart water meter and returns to perform periodic time information collection and data monitoring reporting, forming a closed-loop clock calibration and data monitoring cycle.
[0012] As a further aspect of the present invention: the storage procedure for the reference time pair is as follows:
[0013] In the same network connection-maintained state after initial data reporting, continuously decode a predetermined number of downlink radio signal frames;
[0014] Extract the system frame number from each of the predetermined number of downlink radio signal frames, and verify the continuity of the values of these system frame numbers.
[0015] From the system frame numbers that pass the continuity check, select the middle system frame number as the final first network timestamp;
[0016] The final first network timestamp is associated with the first local clock value and stored as a base time pair.
[0017] As a further aspect of the present invention: the step of decoding the current system frame number from the downlink wireless signal of the base station as the current network timestamp specifically includes:
[0018] After confirming successful reporting, continuously monitor and decode a predetermined number of downlink wireless signal frames;
[0019] Extract the system frame number carried by a predetermined number of downlink radio signal frames, and verify that the values of these system frame numbers are strictly continuously increasing.
[0020] Once the verification is successful, the system frame number with the middle sequence number among a predetermined number of downlink wireless signal frames is selected as the current network timestamp.
[0021] As a further aspect of the present invention: the calculation of the unit-time drift rate of the internal clock relative to the network time specifically includes:
[0022] Extract the most recent preset number of time collection pairs from the historical time pair queue in chronological order;
[0023] For each time-collected pair, calculate the instantaneous ratio;
[0024] Sort all instantaneous ratios by numerical value and remove the maximum and minimum instantaneous ratios of a preset number from the sort;
[0025] Add up all the remaining instantaneous ratios and divide by the remaining quantity; the result is the drift rate per unit time.
[0026] As a further aspect of the present invention: the generation of the calibration enable signal specifically includes:
[0027] When the drift rate per unit time exceeds the drift threshold, an over-limit flag is accumulated in the temporary counter;
[0028] After each calculation of the new drift rate per unit time, it is determined whether the number of out-of-limit markers in the temporary counter has reached the preset cumulative threshold.
[0029] If the cumulative threshold is reached, a calibration enable signal is output and the temporary counter is cleared.
[0030] Fourth step: If the cumulative threshold is not reached, retain the current number of over-limit markers and wait for the next drift rate calculation.
[0031] As a further aspect of the present invention: the reverse compensation calculation of the preset nominal sleep interval based on the unit time drift rate specifically includes:
[0032] When a calibration enable signal is received, the ratio of the drift rate per unit time to the value one is calculated to obtain the initial compensation factor.
[0033] Read the historical compensation factors stored after the last compensation calculation, and calculate the weighted average of the initial compensation factor and the historical compensation factors to generate the actual compensation factor for this time.
[0034] Divide the preset nominal dormancy interval by the actual compensation factor to obtain the intermediate interval value;
[0035] The intermediate interval value is then weighted and averaged again with the nominal dormancy interval to obtain the actual dormancy interval.
[0036] As a further aspect of the present invention: the step of waking up the smart water meter after the sleep period ends specifically includes:
[0037] Before entering sleep mode, the actual sleep interval value is written into the timer's period register, and the timer's trigger mode is set to single trigger.
[0038] After the timer is started, the main control chip of the smart water meter is immediately switched to deep sleep mode, at which point only the timer continues to run;
[0039] When the timer count reaches the value of the actual sleep interval, a hardware interrupt signal is generated;
[0040] The hardware interrupt signal triggers the main control chip to exit the deep sleep state, complete the wake-up process, and clear the interrupt flag of the timer.
[0041] As a further aspect of the present invention: the closed-loop clock calibration and data monitoring loop specifically includes:
[0042] After the wake-up process is completed, the current storage capacity of the historical time queue is checked first.
[0043] If the storage capacity does not reach the queue limit, a new round of data monitoring and reporting process will be started directly;
[0044] If the storage capacity has reached the queue limit, the earliest time collection pair generated in the historical time pair queue will be deleted before starting a new round of processes.
[0045] After the queue management operation is completed, the initial operation of the periodic time information collection module is automatically triggered and executed, thereby restarting the data collection, reporting and subsequent closed-loop analysis process.
[0046] The beneficial effects of this invention are:
[0047] (1) This invention uses the inherent, high-precision system frame number in the downlink signal of the base station as a free and stable network time source. By continuously monitoring and compensating for local clock drift, the device's sleep-wake rhythm can dynamically follow the network time reference. This ensures that even in low-precision crystal oscillators and complex environments, the water meter's listening window can remain synchronized with the network paging window for a long time, avoiding the silent failure of a batch of devices due to "oversleeping" and ensuring the continuity and integrity of water management data.
[0048] (2) The entire calibration process utilizes the downlink signals in the original communication links of the equipment without any additional air interface overhead; the calculation is only performed during the brief wake-up period after each normal report, and a lightweight filtering and weighted average algorithm is used, resulting in minimal computation and storage overhead; the calibration decision adopts a continuous over-limit judgment mechanism to avoid erroneous adjustments caused by instantaneous interference. This "passive sensing, event-driven, on-demand calibration" design makes high-reliability time synchronization no longer dependent on external clocks or frequent active synchronization signaling, achieving a leap in long-term system stability while maintaining the original microampere-level average power consumption and battery life. Attached Figure Description
[0049] The invention will now be further described with reference to the accompanying drawings.
[0050] Figure 1 This is a system block diagram of the present invention. Detailed Implementation
[0051] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0052] Please see Figure 1 As shown, this invention is a smart water meter data monitoring system based on NB-IoT, comprising:
[0053] The initial time reference establishment module decodes the first system frame number from the downlink wireless signal of the base station as the first network timestamp after the smart water meter successfully connects to the NB-IoT network for the first time and completes the initial data reporting. At the same time, it reads the first count value of the internal clock of the smart water meter as the first local clock value and stores the first network timestamp and the first local clock value as a reference time pair.
[0054] The periodic time information acquisition module, after each subsequent data monitoring and reporting task performed by the smart water meter and after confirming successful reporting, decodes the current system frame number from the downlink wireless signal of the base station as the current network timestamp, and synchronously reads the current count value of the internal clock as the current local clock value. It associates the current network timestamp and the current local clock value to form a time acquisition pair and stores them in the historical time pair queue.
[0055] The clock drift calculation and calibration judgment module calculates the unit time drift rate of the internal clock relative to the network time based on at least two time acquisition pairs stored in the historical time pair queue, and compares the unit time drift rate with a preset drift threshold. When the unit time drift rate exceeds the drift threshold, a calibration enable signal is generated.
[0056] The sleep interval dynamic compensation module, in response to the calibration enable signal, performs reverse compensation calculation on the preset nominal sleep interval based on the drift rate per unit time to obtain the actual sleep interval;
[0057] The closed-loop monitoring execution module configures the actual sleep interval as the duration for the smart water meter to enter sleep mode next time. After the sleep period ends, it wakes up the smart water meter and returns to perform periodic time information collection and data monitoring reporting, forming a closed-loop clock calibration and data monitoring cycle.
[0058] In the initial time base establishment module, after the smart water meter completes its initial data reporting, the current wireless connection with the base station is maintained without immediate release. During this continuous connection, the device firmware initiates a dedicated decoding program that continuously captures and parses adjacent downlink wireless signals. Specifically, this program sets a fixed number of decoding frames, such as 5 frames, to ensure that each of these 5 consecutive downlink wireless signal frames is decoded sequentially to obtain the physical layer information contained within.
[0059] Next, from the five downlink radio signal frames obtained through continuous decoding, the system frame number carried in each frame structure is extracted sequentially. Then, a continuity check procedure is executed. The specific method of this check procedure is as follows: the five extracted system frame numbers are arranged in the order of their decoding, and the numerical difference between each subsequent system frame number and the preceding system frame number is calculated sequentially. Each difference is checked to ensure it is strictly equal to 1. Only when all four consecutive difference calculations result in 1 is the set of system frame numbers considered to have passed the numerical continuity check, indicating that the radio signal was stable and no frames were lost during decoding. If any difference is not 1, the current decoding process is considered invalid, and the continuous decoding and extraction steps must be repeated.
[0060] Among the five system frame numbers that pass the continuity check, the system frame number in the middle position is selected as the final first network timestamp. For example, if the five system frame numbers arranged in decoding order are N, N+1, N+2, N+3, and N+4, then the third one, N+2, is selected as the final first network timestamp. This method aims to reduce the random errors that may be caused by momentary disturbances during a single decoding process by taking the middle value.
[0061] Finally, an associated storage operation is performed. The final first network timestamp determined above is taken as a data item and, together with the first count value read from the smart meter's internal clock circuit at the same moment the intermediate frame signal is decoded, forms a data pair. This data pair, in a structured form, such as a record containing two fields, is written to a designated area in the device's non-volatile memory. This stored record is defined as the reference time pair used in subsequent processes.
[0062] In the periodic time information acquisition module, after the smart water meter completes a data monitoring and reporting task and receives a clear success confirmation message from the network side, the process of acquiring the current network timestamp is immediately initiated. This process first controls the wireless communication unit to remain in a connected state, preventing it from immediately entering sleep mode, and then starts a specific listening program. This program sets a specific number of decoding frames, such as 3 frames, and then, within consecutive communication time slots, it captures and decodes three adjacent downlink wireless signal frames to obtain their complete frame structure information.
[0063] After decoding three downlink radio signal frames, the system frame number carried in each frame is extracted from a specific field. Then, a rigorous continuity verification is performed. This verification method involves arranging the three extracted system frame numbers in the order they were decoded, resulting in an ordered list. Next, the difference between the second and first system frame numbers in the list is calculated, and simultaneously, the difference between the third and second system frame numbers is also calculated. Only when both differences are strictly equal to 1 is the set of system frame numbers considered to have passed the "strictly continuous increment" verification, indicating that the radio link is stable and frame synchronization is error-free within the short listening window. If either difference is not equal to 1, the verification fails, the current process terminates, and no time acquisition pair is generated to avoid introducing incorrect time bases due to transient signal anomalies.
[0064] Assuming successful verification, the middle system frame number is selected from the three confirmed, strictly ascending system frame numbers as the current network timestamp used for this data collection. Specifically, the second system frame number is selected from the three numbers arranged in decoding order. For example, if the decoded frame number sequence is A, A+1, A+2, then A+1 is selected as the current network timestamp. The purpose of using the middle value instead of the first or last frame number is to average out the minute time-series jitter that may exist at the beginning and end of the frame decoding process, thereby obtaining a more stable network time reference value that better represents the central moment of this communication event.
[0065] In the clock drift calculation and calibration judgment module, the process of calculating the unit-time drift rate of the internal clock relative to the network time begins with the selection of data from the historical time pair queue. The historical time pair queue stores time acquisition pairs in chronological order. When calculating the drift rate, a specified number of time acquisition pairs are extracted from the end of the queue, i.e., the most recently stored position. This specified number is a pre-set fixed value, such as 10. This means that a total of the 10 most recently successfully acquired and stored time acquisition pairs are extracted for this calculation. Each time acquisition pair contains a network timestamp and a corresponding local clock count value.
[0066] After obtaining the 10 time-series data pairs, calculate an instantaneous ratio for each pair. This ratio should be constant at 1 under ideal, drift-free conditions. Repeat this calculation for all 10 time-series data pairs to obtain 10 instantaneous ratio values.
[0067] These 10 instantaneous ratio values are preprocessed to enhance their robustness against interference. Specifically, the 10 values are sorted in descending order. After sorting, a specified number of values are removed from both ends of the sequence. For example, the two largest and two smallest values are removed from the sorted sequence. This step aims to eliminate outlier data points that may deviate significantly from the normal range due to single-transmission decoding errors, transient signal interference, or other accidental factors. After removing outliers, the sequence will contain 6 instantaneous ratio values.
[0068] Finally, the final unit-time drift rate is calculated based on the preprocessed data. The remaining six instantaneous ratio values are summed together. This sum is then divided by the number of remaining values, which is 6, and the resulting arithmetic mean is determined as the calculated unit-time drift rate. This value represents the ratio between the average internal clock rate, assessed based on recent historical data, and the network's standard time rate.
[0069] The process of generating the calibration enable signal is based on a continuous judgment-based decision logic, designed to avoid unnecessary calibrations triggered by accidental fluctuations in a single calculation. This process maintains a temporary counter, initially set to zero. After each calculation of the drift rate per unit time, the drift rate is compared to a preset drift threshold. This drift threshold is a fixed value, for example, set to ±0.05% relative to a reference value of 1; that is, a drift rate greater than 1.0005 or less than 0.9995 is considered out of range. If the calculated drift rate per unit time exceeds this threshold, an accumulation operation is performed, incrementing the value in the temporary counter by 1.
[0070] After the cumulative operation, or if the drift rate per unit time does not exceed the limit, the value in the temporary counter is immediately evaluated. The evaluation is based on another preset cumulative threshold, for example, set to 3. The evaluation logic is: check if the current value in the temporary counter has reached or exceeded this cumulative threshold of 3. If it has, a valid calibration enable signal is generated, which is then passed to the subsequent sleep interval compensation process. Simultaneously, after outputting the calibration enable signal, the temporary counter must be cleared to prepare for the next evaluation cycle.
[0071] If the current value in the temporary counter has not yet reached the cumulative threshold of 3, the decision logic will not output a calibration enable signal. In this case, the temporary counter will maintain its current cumulative value until the next new unit-time drift rate calculation is completed and the above comparison and judgment process is executed again. This mechanism ensures that calibration is only triggered when the internal clock drift is consistently determined to be outside the allowable range in multiple consecutive calculations, thereby improving the system's robustness to random errors and the reliability of calibration decisions.
[0072] In the sleep interval dynamic compensation module, the compensation calculation process is initiated upon receiving a valid calibration enable signal. The first step is to calculate the initial compensation factor. The input used for this calculation is the currently calculated unit time drift rate. Specifically, the unit time drift rate is used as the dividend, and the value 1 is used as the divisor, to perform a division operation. For example, if the unit time drift rate is 1.0003, then the calculated initial compensation factor is 1.0003. This factor directly reflects the current measured speed of the internal clock.
[0073] The second step is to generate the actual compensation factor to be used in this operation. This step aims to smooth the change in compensation amount and avoid drastic adjustments to the sleep interval due to accidental fluctuations in a single drift rate calculation. First, a value called the historical compensation factor is read from the device's non-volatile memory. This value is the actual compensation factor result stored after the last successful compensation calculation. If it is the first compensation, the historical compensation factor is preset to a value of one. Then, a weighted average is calculated by combining the initial compensation factor obtained in the first step with the read historical compensation factor. The specific implementation of the weighted average is as follows: multiply the initial compensation factor by a first weight value, and simultaneously multiply the historical compensation factor by a second weight value. Then, add these two products together, and finally divide the sum by the sum of the first and second weights. For example, if the first weight is set to 1 and the second weight is set to 3, then the actual compensation factor is equal to the sum of (initial compensation factor multiplied by 1 plus historical compensation factor multiplied by 3) divided by 4. The calculated result is the actual compensation factor for this operation.
[0074] The third step is to calculate an intermediate interval value. This step involves calculating the preset nominal sleep interval, which is the fixed sleep duration set by the smart water meter under ideal conditions without clock drift, for example, 86,400,000 internal clock count units (corresponding to 24 hours), with the actual compensation factor obtained in the second step. The calculation method is as follows: use the nominal sleep interval as the dividend and the actual compensation factor as the divisor, and perform a division operation. The resulting quotient is the intermediate interval value. Mathematically, this value is equivalent to directly dividing the nominal sleep interval by the actual compensation factor.
[0075] The fourth step is to determine the final actual sleep interval. This step aims to constrain the intermediate interval value obtained in the third step, preventing the compensated sleep interval from deviating too far from the nominal value and introducing additional control risks. The specific method is to perform a weighted average calculation again on the intermediate interval value calculated in the third step and the original nominal sleep interval. For example, if the weight of the intermediate interval value is set to 2 and the weight of the nominal sleep interval to 1, then the intermediate interval value is multiplied by 2, the nominal sleep interval is multiplied by 1, and the two products are added together. Finally, the sum is divided by the sum of the weights, 3. The result of this weighted average calculation is the final actual sleep interval obtained from this compensation calculation, and this actual sleep interval is output for configuring the next sleep behavior. Simultaneously, the actual compensation factor calculated in the second step is updated and stored in non-volatile memory, replacing the old historical compensation factor, for use in the next compensation calculation.
[0076] In the closed-loop monitoring execution module, during the process of configuring the device to sleep based on the calculated actual sleep interval, the hardware timer is first set. Specifically, before the smart water meter's main control chip decides to enter sleep mode, the software program writes the value of the actual sleep interval, in the form of clock count units, into the periodic reload register of an independent low-power timer inside the main control chip. Next, the timer's operating mode is configured to a single-trigger mode, meaning it automatically stops after reaching the set value and generating an interrupt, rather than repeating periodically. After this configuration, the software command starts the timer, causing it to begin counting from zero.
[0077] After the timer starts, the main control chip immediately executes an instruction to enter a deep sleep state. This instruction shuts down the power to the main control chip core, most peripherals, and memory, retaining only a very small portion of circuitry necessary to maintain minimum functionality, including the aforementioned independent timer, real-time clock, and logic units for receiving interrupt signals. In this state, the overall current consumption drops to the microamplitude level, while the timer continues to run using an independent low-speed clock source, unaffected by the main control chip's sleep state, thus accurately measuring the elapsed sleep time.
[0078] When the accumulated count value of the independent timer since startup equals the actual sleep interval value previously written to the period register, the timer's compare-match logic is triggered. This logic automatically generates a high-level active hardware interrupt signal, which is directly connected to the main control chip's dedicated wake-up pin. This hardware interrupt signal, as a wake-up event, triggers the main control chip's internal power-on reset and state recovery sequence, causing it to exit deep sleep, power on the kernel and necessary peripherals, and resume program execution from a pre-specified memory address, thus completing the wake-up process. After the program resumes execution, one of the first operations is to write a specific value to the timer's status register to clear the interrupt flag generated by this compare-match, preparing for the next timer configuration.
[0079] After the wake-up process is complete, the program flow immediately enters the closed-loop maintenance phase. This phase first performs a status check on the data queue. Specifically, it accesses the storage area of the historical time pair queue and reads the counter value recording the number of currently stored time collection pairs. This counter value is compared with a preset queue upper limit. This upper limit is a fixed constant, such as 50, which specifies the maximum number of time collection pairs the historical time pair queue can hold.
[0080] Based on the inspection results, the program executes different branch operations. If the current storage quantity counter value is less than the queue limit of 50, indicating that there is still space in the queue, the program does not need to delete data and directly jumps to the standard process entry point for executing a new round of data monitoring and reporting. This standard process includes the sequence of operations for collecting water flow data, reporting via the NB-IoT network, and subsequently collecting time information.
[0081] If the current storage count counter value is equal to the queue's maximum value of 50, it indicates that the queue is full. Queue management must be performed to free up space before initiating a new round of standard procedures. The specific steps for management are as follows: First, identify the earliest time-collected pair in the historical time pair queue. Since the queue is arranged chronologically, this is usually the first record stored in the queue. Then, delete this record from the queue storage area. Deletion can be achieved by shifting all subsequent records forward one position to overwrite the original record, or by moving the head pointer in a circular queue structure. Subsequently, decrement the storage count counter value by 1 to reflect the actual number of records after the deletion operation.
[0082] Whether entering directly or after deletion, the program automatically triggers and begins a new round of data monitoring and time information acquisition after completing the necessary queue status checks and maintenance. This marks the end of one sleep cycle and the seamless transition to the beginning of the next. The time information acquired in the new cycle will be stored in the queue and used for future drift calculations and calibration. This cycle repeats continuously, forming a complete, self-sustaining closed-loop clock calibration and data monitoring loop, enabling the device to automatically correct clock deviations and maintain reliable synchronization with the network during long-term operation.
[0083] The working principle of this invention is as follows: First, when the device first joins the network, multiple downlink wireless frames are continuously decoded, their system frame number continuity is verified, and the median value is selected as the first network timestamp, which is then associated with the local clock value and stored as a reference time pair. Subsequently, after each successful data report, the current network timestamp and the local clock value are obtained in the same way to form a time acquisition pair, which is stored in the historical queue. Then, based on multiple time acquisition pairs in the historical queue, the unit time drift rate is obtained by calculating the instantaneous ratio, sorting and removing outliers, and then calculating the average value. A continuous over-limit cumulative decision mechanism is used to determine whether to generate a calibration enable signal. When calibration is required, a compensation factor is calculated based on the drift rate, and a weighted average smoothing process is used to reverse-compensate the preset nominal sleep interval to obtain the actual sleep interval. Finally, a low-power timer is configured using this actual sleep interval to control deep sleep and wake-up. After wake-up, historical data is automatically managed according to the queue capacity, triggering a new round of data acquisition and reporting, thus forming a complete closed loop that continuously monitors clock deviation and dynamically adjusts the sleep rhythm, ensuring that the water meter maintains long-term reliable synchronization with the network under ultra-low power consumption.
[0084] The foregoing has provided a detailed description of one embodiment of the present invention, but this description is merely a preferred embodiment and should not be construed as limiting the scope of the invention. All equivalent variations and modifications made within the scope of the claims of this invention should still fall within the patent coverage of this invention.
Claims
1. A NB-IoT based smart water meter data monitoring system, characterized in that, The application comprises: An initial time reference establishing module, which, after the smart water meter is successfully connected to the NB-IoT network for the first time and initial data reporting is completed, decodes a first system frame number from a wireless signal transmitted by a base station to obtain a first network timestamp, reads a first count value of an internal clock of the smart water meter to obtain a first local clock value, and stores the first network timestamp and the first local clock value in association as a reference time pair; A periodic time information acquisition module, which, after the smart water meter performs a data monitoring and reporting task each time and confirms successful reporting, decodes a current system frame number from a wireless signal transmitted by a base station to obtain a current network timestamp, synchronously reads a current count value of the internal clock to obtain a current local clock value, forms a time acquisition pair by associating the current network timestamp and the current local clock value, and stores the time acquisition pair in a historical time pair queue; A clock drift calculation and calibration judgment module, which, based on at least two time acquisition pairs stored in the historical time pair queue, calculates a unit time drift rate of the internal clock relative to network time, and compares the unit time drift rate with a preset drift threshold value, and generates a calibration enable signal when the unit time drift rate exceeds the drift threshold value; The calculation of the unit time drift rate of the internal clock relative to network time specifically comprises: extracting a preset number of time acquisition pairs in chronological order from the historical time pair queue; calculating an instantaneous rate for each time acquisition pair; sorting all the instantaneous rates according to their numerical values, and removing a preset number of the largest and smallest instantaneous rates in the sorting; adding all the remaining instantaneous rates and dividing the sum by the remaining number, and taking the result as the unit time drift rate; A sleep interval dynamic compensation module, which, in response to the calibration enable signal, performs reverse compensation calculation on a preset nominal sleep interval according to the unit time drift rate to obtain an actual sleep interval; The reverse compensation calculation on the preset nominal sleep interval according to the unit time drift rate specifically comprises: when the calibration enable signal is received, calculating a ratio of the unit time drift rate to the value one to obtain an initial compensation factor; reading a historical compensation factor stored after the last compensation calculation, performing weighted averaging of the initial compensation factor and the historical compensation factor to generate an actual compensation factor for this time; dividing the preset nominal sleep interval by the actual compensation factor to obtain an intermediate interval value; performing weighted averaging of the intermediate interval value and the nominal sleep interval again, and taking the calculation result as the actual sleep interval; A closed-loop monitoring and execution module, which configures the actual sleep interval as a duration for the smart water meter to enter a sleep state next time, wakes up the smart water meter after the sleep ends, and returns to perform periodic time information acquisition and data monitoring and reporting, thereby constituting a closed-loop clock calibration and data monitoring cycle. 2.The NB-IoT based smart water meter data monitoring system of claim 1, wherein, The storage process of the reference time pair comprises: under the same network connection maintaining state after the initial data reporting is completed, continuously decoding a predetermined number of downlink wireless signal frames; from the predetermined number of downlink wireless signal frames, extracting their respective system frame numbers and verifying the numerical continuity of the system frame numbers; from the system frame numbers that pass the continuity verification, selecting a system frame number in the middle as the final first network timestamp; The final first network timestamp is associated with the first local clock value and stored as a reference time pair. 3.The NB-IoT based smart water meter data monitoring system of claim 1, wherein, The current system frame number is obtained by decoding the wireless signal from the base station as the current network timestamp, and specifically includes: After confirming the successful reporting, continuously monitoring and continuously decoding a predetermined number of downlink wireless signal frames; Extracting the system frame numbers carried by the predetermined number of downlink wireless signal frames, and verifying whether the values of these system frame numbers are strictly and continuously increasing; When the verification is passed, the system frame number in the middle of the predetermined number of downlink wireless signal frames is selected as the current network timestamp. 4.The NB-IoT based smart water meter data monitoring system of claim 1, wherein, The generation of the calibration enable signal specifically includes: When the unit time drift rate exceeds the drift threshold, a one-time out-of-limit flag is accumulated in the temporary counter; After calculating the new unit time drift rate each time, it is judged whether the number of out-of-limit flags in the temporary counter reaches the preset accumulation threshold; If the accumulation threshold is reached, the calibration enable signal is output, and the temporary counter is cleared; The fourth step, if the accumulation threshold is not reached, the current number of out-of-limit flags is retained, and the next drift rate calculation is waited for judgment. 5.The NB-IoT based smart water meter data monitoring system of claim 1, wherein, The smart water meter is woken up after the sleep is ended, and specifically includes: Before entering the sleep, the value of the actual sleep interval is written into the period register of the timer, and the trigger mode of the timer is set to single trigger; After starting the timer, the main control chip of the smart water meter is immediately switched to a deep sleep state, at which time only the timer remains running; When the timer count reaches the value of the actual sleep interval, a hardware interrupt signal is generated; The hardware interrupt signal triggers the main control chip to exit the deep sleep state, completes the wake-up process, and clears the interrupt flag bit of the timer. 6.The NB-IoT based smart water meter data monitoring system of claim 1, wherein, The closed-loop clock calibration and data monitoring cycle is constructed, and specifically includes: After completing the wake-up process, first check the current storage capacity of the historical time pair queue; If the storage capacity does not reach the upper limit of the queue, directly start a new round of data monitoring reporting process; If the storage capacity has reached the upper limit of the queue, delete the time collection pair with the earliest generation time in the historical time pair queue before starting a new round of process; After completing the queue management operation, automatically trigger and execute the initial operation of the periodic time information acquisition module, so as to restart the data acquisition, reporting and subsequent closed-loop analysis process.
Citation Information
Patent Citations
Calibration device and method and computer readable storage medium
CN112230711A
Tiantong satellite Internet-of-things terminal low-power-consumption wake-up clock pre-compensation device and method
CN114025421A