A clock synchronization circuit and synchronization method between Internet of Things (IoT) devices
By connecting the microcontroller to the positioning module via the USART interface, and utilizing the clock pulse output of the positioning module and the timer frequency division adjustment, the problems of large clock synchronization error and high cost in the Internet of Things are solved, achieving high-precision and low-cost clock synchronization.
Patent Information
- Application Number
- CN202611265994.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-20
- Publication Date
- 2026-11-17
AI Technical Summary
Existing IoT clock synchronization technologies suffer from large errors and high costs. In particular, the synchronization error of the IEEE 1588 PTP protocol is ≥ ±1.5μs and consumes a lot of CPU resources. Temperature-compensated crystal oscillators have limited accuracy in temperature drift compensation and are also expensive.
By connecting the microcontroller to the positioning module via the USART interface, the clock pulse output of the positioning module is used to achieve clock synchronization at the second and microsecond levels. Combined with the adjustment of the timer divider value, high-precision clock synchronization is achieved.
It achieves a synchronization effect with a clock synchronization error of less than 1μs, while saving costs and not adding any additional electronic components.
Smart Images

Figure CN123122718A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technology, specifically to a clock synchronization circuit and synchronization method between Internet of Things (IoT) devices. Background Technology
[0002] Clock synchronization between IoT devices refers to the technical means to calibrate the local clocks of multiple terminal devices distributed in different locations in an IoT system, such as sensors, controllers, gateways, and servers, to the same unified time reference.
[0003] Currently, the mainstream technologies for IoT clock synchronization can be divided into two categories: One type uses improved time synchronization protocols such as the IEEE 1588 PTP protocol. A representative paper is Rajan, A. et al. "Adaptive Clock Synchronization in IoT Networks Using software-based PTP" (IEEE IoT Journal, 2022). Its technical solution is to dynamically adjust the clock offset compensation algorithm in software to achieve microsecond-level synchronization at the application layer. Its core drawback is that network jitter causes a synchronization error of ≥±1.5μs, and the protocol stack processing delay consumes 20-30% of CPU resources. Another type uses a dedicated clock chip to provide a reference clock source. A temperature-compensated crystal oscillator-based IoT clock circuit with application number CN114124296A uses a temperature-compensated crystal oscillator (TCXO) to reduce environmental drift. Its core drawback is that the temperature drift compensation accuracy is limited (±0.5ppm), and it still produces an accumulated error of ≥±25μs / day under operating conditions of -40℃ to 85℃, and the cost is relatively high.
[0004] This application aims to achieve clock synchronization with small error by designing a microcontroller and positioning module without adding any other electronic components, thus saving costs. After a detailed search, no relevant prior art was found.
[0005] Therefore, a new technical solution is needed to solve the above-mentioned technical problems. Summary of the Invention
[0006] A clock synchronization circuit between Internet of Things (IoT) devices includes a microcontroller. The microcontroller is connected to the USART RX pin of a positioning module via its USART TX pin and the USART TX pin of the positioning module via its USART RX pin. The microcontroller is also connected to the clock pulse output pin PPS2 of the positioning module via a pin 2 capable of high and low level interrupts.
[0007] As a preferred embodiment, the microcontroller further includes pins 3 and 4, which are connected to a crystal oscillator circuit.
[0008] As a preferred embodiment, the communication method between the microcontroller and the positioning module is serial TTL.
[0009] As a preferred option, the positioning module uses the L76K.
[0010] As a preferred option, the microcontroller is an STM32L071RBT6.
[0011] A method for clock synchronization between Internet of Things (IoT) devices includes the following steps: S1: The positioning module connects to satellites for positioning; S2: After successful positioning, the positioning module transmits time and position information accurate to the second to the microcontroller's USART TX pin through the positioning module's USART RX pin, achieving second-level clock synchronization; S3: The precise second pulse input from the positioning module is sent to pin 2 of the microcontroller. The rising edge of the pulse triggers the microcontroller to enter an interrupt. At the same time, the timer is started in the interrupt to begin counting. The timer division value is adjusted to the microsecond scale to achieve microsecond clock synchronization.
[0012] As a preferred embodiment, the positioning module transmits time and location information to the microcontroller's USART TX pin via the USART RX pin of the positioning module using the $GNRMC protocol.
[0013] As a preferred embodiment, the location information includes latitude and longitude.
[0014] As a preferred embodiment, the communication method between the microcontroller and the positioning module is serial TTL.
[0015] As a preferred option, the positioning module uses the L76K.
[0016] As a preferred option, the microcontroller is an STM32L071RBT6.
[0017] This application can reduce the clock synchronization error to 1μs and only utilizes the microcontroller and positioning module with clock pulse output pin in the original circuit design, without adding any other electronic components, thus greatly saving costs. Attached Figure Description
[0018] Figure 1 This is the schematic diagram of the microcontroller in this application; Figure 2 This is a schematic diagram of the positioning module of this application; Figure 3This is the schematic diagram of the reset circuit module; Figure 4 This is the schematic diagram of the program download circuit; Figure 5 This is a PCB layout diagram for an IoT device. Figure label: 1. Microcontroller; 2. Positioning module; 3. 4G communication module; 4. Bluetooth communication module; 5. Sensor; 6. Power supply; 7. Data storage unit; 8. Wired communication port. Detailed Implementation
[0019] The following combination Figure 1 — Figure 5 The specific embodiments of the present invention will be described in detail below; it should be noted that the specific embodiments described herein are only for illustrating and explaining the present invention and are not intended to limit the present invention. Example 1
[0020] This embodiment provides a clock synchronization circuit between IoT devices, including a microcontroller 1, which is an STM32L071RBT6, connected to a positioning module 2, which is an L76K. Specifically, the communication method between the microcontroller 1 and the positioning module 2 is a serial TTL method. Figure 1 Microcontroller 1 communicates with the USART TX pin of its serial port. Figure 2 The serial port USART RX pin of the positioning module 2 is connected, and the microcontroller 1 is connected to the serial port USART TX pin of the positioning module 2 through the serial port USART RX pin of the microcontroller 1. The microcontroller 1 is also connected to the clock pulse output pin PPS2 of the positioning module 2 through pin 2, which can perform high and low level interrupts. The microcontroller 1 and the positioning module 2 can communicate and achieve clock synchronization using only three pins.
[0021] The microcontroller 1 includes pins 3 and 4, which are connected to a crystal oscillator circuit; the microcontroller also includes pin 7, which is connected to a reset circuit module, such as... Figure 3As shown, the reset circuit module includes a resistor R60 and a capacitor C55. The RESER pin of the reset circuit module is connected to pin 7 of the microcontroller. Pin 7 of the microcontroller supports interrupt functionality and is configured as a rising edge triggered interrupt mode. The interrupt controller enables the interrupt request of the corresponding channel. The principle is as follows: when the microcontroller 1 is powered on, the capacitor C55 begins to charge, and pin 7 is pulled to a high level. After the capacitor is fully charged, pin 7 returns to a low level. Because this pin is configured as a rising edge triggered interrupt, the low-to-high transition at power-on will automatically trigger an interrupt. During the interrupt, the microcontroller 1 pauses the current program, enters the interrupt service function to execute the corresponding logic, and after returning to a low level, waits for the next trigger. The microcontroller 1 also includes pins 46 and 49, which are connected to the program download circuit.
[0022] by Figure 5 Taking IoT devices as an example, the complete clock synchronization process is as follows: Power supply 6 is powered on, providing power to all modules including microcontroller 1, 4G communication module 3, and sensor 5. Microcontroller 1 initializes the preset date and time, which can be used to determine whether positioning module 2 is working properly. Simultaneously, positioning module 2, 4G communication module 3, wired communication port 8, and Bluetooth communication module 4 are initialized. When positioning module 2 is successfully connected to the satellite for positioning, it transmits time information accurate to the second and latitude / longitude location information via the GNRMC protocol to the microcontroller 1's USART serial port RX pin. The TX pin enables second-level clock synchronization. The precise second pulse input from positioning module 2 is sent to pin 2 of microcontroller 1. The rising edge of the pulse triggers microcontroller 1 to enter an interrupt, simultaneously starting a timer within the interrupt. The timer's division value is adjusted to the microsecond scale, and then timing begins, achieving microsecond clock synchronization. Microcontroller 1 compares the offset between its local real-time clock and the satellite time, directly calibrating its local clock. After completing its own clock calibration, microcontroller 1 synchronizes the standard UTC time to sensor 5 via its internal control bus. Simultaneously, the time synchronization command can be distributed to other sub-devices on the same network via 4G communication module 3 and Bluetooth communication module 4, achieving time unification across the entire IoT node. Example 2
[0023] This embodiment provides a clock synchronization method between IoT devices, including the following steps: S1: Positioning module 2 connects to the satellite for positioning; S2: After successful positioning, positioning module 2 transmits time information accurate to the second and latitude and longitude location information to the USART TX pin of microcontroller 1 via the USART RX pin of positioning module 2 using the $GNRMC protocol information to achieve second-level clock synchronization; second-level coarse timing is performed using the $GNRMC protocol information output by positioning module 2. S3: The precise second pulse from positioning module 2 is input to pin 2 of microcontroller 1. The rising edge of the pulse triggers microcontroller 1 to enter an interrupt, and at the same time, the timer is started in the interrupt to start counting. The timer division value is adjusted to the microsecond scale to achieve microsecond clock synchronization. The precise second pulse output by positioning module 2 is used for microsecond-level time synchronization. Positioning module 2 outputs second pulses with an accuracy of less than 30 ns for fine timing, thereby achieving clock synchronization of less than 1us.
[0024] In summary, this invention fully utilizes the two basic circuit designs of microcontroller 1 and positioning module 2 to achieve clock synchronization between devices. This application can reduce the clock synchronization error to 1μs and only utilizes the microcontroller 1 and the positioning module 2 with clock pulse output pin in the original circuit design, without adding any other electronic components, which greatly saves costs.
[0025] However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims. All of these are within the protection scope of this application.
Claims
1. A clock synchronization circuit between Internet of Things (IoT) devices, comprising a microcontroller (1), characterized in that, The microcontroller (1) is connected to the USART RX pin of the positioning module (2) through the USART TX pin of the microcontroller (1) and the USART TX pin of the positioning module (2) through the USART RX pin of the microcontroller (1). The microcontroller (1) is also connected to the clock pulse output pin PPS2 of the positioning module (2) through pin 2, which is capable of high and low level interrupts.
2. The clock synchronization circuit between IoT devices according to claim 1, characterized in that, The communication method between the microcontroller (1) and the positioning module (2) is serial TTL.
3. The clock synchronization circuit between IoT devices according to claim 1, characterized in that, The positioning module (2) adopts L76K.
4. The clock synchronization circuit between IoT devices according to claim 1, characterized in that, The microcontroller (1) is model STM32L071RBT6.
5. A clock synchronization method using a clock synchronization circuit between IoT devices as described in any one of claims 1 to 4, comprising the following steps: S1: Positioning module (2) connects to the satellite for positioning; S2: After successful positioning, the positioning module (2) transmits the time and position information accurate to the second to the USART TX pin of the microcontroller (1) through the USART RX pin of the positioning module (2) to achieve second-level clock synchronization; S3: The precise second pulse input of the positioning module (2) is sent to the second pin of the microcontroller (1). The rising edge of the pulse triggers the microcontroller (1) to enter the interrupt. At the same time, the timer is started in the interrupt to start counting. The timer division value is adjusted to the microsecond scale to achieve microsecond clock synchronization.
6. The clock synchronization method between IoT devices according to claim 5, characterized in that, The positioning module (2) transmits time and location information to the USART TX pin of the microcontroller (1) via the USART RX pin of the positioning module (2) using the $GNRMC protocol.
7. A clock synchronization method between IoT devices according to claim 5, characterized in that, The location information includes latitude and longitude.
8. A clock synchronization method between IoT devices according to claim 5, characterized in that, The communication method between the microcontroller (1) and the positioning module (2) is serial TTL.
9. A clock synchronization method between IoT devices according to claim 5, characterized in that, The positioning module (2) adopts L76K.
10. A clock synchronization method between IoT devices according to claim 5, characterized in that, The microcontroller (1) is model STM32L071RBT6.
Citation Information
Patent Citations
Anti-interference serial inter-board communication method and system
CN114124296A
