Window sash posture monitoring system and method based on multi-dimensional constraint and self-adaptive calibration

By using a window sash attitude monitoring system based on multidimensional constraints and adaptive calibration, and utilizing a six-axis inertial measurement unit and a magnetic induction unit, the system solves the problems of accuracy and installation complexity in window opening angle monitoring in existing technologies, and achieves accurate monitoring and improved stability of window sash attitude.

CN122043983APending Publication Date: 2026-05-15CHONGQING UNIVERSITY OF SCIENCE AND TECHNOLOGY
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
CHONGQING UNIVERSITY OF SCIENCE AND TECHNOLOGY
Filing Date
2026-01-30
Publication Date
2026-05-15

AI Technical Summary

Technical Problem

Existing window status monitoring technologies suffer from limitations such as limited information dimensions, mechanical contact wear, physical blind spots of MEMS accelerometers, and integral drift issues of pure gyroscopes. These limitations make it impossible to accurately quantify the window opening angle, and they are complex to install and unsuitable for retrofitting existing buildings.

Method used

A window sash attitude monitoring system based on multidimensional constraints and adaptive calibration is adopted. It utilizes a six-axis inertial measurement unit (IMU), a magnetic induction unit, and a microcontroller unit (MCU), combined with a magnetic switch and a wireless communication module, to achieve accurate monitoring of the window sash attitude through adaptive calibration and dead-zone filtering technology.

Benefits of technology

It enables precise monitoring of window sash posture, eliminates cumulative errors and environmental temperature drift, is flexible in installation and applicable to a variety of rotating components around an axis, reduces construction difficulty, and improves system stability and applicability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122043983A_ABST
    Figure CN122043983A_ABST
Patent Text Reader

Abstract

The invention provides a window sash posture monitoring system and method based on multi-dimensional constraint and self-adaptive calibration. The monitoring system comprises a micro-control unit MCU, a six-axis inertial measurement unit IMU, a magnetic induction unit and a wireless communication module which are arranged in a monitoring terminal; the data end of the six-axis inertial measurement unit IMU is connected with the inertial data end of the micro-control unit MCU, the data end of the magnetic induction unit is connected with the magnetic induction data end of the micro-control unit MCU, and the data end of the wireless communication module is connected with the wireless data end of the micro-control unit MCU; and monitoring of the movable end is realized through data monitored by the monitoring terminal. The device is simple in structure and flexible in installation, and can automatically eliminate accumulative errors and environment temperature excursion through physical boundaries to achieve angle measurement.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of smart home and building automation control technology, and in particular to a window sash attitude monitoring system and method based on multidimensional constraints and adaptive calibration. Background Technology

[0002] In the fields of building energy conservation, indoor air quality control, and smart security, real-time acquisition of the precise opening angle of windows is a key parameter for calculating natural ventilation (ACH) and judging intrusion behavior.

[0003] Existing window status monitoring technologies have the following main drawbacks:

[0004] (1) Single information dimension: Ordinary door magnetic sensors can only provide feedback on two discrete states, "open" and "closed", and cannot quantify the opening angle, making it difficult to meet the needs of refined ventilation control.

[0005] (2) Mechanical contact wear: Pull-wire or rotating shaft potentiometers require mechanical linkages to connect the fixed frame and the movable fan, which is complicated to install, damages the aesthetics of the decoration, and the mechanical parts are prone to wear and failure after long-term operation.

[0006] (3) Physical blind zone of MEMS accelerometers: Conventional tilt sensors rely on the gravitational acceleration component to calculate the angle. For casement doors and windows rotating around the vertical axis, the gravity vector (g) is always perpendicular to the plane of rotation during the movement. The gravity components of each axis of the sensor do not change with the angle, which means that the horizontal rotation angle cannot be detected at the physical level.

[0007] (4) Integral drift of pure gyroscope: Although gyroscope can detect angular velocity, it has an inherent "zero drift". Over time, small errors will be accumulated and amplified by integration; and affected by ambient temperature, the sensor will also output false slow rotation signals when stationary, which will cause the system to be unable to operate stably for a long time.

[0008] (5) Strict installation orientation restrictions: Existing inertial monitoring solutions typically require sensors to be installed strictly in a specific orientation (e.g., the X-axis must be vertically upward). If the user installs the sensor at an angle or mistakenly attaches it to the side, it will cause the measurement axis to be incorrect, and the system will not function properly. This greatly increases the difficulty of installation and commissioning, limiting its large-scale application in the renovation of existing buildings. Summary of the Invention

[0009] This invention aims to at least solve the technical problems existing in the prior art, and in particular, it innovatively proposes a window sash attitude monitoring system and method based on multidimensional constraints and adaptive calibration.

[0010] To achieve the above-mentioned objectives of the present invention, the present invention provides a window sash attitude monitoring system based on multidimensional constraints and adaptive calibration, including a monitoring terminal and a monitoring reference component;

[0011] The monitoring terminal is set at the active end;

[0012] The monitoring reference element is set at a fixed end;

[0013] The monitoring terminal is equipped with a microcontroller unit (MCU), a six-axis inertial measurement unit (IMU), a magnetic induction unit, and a wireless communication module.

[0014] The data terminal of the six-axis inertial measurement unit (IMU) is connected to the inertial data terminal of the microcontroller unit (MCU), the data terminal of the magnetic induction unit is connected to the magnetic induction data terminal of the MCU, and the data terminal of the wireless communication module is connected to the wireless data terminal of the MCU.

[0015] Monitoring of activities is achieved by monitoring data from monitoring terminals.

[0016] It also includes a monitoring platform, which uses a wireless communication module to interconnect the monitoring platform and the monitoring system, and can display real-time angle changes on the APP.

[0017] The present invention also discloses a window sash attitude monitoring system based on multidimensional constraints and adaptive calibration, including a magnetic induction unit and a monitoring reference component;

[0018] The magnetic induction unit is located at the movable end;

[0019] The monitoring reference element is set at a fixed end;

[0020] It also includes a monitoring terminal, which is equipped with a microcontroller unit (MCU), a six-axis inertial measurement unit (IMU), and a wireless communication module.

[0021] The data terminal of the six-axis inertial measurement unit (IMU) is connected to the inertial data terminal of the microcontroller unit (MCU), the data terminal of the magnetic induction unit is connected to the magnetic induction data terminal of the MCU, and the data terminal of the wireless communication module is connected to the wireless data terminal of the MCU.

[0022] And including monitoring platforms;

[0023] Monitoring of activities is achieved by monitoring data from monitoring terminals.

[0024] It also includes a monitoring platform, which uses a wireless communication module to interconnect the monitoring platform and the monitoring system, and can display real-time angle changes on the APP.

[0025] In a preferred embodiment of the present invention, the magnetic induction unit and the monitoring reference element constitute a magnetic switch;

[0026] The magnetic switch is model MC-38;

[0027] The microcontroller unit (MCU) is model ESP32; preferably, it can be an IoT module that integrates the MCU and the wireless communication module, specifically ESP32-C3, ESP32-WROOM, or ESP32-WROOM-32UE-N8, and the wireless communication module has a WiFi unit and a Bluetooth module.

[0028] The model number of the six-axis inertial measurement unit (IMU) is MPU-6050.

[0029] This invention also discloses a window sash attitude monitoring method based on multidimensional constraints and adaptive calibration, comprising the following steps:

[0030] S1, Installation of attitude monitoring system;

[0031] S2, the attitude monitoring system acquires angle changes.

[0032] In a preferred embodiment of the present invention, step S1 includes:

[0033] The microcontroller unit (MCU), six-axis inertial measurement unit (IMU), magnetic induction unit, wireless communication module, and power supply module are placed inside the monitoring terminal housing. The data terminal of the six-axis inertial measurement unit (IMU) is connected to the inertial data terminal of the MCU, the data terminal of the magnetic induction unit is connected to the magnetic induction data terminal of the MCU, and the data terminal of the wireless communication module is connected to the wireless data terminal of the MCU. The power supply module provides adapter power to the MCU, IMU, and wireless communication module respectively. The monitoring terminal is attached to the movable end using adhesive backing.

[0034] The monitoring reference component is attached to the fixed end using adhesive backing.

[0035] Alternatively, the microcontroller unit (MCU), six-axis inertial measurement unit (IMU), wireless communication module, and power supply module can be placed inside the monitoring terminal housing. The data terminal of the six-axis IMU is connected to the inertial data terminal of the MCU, the data terminal of the magnetic induction unit is connected to the magnetic induction data terminal of the MCU, and the data terminal of the wireless communication module is connected to the wireless data terminal of the MCU. The power supply module provides adapter power to the MCU, IMU, and wireless communication module respectively. The data terminal of the magnetic induction unit is connected to the magnetic induction data terminal of the MCU. The monitoring terminal is attached to the movable end using adhesive backing.

[0036] The monitoring reference component and the magnetic induction unit are respectively attached to the fixed end and the movable end using adhesive backing.

[0037] In a preferred embodiment of the present invention, step S2 includes:

[0038] S21, Obtain the time difference. The method for obtaining the time difference is as follows:

[0039] Read the current system time Get the last running time According to the current system time and last run time Calculate the difference:

[0040] ,

[0041] in, Indicates the sampling period;

[0042] This indicates the current system time, in milliseconds.

[0043] This indicates the last execution time, in milliseconds.

[0044] S22, angular velocity Data Acquisition:

[0045] Based on the initialization phase The raw angular velocities of the corresponding axes are read from the six-axis inertial measurement unit (IMU). ;

[0046] S23, Judgment and Relationship:

[0047] like This is determined to be invalid noise. ;

[0048] like This is considered a valid movement. ;

[0049] in, Indicates the current sampling period Inside, after being determined to be valid motion through dead-zone filtering, the angle change increment is calculated;

[0050] This indicates the preset dead zone threshold.

[0051] Indicates taking the absolute value;

[0052] S24, Update the angle. The method for updating the angle is as follows:

[0053] ,

[0054] in, This indicates the total opening angle of the window sash at the current moment;

[0055] The angle value recorded at the previous moment;

[0056] S25, Angle Correction, the method for angle correction is as follows:

[0057] Read the magnetic switch status :

[0058] If the magnetic switch is in state If it is in the closed state, then a forced reset is required. .

[0059] In a preferred embodiment of the present invention, step S22 includes:

[0060] Triaxial acceleration components measured using a six-axis inertial measurement unit (SMU) ) respectively compared with the standard gravitational acceleration threshold A comparison is performed to lock the target sensitive axis.

[0061] In a preferred embodiment of the present invention, step S22 includes:

[0062] After locking the sensitive axis, the angular velocity data of that axis is collected several times in a stationary state, and the average value is calculated as the bias error. In subsequent calculations, the bias value is subtracted from all raw angular velocity data to eliminate the inherent DC bias of the hardware.

[0063] The present invention also discloses a computer system, comprising:

[0064] processor;

[0065] Memory used to store processor-executable instructions;

[0066] The processor is configured to implement a window sash attitude monitoring method based on multidimensional constraints and adaptive calibration when executing the executable instructions.

[0067] The present invention also discloses a computer-readable storage medium, comprising:

[0068] A memory on which computer programs are stored;

[0069] A processor is configured to execute the program in the memory to implement a window sash attitude monitoring method based on multidimensional constraints and adaptive calibration.

[0070] In summary, due to the adoption of the above technical solutions, the present invention has a simple structure, flexible installation, and can automatically eliminate accumulated errors and environmental temperature drift by utilizing physical boundaries to achieve angle measurement.

[0071] Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description

[0072] The above and / or additional aspects and advantages of the present invention will become apparent and readily understood from the description of the embodiments taken in conjunction with the following drawings, in which:

[0073] Figure 1 This is a schematic diagram of the installation and connection of the present invention.

[0074] Figure 2 This is a schematic diagram of the hardware topology of the present invention.

[0075] Figure 3 This is a schematic flowchart of the attitude calculation stage of the present invention.

[0076] Figure 4 This is a schematic flowchart of the second stage of attitude calculation in this invention. Detailed Implementation

[0077] Embodiments of the present invention are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.

[0078] This invention proposes a window sash attitude monitoring method based on multidimensional constraints and adaptive calibration, such as... Figures 1-4 As shown, this method is executed by a microcontroller unit (MCU), and specifically includes the following four core steps:

[0079] (1) Installation of attitude adaptive recognition steps: After the system is powered on, it is initially in a stationary state. The current gravity vector distribution is measured using a six-axis inertial measurement unit. The system will then measure the three-axis acceleration components ( ) respectively compared with the standard gravitational acceleration threshold Typically, 0.8g (where g is the acceleration due to gravity) is used for comparison.

[0080] like > The sensor (six-axis inertial measurement unit IMU) is determined to be mounted on its side with the X-axis perpendicular to the ground plane, and the X-axis is locked as the integral sensitive axis of the rotational angular velocity.

[0081] like > The sensor is determined to be mounted on its side with its Y-axis perpendicular to the ground plane, and the Y-axis is locked as the integral sensing axis of the rotational angular velocity.

[0082] like > The sensor is determined to be mounted flat with its Z-axis perpendicular to the ground plane, and the Z-axis is locked as the integral sensitive axis of the rotational angular velocity.

[0083] in, Represents the X-axis acceleration component. Represents the Y-axis acceleration component. Represents the Z-axis acceleration component. This indicates taking the absolute value. Indicates the standard gravitational acceleration threshold;

[0084] (2) Static zero-point calibration steps: After locking the sensitive axis, the system collects angular velocity data of the axis several times (e.g., 100 times) in a static state, and calculates the average value as the zero bias error. In subsequent calculations, all raw angular velocity data must be subtracted from this bias value to eliminate the inherent DC bias of the hardware.

[0085] (3) Dynamic dead zone filtering and integration steps: After entering the main monitoring loop, the angular velocity data of the selected sensitive axis is read in real time, and the data is processed using the "dead zone threshold determination method":

[0086] (4) Dead zone determination: If the absolute value of the current angular velocity is less than the preset dead zone threshold. The system determines that the window sash is in a "stationary" or "vibrating in a light breeze" state, and forces the effective angular velocity to be 0, keeping the angle unchanged;

[0087] Effective integral: only if the absolute value of the angular velocity is greater than When a genuine human action of pushing the window is detected, the system performs an integral calculation of the effective angular velocity over time and updates the current opening angle accordingly.

[0088] (5) Physical Boundary Reset Step: The system continuously monitors the level state (magnetic switch state) of the magnetic induction unit. When a closed signal (Logic LOW) is detected, it indicates that the window sash has physically returned to the window frame. At this time, the highest priority reset operation is triggered, forcibly returning the current integral angle to zero. This step utilizes a deterministic physical position signal to eliminate the cumulative integral drift generated by the gyroscope during prolonged operation or multiple reciprocating motions.

[0089] Hardware: The main control unit (microcontroller unit MCU) and sensors use ESP32-C3, ESP32-WROOM, or ESP32-WROOM-32UE-N8 microcontroller unit MCU chips, paired with MPU6050 six-axis inertial measurement unit (IMU).

[0090] Installation method: The monitoring terminal is installed at any corner of the movable door / window using adhesive backing. The monitoring reference component can also be installed on the fixed end (door / window frame) using adhesive backing. The monitoring reference component should be properly positioned with the magnetic induction unit to ensure that the magnetic induction unit is in a closed state when the door / window is closed. Because this invention has adaptive algorithm capabilities, users do not need to pay attention to the specific pasting direction of the sensor (horizontal / vertical), but only need to ensure that one axis of the sensor is approximately parallel to the door / window hinge.

[0091] Software algorithm implementation details

[0092] The system runs in a microcontroller unit (MCU) and executes the following loop logic:

[0093] Variable and parameter definitions

[0094] To ensure the technical solution is clear and unambiguous, the key parameters involved in this embodiment are defined as follows:

[0095] : Target sensitive axis identifiers locked by the adaptive algorithm (0=X-axis, 1=Y-axis, 2=Z-axis);

[0096] (Gyro_Speed): The sensor is in Real-time raw angular velocity output on the axis, unit: degrees / second;

[0097] (DEADZONE): The preset dead zone threshold, set to 0.5° / s in this embodiment. The physical meaning of this value is: to ignore any minute fluctuations less than 0.5 degrees per second;

[0098] The time interval between two samples is calculated in real time by the system clock, and the unit is seconds (s).

[0099] (Current_Angle): The current calculated absolute opening angle of the window sash, in degrees (°);

[0100] : The level state of the magnetic induction unit (LOW = window closed / magnet engaged, HIGH = window open / magnet disengaged).

[0101] Detailed processing flow: The system runs in a main loop, and each loop contains the following logic:

[0102] Step 1: Time Differential Calculation

[0103] Read the current system time Calculate the time since the last run The difference:

[0104]

[0105] (Note: Convert milliseconds to seconds)

[0106] Step 2: Data Acquisition

[0107] Based on the initialization phase Read the raw angular velocity of the corresponding axis from the IMU. For example, if =0, then read = ;

[0108] like =1, then read = ;

[0109] like =2, then read = ;

[0110] Represents the angular velocity along the X-axis. Represents the angular velocity along the Y-axis. Represents the angular velocity along the Z-axis;

[0111] Step 3: Dead-zone filtering determination (core anti-drift logic)

[0112] judge and Relationship:

[0113] Scenario A: If This was determined to be invalid noise.

[0114]

[0115] Scenario B: If This is considered a valid exercise.

[0116]

[0117] Indicates the current sampling period Inside, after being determined to be valid motion through dead zone filtering, the calculated window sash angle change increment is expressed in degrees (°).

[0118] Points update:

[0119]

[0120] This indicates the total opening angle of the window sash at the current moment. This is the angle recorded at the previous moment.

[0121] Step 4: Physical Boundary Correction: Reading the Magnetic Switch Status :

[0122] like (Closed), forced reset: .0;

[0123] Closed-loop error correction mechanism: Unlike traditional open-loop integration schemes using pure gyroscopes, this invention constructs a dual-constraint model of "magnetic boundary + inertial integration". Utilizing the absolute zero-position signal provided by a magnetic reference component, the accumulation of integration error in the inertial sensor is periodically truncated; combined with a static zero-bias self-learning algorithm, the temperature drift and divergence problems of low-cost MEMS sensors after long-term operation are fundamentally solved, achieving industrial-grade measurement stability for consumer-grade hardware.

[0124] Adaptive Installation: Thanks to its built-in gravity vector recognition algorithm, this system features "blind installation." Users do not need to distinguish the front or back of the sensor or a specific pasting direction; the system automatically identifies the installation posture and locks the optimal sensitive axis after power-on. This greatly reduces construction difficulty and is particularly suitable for the intelligent renovation of existing building doors and windows.

[0125] High cost-effectiveness and versatility: This solution eliminates expensive and cumbersome mechanical angle sensors (such as photoelectric encoders), utilizing only the general-purpose ESP32 main controller and MPU6050 chip, and compensating for the lack of hardware accuracy through highly robust software algorithms. Furthermore, the system is compatible with various rotating components around an axis, such as casement windows, casement doors, and awning windows, and has extremely broad market application prospects.

[0126] Intelligent anti-interference logic: To address window sash vibrations caused by a light breeze or the instantaneous impact when closing a door, the system introduces dynamic dead zone filtering and impact suppression logic to ensure "zero fluctuation" in data during non-effective motion states, thus avoiding the uploading of false data.

[0127] Application scenarios

[0128] This device (method) can be widely applied in the following scenarios:

[0129] Building natural ventilation and ambient thermal comfort control: In green buildings, this system can provide real-time window opening angles. By combining window geometry, the HVAC control system can accurately calculate the effective ventilation area, and then estimate the building's real-time air change rate (ACH). The linkage logic is as follows: When the outdoor enthalpy is suitable during the transitional season, the system automatically reduces the load on the mechanical fresh air system based on the monitored ventilation volume, achieving maximum energy-saving control; when it detects that the window opening angle is too small (insufficient ventilation) leading to excessive indoor CO2, it automatically activates the exhaust fan.

[0130] Home-based elderly care behavior analysis and monitoring is applied to the bathroom or bedroom doors of elderly people living alone: ​​Behavior recognition: By analyzing the angular velocity curve of door opening, the system identifies the elderly person's movement characteristics. If abnormally slow door opening is detected (indicating physical weakness) or no door opening signal is detected for an extended period (indicating a possible fall), the system automatically sends an alert to the caregiver.

[0131] Differentiated intelligent security: Traditional door sensors can only detect "open" and cannot distinguish intent; this system allows setting tiered thresholds: Ventilation mode: Window open. If the temperature is below 15°C, the system determines it as normal ventilation, does not trigger an alarm, and allows the robot vacuum to operate. Intrusion mode: If the system is armed, and the window is open... If the angle is less than 30° or a sudden change in the angular velocity of the window sash is detected (violent damage), an intrusion alarm will be immediately triggered and the camera will be activated to capture the image.

[0132] Fire exit and fire door monitoring is applied to normally closed fire doors: the system can monitor in real time whether the fire door is fully closed. If the fire door is detected to be slightly open (e.g., due to obstruction by a foreign object) for more than a set threshold, the system will automatically report to the fire control center to eliminate the safety hazard.

[0133] This invention discloses a method for monitoring the attitude of opening and closing components (doors / windows) based on multidimensional constraints and adaptive calibration, comprising the following steps:

[0134] S1 Data Acquisition Steps: Use a six-axis inertial measurement unit to acquire angular velocity data of the opening and closing components, and use a magnetic induction unit to detect the closing state between the opening and closing components and the fixed frame;

[0135] S2 Dynamic Dead Zone Filtering Steps: Real-time monitoring of angular velocity data; when the absolute value of the angular velocity is less than the preset dead zone threshold, it is determined that the opening and closing component is in a static or slightly vibrating state, and the current angle value is forcibly locked and remains unchanged; only when the absolute value of the angular velocity is greater than the threshold, integral calculation is performed to update the opening angle.

[0136] S3 Physical Boundary Reset Step: When the magnetic induction unit detects a closing signal, it triggers the highest priority reset command, forcibly resetting the current integral angle to zero and eliminating the accumulated error during the opening and closing process.

[0137] In a preferred embodiment of the present invention, a "self-checking of installation posture" step is also included: when the system is powered on and initialized, the three-axis gravity components are collected; based on the projection distribution of the gravity vector on the three axes, the installation orientation of the sensor on the surface of the opening and closing component is automatically determined; based on the determination result, one of the three axes of angular velocity is automatically locked as the main sensitive axis parallel to the rotation axis of the opening and closing component for data acquisition in step S1.

[0138] In a preferred embodiment of the present invention, a "static zero-bias self-learning" step is also included: when the system detects that the magnetic induction unit is in a closed state and the variance of the angular velocity data within a preset time period is lower than the stability threshold, the average drift of the inertial sensor at the current moment is automatically calculated and the zero-bias compensation parameters of the system are updated.

[0139] In a preferred embodiment of the present invention, an "anti-impact interference" step is also included: when the six-axis inertial measurement unit detects transient vibration exceeding a preset impact threshold, the system suspends angular velocity integration calculation within a preset time window and prioritizes the status signal of the magnetic induction unit to prevent algorithm divergence caused by violent impact of the door.

[0140] The present invention also discloses an attitude monitoring system based on the above method, comprising: a monitoring terminal 3: disposed on the opening and closing component (movable end 1), integrating a microcontroller unit 5, a six-axis inertial measurement unit 4, and a magnetic induction unit 7; a monitoring reference component 8: disposed at the corresponding closed position of the fixed frame (fixed end 6), used to trigger the magnetic induction unit 7; the monitoring terminal is configured to execute the attitude monitoring method described above; and also includes a power module for adapting power to the microcontroller unit 5 and the six-axis inertial measurement unit 4.

[0141] Key code examples:

[0142] / *

[0143] * Fully automatic monitoring solution for casement windows / doors: Dead zone integration + adaptive installation recognition

[0144] * Attitude self-check + dead zone filtering

[0145] /

[0146] #include "Wire.h"

[0147] #include<MPU6050_light.h>

[0148] / / === Hardware Configuration ===

[0149] #define SDA_PIN 21

[0150] #define SCL_PIN 22

[0151] #define MAG_PIN 4 / / Magnetic switch

[0152] #define LED_PIN 2

[0153] MPU6050 mpu(Wire);

[0154] / / === Global variables ===

[0155] / / ! No more hardcoding AXIS_TYPE, use a variable instead!

[0156] int target_axis = 1; / / Defaults to the Y-axis, but will be automatically modified in setup.

[0157] / / === Parameter Tuning ===

[0158] const float DEADZONE = 0.5;

[0159] float current_angle = 0.0;

[0160] unsigned long last_time = 0;

[0161] / / === Adaptive Recognition Function (Core Algorithm) ===

[0162] void auto_detect_orientation() {

[0163] Serial.println(" Checking installation posture...");

[0164] / / Read the current acceleration value (gravity component)

[0165] float ax = mpu.getAccX();

[0166] float ay = mpu.getAccY();

[0167] float az = mpu.getAccZ();

[0168] / / Print debugging information

[0169] Serial.print("Gravity component -> X:"); Serial.print(ax);

[0170] Serial.print(" Y:"); Serial.print(ay);

[0171] Serial.print(" Z:"); Serial.println(az);

[0172] / / Logic: The casement window rotates about the vertical axis.

[0173] / / The direction of gravity is also perpendicular.

[0174] Therefore, the axis whose absolute acceleration is closest to 1.0g is the vertical axis, which is also the axis of rotation.

[0175] if (abs(ax) > 0.8) {

[0176] target_axis = 0;

[0177] Serial.println(" Recognition result: Side-mounted (X-axis perpendicular) -> Lock GyroX");

[0178] }

[0179] else if (abs(ay) > 0.8) {

[0180] target_axis = 1;

[0181] Serial.println(" Recognition result: Side-mounted (Y-axis perpendicular) -> Lock GyroY");

[0182] }

[0183] else {

[0184] target_axis = 2; / / Default or flat

[0185] Serial.println(" Recognition result: Flat mounting (Z-axis perpendicular) -> Lock GyroZ");

[0186] }

[0187] }

[0188] void setup() {

[0189] Serial.begin(115200);

[0190] pinMode(MAG_PIN, INPUT_PULLUP);

[0191] pinMode(LED_PIN, OUTPUT);

[0192] Wire.begin(SDA_PIN, SCL_PIN);

[0193] Wire.setClock(400000);

[0194] byte status = mpu.begin();

[0195] while(status != 0){

[0196] Serial.println("Sensor not connected"); delay(1000); status = mpu.begin();

[0197] }

[0198] / / ===Step S1: Installation Attitude Self-Check===

[0199] / / The attitude must be determined before static calibration.

[0200] / / For accuracy, let's delay briefly until the data stabilizes.

[0201] delay(500);

[0202] mpu.update();

[0203] auto_detect_orientation(); / / <--- Call the adaptive function

[0204] Serial.println(" Calibrate zero point (de-noise)...);

[0205] delay(1000);

[0206] mpu.calcOffsets();

[0207] Serial.println(" Calibration complete");

[0208] last_time = millis();

[0209] }

[0210] void loop() {

[0211] mpu.update();

[0212] unsigned long now = millis();

[0213] float dt = (now - last_time) / 1000.0;

[0214] last_time = now;

[0215] / / ===Step S2: Dynamically acquire target axis data===

[0216] float gyro_speed = 0.0;

[0217] / / Retrieve values ​​based on the results automatically identified in the setup.

[0218] switch(target_axis) {

[0219] case 0: gyro_speed = mpu.getGyroX(); break;

[0220] case 1: gyro_speed = mpu.getGyroY(); break;

[0221] case 2: gyro_speed = mpu.getGyroZ(); break;

[0222] }

[0223] / / ===Step S3: Dead Zone Filtering===

[0224] if (abs(gyro_speed) > DEADZONE) {

[0225] current_angle += gyro_speed * dt;

[0226] }

[0227] / / ===Step S4: Physical Boundary Reset===

[0228] if (digitalRead(MAG_PIN) == LOW) {

[0229] current_angle = 0.0;

[0230] digitalWrite(LED_PIN, LOW);

[0231] } else {

[0232] digitalWrite(LED_PIN, HIGH);

[0233] }

[0234] / / Display logic

[0235] float display = abs(current_angle);

[0236] if (display < 2.0) display = 0.0;

[0237] static unsigned long print_timer = 0;

[0238] if (millis() - print_timer > 100) {

[0239] Serial.print("Automatic axis["); Serial.print(target_axis);

[0240] Serial.print("] Speed:"); Serial.print(gyro_speed);

[0241] Serial.print(" | Angle: "); Serial.println(display, 1);

[0242] print_timer = millis();

[0243] }

[0244] }

[0245] Although embodiments of the invention have been shown and described, those skilled in the art will understand that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the claims and their equivalents.

Claims

1. A window sash attitude monitoring system based on multidimensional constraints and adaptive calibration, characterized in that, Includes monitoring terminals and monitoring reference components; The monitoring terminal is set at the active end; The monitoring reference element is set at a fixed end; The monitoring terminal is equipped with a microcontroller unit (MCU), a six-axis inertial measurement unit (IMU), a magnetic induction unit, and a wireless communication module. The data terminal of the six-axis inertial measurement unit (IMU) is connected to the inertial data terminal of the microcontroller unit (MCU), the data terminal of the magnetic induction unit is connected to the magnetic induction data terminal of the MCU, and the data terminal of the wireless communication module is connected to the wireless data terminal of the MCU. Monitoring of activities is achieved by monitoring data from monitoring terminals.

2. A window sash attitude monitoring system based on multidimensional constraints and adaptive calibration, characterized in that, Includes a magnetic induction unit and a monitoring reference component; The magnetic induction unit is located at the movable end; The monitoring reference element is set at a fixed end; It also includes a monitoring terminal, which is equipped with a microcontroller unit (MCU), a six-axis inertial measurement unit (IMU), and a wireless communication module. The data terminal of the six-axis inertial measurement unit (IMU) is connected to the inertial data terminal of the microcontroller unit (MCU), the data terminal of the magnetic induction unit is connected to the magnetic induction data terminal of the MCU, and the data terminal of the wireless communication module is connected to the wireless data terminal of the MCU. And including monitoring platforms; Monitoring of activities is achieved by monitoring data from monitoring terminals.

3. The window sash attitude monitoring system based on multidimensional constraints and adaptive calibration according to claim 1 or 2, characterized in that, The magnetic induction unit and the monitoring reference component constitute a magnetic switch; The magnetic switch is model MC-38; The microcontroller unit (MCU) is model ESP32; The model number of the six-axis inertial measurement unit (IMU) is MPU-6050.

4. A method for monitoring window sash attitude based on multidimensional constraints and adaptive calibration, characterized in that, Includes the following steps: S1, Installation of attitude monitoring system; S2, the attitude monitoring system acquires angle changes.

5. The window sash attitude monitoring method based on multidimensional constraints and adaptive calibration according to claim 4, characterized in that, Step S1 includes: The microcontroller unit (MCU), six-axis inertial measurement unit (IMU), magnetic induction unit, wireless communication module, and power supply module are placed inside the monitoring terminal housing. The data terminal of the six-axis inertial measurement unit (IMU) is connected to the inertial data terminal of the MCU, the data terminal of the magnetic induction unit is connected to the magnetic induction data terminal of the MCU, and the data terminal of the wireless communication module is connected to the wireless data terminal of the MCU. The power supply module provides adapter power to the MCU, IMU, and wireless communication module respectively. The monitoring terminal is attached to the movable end using adhesive backing. The monitoring reference component is attached to the fixed end using adhesive backing. Alternatively, the microcontroller unit (MCU), six-axis inertial measurement unit (IMU), wireless communication module, and power supply module can be placed inside the monitoring terminal housing. The data terminal of the six-axis IMU is connected to the inertial data terminal of the MCU, the data terminal of the magnetic induction unit is connected to the magnetic induction data terminal of the MCU, and the data terminal of the wireless communication module is connected to the wireless data terminal of the MCU. The power supply module provides adapter power to the MCU, IMU, and wireless communication module respectively. The data terminal of the magnetic induction unit is connected to the magnetic induction data terminal of the MCU. The monitoring terminal is attached to the movable end using adhesive backing. The monitoring reference component and the magnetic induction unit are respectively attached to the fixed end and the movable end using adhesive backing.

6. The window sash attitude monitoring method based on multidimensional constraints and adaptive calibration according to claim 4, characterized in that, Step S2 includes: S21, Obtain the time difference. The method for obtaining the time difference is as follows: Read the current system time Get the last running time According to the current system time and last run time Calculate the difference: , in, Indicates the sampling period; This indicates the current system time, in milliseconds. This indicates the last execution time, in milliseconds. S22, angular velocity Data Acquisition: Based on the initialization phase The raw angular velocities of the corresponding axes are read from the six-axis inertial measurement unit (IMU). ; S23, Judgment and Relationship: like This is determined to be invalid noise. ; like This is considered a valid movement. ; in, Indicates the current sampling period Inside, after being determined to be valid motion through dead-zone filtering, the angle change increment is calculated; This indicates the preset dead zone threshold. Indicates taking the absolute value; S24, Update the angle. The method for updating the angle is as follows: , in, This indicates the total opening angle of the window sash at the current moment; The angle value recorded at the previous moment; S25, Angle Correction, the method for angle correction is as follows: Read the magnetic switch status : If the magnetic switch is in state If it is in the closed state, then a forced reset is required. .

7. The window sash attitude monitoring method based on multidimensional constraints and adaptive calibration according to claim 4, characterized in that, Step S22 includes: Triaxial acceleration components measured using a six-axis inertial measurement unit (SMU) ) respectively compared with the standard gravitational acceleration threshold A comparison is performed to lock the target sensitive axis.

8. The window sash attitude monitoring method based on multidimensional constraints and adaptive calibration according to claim 4, characterized in that, Step S22 includes: After locking the sensitive axis, the angular velocity data of that axis is collected several times in a stationary state, and the average value is calculated as the bias error. In subsequent calculations, the bias value is subtracted from all raw angular velocity data to eliminate the inherent DC bias of the hardware.

9. A computer system, characterized in that, include: processor; Memory used to store processor-executable instructions; The processor is configured to implement the window sash attitude monitoring method based on multidimensional constraints and adaptive calibration as described in any one of claims 4 to 8 when executing the executable instructions.

10. A computer-readable storage medium, characterized in that, include: A memory on which computer programs are stored; A processor is configured to execute the program in the memory to implement the window sash attitude monitoring method based on multidimensional constraints and adaptive calibration as described in any one of claims 4 to 8.