Sheep house environment monitoring control system and method based on internet of things
By collecting and processing sheepfold environmental data in real time through an Internet of Things (IoT) sensor network, structured data and control commands are generated, solving the problems of lagging regulation and insufficient precision in traditional sheepfold environmental management. This enables timely, accurate and stable regulation of the sheepfold environment, improving the system's systematicness and reliability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GANSU SHEEP BREEDING TECH PROMOTION STATION
- Filing Date
- 2026-03-11
- Publication Date
- 2026-06-09
AI Technical Summary
Traditional sheepfold environmental management relies on manual, timed inspections, which suffers from delayed regulation, insufficient precision, and high labor intensity. It is difficult to achieve real-time, accurate, and stable control of environmental factors, and existing technologies have logical gaps in data processing and regulation strategies.
The system collects real-time environmental data of the sheepfold through an Internet of Things (IoT) sensor network, preprocesses the data to generate structured data, evaluates the environmental status based on preset standard ranges, generates control commands, and controls the environmental regulation equipment one by one to perform regulation operations, ensuring closed-loop feedback and reliable execution.
It enables timely, accurate, and stable control of the sheepfold environment, avoids the arbitrariness and lag of human intervention, improves the systematicness and reliability of environmental management, and saves management costs.
Smart Images

Figure CN122172907A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of sheepfold environment monitoring and control technology, and in particular to a sheepfold environment monitoring and control system and method based on the Internet of Things. Background Technology
[0002] As the primary production and living environment for sheep, the quality of the internal environment (such as temperature, humidity, ammonia concentration, and light) directly affects the health, growth performance, and reproductive efficiency of sheep. Traditional sheep pen environmental management relies heavily on manual, periodic inspections and experience-based judgment, which suffers from drawbacks such as delayed regulation, insufficient precision, and high labor intensity. It is difficult to achieve real-time, accurate, and stable control of environmental factors. While deploying a sensor network within the pen can enable automated collection of multi-location, multi-parameter environmental data, existing solutions often focus on remote data viewing and simple threshold alarms. In the process of transforming massive, heterogeneous real-time monitoring data into precise, executable control commands, logical gaps often exist. Specifically, this manifests as: incomplete data processing workflows, making it difficult to generate high-quality, structured environmental state descriptions; simplistic environmental assessment methods, lacking a systematic, multi-parameter collaborative state evaluation mechanism; static and singular control strategies, failing to achieve refined matching of specific environmental deviations; and a lack of reliable feedback during control execution. Summary of the Invention
[0003] Therefore, it is necessary to provide an IoT-based sheepfold environment monitoring and control system and method to solve at least one of the above-mentioned technical problems.
[0004] To achieve the above objectives, an IoT-based method for monitoring and controlling the environment of a sheepfold includes the following steps:
[0005] Step S1: Obtain real-time monitoring data collected from various locations within the sheepfold, preprocess the real-time monitoring data, and generate structured environmental data;
[0006] Step S2: Based on the actual values of each monitoring item in the structured environmental data, compare the actual values with the preset standard range of the corresponding monitoring item to generate a single environmental status assessment result;
[0007] Step S3: Based on the evaluation results of individual environmental conditions, match them one by one in the preset control strategy table to generate control instructions for individual environmental parameters;
[0008] Step S4: Based on the control instructions of the generated individual environmental parameters, control the corresponding environmental regulation equipment in the sheepfold to perform single adjustment operations one by one until all individual adjustments are completed.
[0009] The present invention also provides an IoT-based sheepfold environment monitoring and control system for executing the IoT-based sheepfold environment monitoring and control method described above. The IoT-based sheepfold environment monitoring and control system includes:
[0010] The data preprocessing module is used to acquire real-time monitoring data collected from various locations within the sheepfold, preprocess the real-time monitoring data, and generate structured environmental data.
[0011] The environmental status assessment module is used to generate a single environmental status assessment result by comparing the actual values of each monitoring item in the structured environmental data with the preset standard range of the corresponding monitoring item.
[0012] The control command generation module is used to match the results of a single environmental state evaluation with the preset control strategy table one by one to generate control commands for a single environmental parameter.
[0013] The environmental regulation module is used to control the corresponding environmental regulation equipment in the sheepfold to perform single regulation operations one by one according to the control instructions of the generated individual environmental parameters, until all individual adjustments are completed.
[0014] The beneficial effects of this invention are as follows: Real-time data acquisition and structured preprocessing from multiple locations ensure the comprehensiveness and quality of the environmental state description, laying the foundation for accurate judgment. Based on preset standard ranges, each parameter is compared and its status evaluated item by item, achieving a quantitative assessment of the sheepfold's environmental health, transforming environmental problem identification from experience-based judgment to data-driven analysis. Furthermore, by mapping specific environmental states to precise equipment control commands through a preset control strategy table, standardization and automation of control decisions are achieved, avoiding the arbitrariness and lag of manual intervention. The control mechanism of issuing commands one by one, executing adjustments individually, and confirming completion ensures reliable execution and closed-loop feedback for each control action, preventing equipment conflicts and over-adjustment. The entire process links discrete environmental parameter perception, independent state judgment, discrete control decisions, and discrete execution actions into a collaborative organic whole, significantly improving the timeliness, accuracy, and system stability of sheepfold environmental control, providing an effective technical means to create a stable environment suitable for sheep growth and save management costs. Attached Figure Description
[0015] Figure 1 This is a flowchart illustrating the steps of a sheepfold environment monitoring and control method based on the Internet of Things.
[0016] Figure 2 for Figure 1 A detailed flowchart illustrating the implementation steps of step S2.
[0017] Figure 3A schematic diagram of the sheepfold environment monitoring and control process;
[0018] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0019] The technical method of the present invention will now be clearly and completely described with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without inventive effort are within the scope of protection of the present invention.
[0020] Furthermore, the accompanying drawings are merely illustrative of the invention and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and therefore repeated descriptions of them will be omitted. Some block diagrams shown in the drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor methods and / or microcontroller methods.
[0021] It should be understood that although the terms "first," "second," etc., may be used herein to describe various units, these units should not be limited by these terms. These terms are used merely to distinguish one unit from another. For example, without departing from the scope of the exemplary embodiments, a first unit may be referred to as a second unit, and similarly, a second unit may be referred to as a first unit. The term "and / or" as used herein includes any and all combinations of one or more of the associated listed items.
[0022] To achieve the above objectives, please refer to Figures 1 to 3 A method for monitoring and controlling the sheepfold environment based on the Internet of Things includes the following steps:
[0023] Step S1: Obtain real-time monitoring data collected from various locations within the sheepfold, preprocess the real-time monitoring data, and generate structured environmental data;
[0024] Step S2: Based on the actual values of each monitoring item in the structured environmental data, compare the actual values with the preset standard range of the corresponding monitoring item to generate a single environmental status assessment result;
[0025] Step S3: Based on the evaluation results of individual environmental conditions, match them one by one in the preset control strategy table to generate control instructions for individual environmental parameters;
[0026] Step S4: Based on the control instructions of the generated individual environmental parameters, control the corresponding environmental regulation equipment in the sheepfold to perform single adjustment operations one by one until all individual adjustments are completed.
[0027] All specific values involved in this embodiment are exemplary parameters used to clearly illustrate the technical operation process and are not the only limitation of the present invention.
[0028] In this embodiment, IoT sensor nodes deployed within the sheepfold (e.g., temperature, humidity, ammonia concentration, and illuminance sensors) collect environmental parameters at their respective monitoring points at a preset sampling period (e.g., every 5 minutes), generating a real-time data stream containing timestamps, sensor IDs, and raw measurement values. Data preprocessing is performed in the data preprocessing module of an edge computing gateway deployed locally in the sheepfold or a remote cloud platform. The preprocessing process includes verifying the received real-time monitoring data stream, checking the integrity and legality of the data format, and filtering invalid or erroneous data packets caused by transmission interference or momentary sensor malfunctions. Next, the verified data is parsed, extracting the payload, and converting heterogeneous data formats from different manufacturers and protocols into standardized JSON or a specific data structure format. Then, for numerical data (e.g., temperature to 50°C, humidity to 0% to 100%), outlier detection is performed based on a set reasonable physical range (e.g., temperature -10°C to 50°C, humidity 0% to 100%), identifying and removing outliers that clearly exceed the biological survival range or the sensor's measurement range. Finally, valid data collected from all monitoring points within the same time window are organized and stored according to a pre-defined database table structure (fields may include: data collection time, monitoring point location coordinates, monitoring item type, processed monitoring values, data quality identifiers, etc.), generating a structured environmental data table that can be used for subsequent analysis. This data table ensures temporal consistency, spatial locationability, and data quality, providing standardized data input for subsequent environmental status assessment.
[0029] From the structured environmental data generated in step S1, the latest round of actual measurement values are extracted and grouped by monitoring item type (such as temperature, humidity, ammonia concentration, and light intensity) to form a "current monitoring value set". A pre-set "standard range parameter table" defines suitable threshold ranges for sheep growth and health for each monitoring item; for example, suitable temperature range is 15℃~25℃, humidity is 60%~70%, ammonia concentration is below 20ppm, and light intensity is 50~200 Lux. The evaluation module iterates through the "current monitoring value set" item by item: for each monitoring value, it retrieves the corresponding upper and lower thresholds from the "standard range parameter table". Then, it compares the actual value with the thresholds to determine which range it falls into. Based on the comparison results, a standardized status label is generated for each monitoring item. For example, if the measured temperature is 22℃, which is between 15℃ and 25℃, the status label is "Normal"; if the measured humidity is 75%, which is higher than the upper limit of 70%, the status label is "High"; if the measured ammonia concentration is 25ppm, which is higher than the upper limit of 20ppm, the status label is "High". After the traversal is complete, all monitoring items and their corresponding status labels (such as "Temperature - Normal", "Humidity - High", "Ammonia Concentration - High", "Light Intensity - Normal") are combined to form a "Single Environmental Status Assessment Result Set". This result set exists in the form of a list or structured data object, clearly identifying the deviation of each key environmental parameter from the standard range, providing a quantitative and qualitative basis for subsequent control decisions.
[0030] The system receives the "Single Environmental Status Evaluation Result Set" generated in step S2 and accesses the preset "Control Strategy Table" within the system. This strategy table is a mapping table whose core logic defines "what operation should be performed on which device under what environmental conditions." For example, one strategy is: when the "temperature" status is "high," perform the "on" operation on "fan 1" and set the operating parameter to "medium speed"; when the "humidity" status is "high," perform the "open to 30-degree angle" operation on "ventilation window actuator A." The system reads the status labels (such as "temperature - normal" or "humidity - high") in the "Single Environmental Status Evaluation Result Set" one by one. For each status label, the system searches the "Control Strategy Table" for a record that completely matches the "monitoring item type" and "status." If a match is found, the system extracts the "target device identifier" (such as device ID or control address) and "control action and parameters" (such as "on," "set temperature value," "adjust opening degree," etc.) from that record. Then, this information is encapsulated into an independent and complete "control command" data packet. This instruction package typically includes fields such as instruction sequence number, generation timestamp, target device identifier, control action, control parameters, and expected execution duration. For example, if a "humidity - high" state is matched, a control instruction is generated with the following content: {Instruction ID: 20231121001, Device: Ventilation Window A, Action: Open, Parameter: Angle = 30 degrees, Confirmation after execution: Yes}. This process generates a precise and executable device control instruction for each monitoring item that needs adjustment, ensuring the specificity and independence of the control behavior.
[0031] Typically, the system comprises two sub-units: instruction scheduling and device communication. The instruction scheduling unit receives one or more "control instructions for individual environmental parameters" generated in step S3. To prevent device conflicts or power load surges, the scheduling unit can process these instructions one by one according to preset priority rules (such as safety-related parameters taking precedence) or sequence. For a single control instruction to be executed, the scheduling unit parses the "target device identifier" in the instruction and locates the specific environmental control device in the sheepfold (such as the variable frequency fan FAN_001 located on the east wall, or the roller shutter motor WIN_002 located on the roof) through the device registry or network topology diagram. Then, the scheduling unit encodes the "control action and parameter" part of the instruction into a device-recognizable protocol message (such as Modbus RTU instructions, MQTT messages, etc.) through the device communication unit (using wired RS485, LoRa, ZigBee, 4G / 5G, or Ethernet communication methods) and sends it to the target device. After receiving the instruction, the device executes the corresponding single adjustment operation (such as starting, stopping, adjusting speed, changing opening degree, etc.). After sending a command, a wait-and-confirmation mechanism is initiated: waiting to receive a "regulation completion confirmation signal" (usually a status feedback message indicating that the command has been successfully received and executed) from the controlled device. If no confirmation signal is received within the set timeout period (e.g., 30 seconds), the command execution can be marked as failed, and a retry or alarm can be triggered according to the strategy. Once a command is confirmed to have been executed, the scheduling unit then processes the next control command sequentially. This cycle of "sending commands one by one -> waiting for device confirmation -> processing the next" continues until all control commands derived from the "single environmental status evaluation result set" that need to be executed have been processed. This process ensures the orderly and reliable execution of control actions, ultimately completing the closed-loop regulation of the sheepfold environment.
[0032] Preferably, step S1 includes the following steps:
[0033] Step S11: Obtain the raw data streams collected by various environmental sensors at various locations within the sheepfold;
[0034] Step S12: Perform outlier identification and filtering on the original data stream to generate a valid data set;
[0035] Step S13: Perform timestamp alignment and spatial location calibration on the valid data set to generate spatiotemporally aligned data;
[0036] Step S14: Perform format conversion and field mapping on the spatiotemporal aligned data to generate structured environment data.
[0037] In this embodiment, various types of environmental monitoring sensors are deployed in the sheepfold according to functional areas (such as rest areas, feeding areas, and activity areas), including but not limited to: digital temperature sensors (such as DS18B20), digital humidity sensors (such as DHT22), ammonia concentration sensors, illuminance sensors, and carbon dioxide sensors. These sensors are networked via wired (such as RS485 bus) or wireless (such as LoRa, ZigBee) IoT nodes, with each node having a unique device identifier. Each sensor actively collects environmental parameters at a preset sampling frequency (e.g., every 1 minute) or is polled by the aggregation gateway, generating raw data packets containing fields such as "device ID, raw measurement value, sensor type, local timestamp, and signal strength." These heterogeneous data packets are aggregated through the IoT gateway to form a continuous, multi-source heterogeneous raw data stream, which is then uploaded in real time to the data receiving buffer of the cloud or edge server via 4G / 5G or Ethernet links. The raw data stream maintains the initial data format and timing of each sensor node and serves as the starting point for subsequent processing.
[0038] Set reasonable physical or logical threshold ranges for different types of monitoring parameters. For example, set the temperature threshold to 0-40℃ (the survival range of sheep pens), the humidity to 0-100%RH, and the ammonia concentration to 0-100ppm. Read the raw data stream in real time, parse each data packet, and extract the sensor type and raw measurement value. For each measurement value, compare it with the corresponding preset threshold range. If the measurement value exceeds the threshold range (e.g., temperature value is -5℃ or 50℃), or if the detected value jumps beyond a reasonable rate of change within a short period (e.g., temperature changes exceeding 5℃ within 1 minute), the data point will be marked as "abnormal." In addition, perform integrity checks on the data packets themselves, checking CRC, data length, etc., and discard data packets with incorrect formats or failed checks. Data points marked as "abnormal" can be either directly removed or recorded in an anomalous log for analysis. All data points that pass the threshold check and integrity check have their valid fields (device ID, measurement value, sensor type, timestamp) extracted and organized into a structured list temporarily stored in memory or a database, called the "valid data set." This set removes obvious noise and erroneous data, providing a quality foundation for subsequent processing.
[0039] Because each sensor node in the sheepfold uses its own local clock, even with time synchronization, there are millisecond-level differences, and their physical location information needs to be associated with the data. Timestamp alignment refers to obtaining the current UTC time of a high-precision time server (such as an NTP server) as the "base time." Then, for the local timestamp carried by each data point in the valid dataset, compensation and correction are performed based on the known device clock drift (which can be obtained through initial calibration) or network latency, aligning all data points to a unified, high-precision UTC time base, generating a "time-synchronized data set" with a unified UTC timestamp. Spatial location calibration refers to accessing a pre-set "device-location mapping table," which stores the precise installation location coordinates (x, y, z) of each device ID (sensor node ID) in the sheepfold's three-dimensional coordinate system (e.g., with a corner of the sheepfold as the origin, and the X, Y, and Z axes representing length, width, and height directions, respectively). For each data point in the "time-synchronized data set," the mapping table is queried based on its device ID, and the data point's location coordinates (x, y, z) are associated with it as a new field. Ultimately, each data point contains a unified time reference, precise spatial coordinates, device ID, sensor type, and measurement value, forming "spatiotemporally aligned data." This allows each measurement value to be precisely located in both time and space dimensions.
[0040] The received "spatiotemporally aligned data" is still a list of records with various structures. Format conversion refers to serializing the data in this list according to a predefined standard data model (e.g., a relational database table structure or a NoSQL document model). For example, define an "Environmental Monitoring Record" table with fields including: record ID (auto-incrementing primary key), unified UTC timestamp, device ID, monitoring point X coordinate, monitoring point Y coordinate, monitoring point Z coordinate, monitoring parameter type (enumerated type, such as "temperature" or "humidity"), parameter value, and data quality identifier. Field mapping refers to mapping each information item of each data point in the "spatiotemporally aligned data" to the corresponding field in the standard data model. For example, map "device ID" to the "device ID" field, "unified UTC timestamp" to the "timestamp" field, location coordinates (x, y, z) to the "X coordinate," "Y coordinate," and "Z coordinate" fields respectively, sensor type to the "monitoring parameter type" field, and measured value to the "parameter value" field. Simultaneously, this step unifies the numerical units (e.g., temperature is unified to degrees Celsius). Ultimately, the mapped data is inserted into the database table as row records or generated as a file in a standard format (such as JSON Lines or Parquet). This final, standardized collection of data, stored in a database or file, is called "structured environment data." It has a unified schema, facilitating subsequent querying, analysis, and computation.
[0041] Preferably, step S12 includes the following steps:
[0042] Step S121: Identify and mark abnormal data points in the original data stream that exceed the threshold range;
[0043] Step S122: Remove marked abnormal data points from the original data stream to generate a valid data set.
[0044] In one embodiment, a safe and effective range for each monitoring parameter is pre-configured. For example, the lower limit for temperature is set to 0 degrees Celsius, and the upper limit to 50 degrees Celsius; the lower limit for humidity is set to 0% and the upper limit to 100%. The raw data stream is continuously read from the data receiving buffer, and each data packet is parsed to extract the sensor number, measured value, and measurement time information. The monitoring parameter type is determined based on the sensor number, and the corresponding upper and lower threshold values are obtained. The measured value is compared with the threshold: if the value is lower than the lower limit or higher than the upper limit, the data point is determined to be an anomaly exceeding the effective range. An "abnormal" status identifier is added to each abnormal data point, and detailed anomaly information is recorded, including the data source, abnormal value, occurrence time, and the violated threshold rule. Furthermore, to further ensure data validity, this embodiment can also implement rate of change monitoring, i.e., comparing the change in the current measured value from the previous valid measured value using the same sensor. If the change exceeds the preset maximum allowable change per minute, the data point is also marked as a "mutation anomaly." This step does not modify the original data content; it only adds a quality status identifier to each data point.
[0045] Receive the tagged data stream output from step S121. Traverse each data point in the data stream and check its status identifier. If the data point is identified as "abnormal" or "mutation abnormal," it is considered invalid and removed from the current processing flow, not entering the subsequent set. Removed data points can be selectively stored in a dedicated anomaly log database for subsequent equipment maintenance and data analysis. For data points with normal status or no anomaly marker, their core information, including sensor number, measurement value, calibrated timestamp, and location code, is retained. All retained data points are organized according to their acquisition time order to form a new ordered data list, which is the "valid data set." To ensure data integrity, this set is stored in memory or a temporary database. Its data structure is clear, includes necessary fields, and the measurement values of all data points are within a preset valid physical range, providing reliable and formatted input for the next spatiotemporal alignment process.
[0046] Preferably, step S13 includes the following steps:
[0047] Step S131: Add a unified reference time marker to each data point in the valid dataset to generate a time synchronization dataset;
[0048] Step S132: Label the three-dimensional position coordinates of each data point in the time synchronization data set in the sheepfold coordinate system to generate spatiotemporal alignment data.
[0049] In this embodiment, because each sensor node in the sheepfold uses its own clock or synchronizes with an inaccurate network, there is an inconsistency in the timestamps of the collected data. To eliminate this discrepancy, a high-precision time server is preset as the time reference source for the entire system. The "valid data set" generated in step S12 is read, in which each data point already contains the original sensor acquisition timestamp. The current accurate standard time is obtained from the time reference source via a network time protocol. Then, for each data point in the "valid data set," the time difference between its original timestamp and the standard time obtained from the time reference source is calculated. This time difference calculation takes into account known, fixed network transmission delays or device clock offsets. Afterward, this calculated time difference compensation value is applied to the original timestamp, and a calibrated, unified standard time stamp is calculated and generated for each data point. Finally, the original timestamp field in the original data points is replaced with this unified reference time stamp, and a new dataset is generated, called the "time synchronization data set." All data points in this set reference the same high-precision time source, ensuring the consistency and comparability of the entire dataset in the time dimension, laying the foundation for subsequent time series analysis and event correlation.
[0050] During the sheepfold construction or sensor deployment phase, a three-dimensional Cartesian coordinate system has been established, with a fixed point within the sheepfold (e.g., the southeast corner of the sheepfold) as the origin, the east-west direction as the X-axis, the north-south direction as the Y-axis, and the vertical upward direction as the Z-axis. Each deployed environmental sensor has its precisely measured three-dimensional position coordinates within this coordinate system, which have been entered into the "Sensor Position Mapping Table." The "Time Synchronization Data Set" generated in step S131 is read, and each data point within it is traversed. For each data point, based on its "Sensor Number" or "Equipment Identifier" as a key field, the "Sensor Position Mapping Table" is queried to retrieve the sensor's installation position coordinates in the sheepfold's three-dimensional coordinate system. This coordinate system is typically an array containing X, Y, and Z values. This three-dimensional coordinate array is added as a new attribute field to the data point. After traversing and processing all data points in the "Time Synchronization Data Set," a new, enhanced data set is generated. Each data point in this new set not only contains a time-synchronized standard timestamp and sensor monitoring values but also precisely correlates its three-dimensional position within the sheepfold's physical space. The resulting dataset is called "spatiotemporally aligned data". It unifies the temporal basis of the data and gives the data clear spatial attributes, so that any data can be accurately located and referenced in a specific time and space.
[0051] Preferably, step S14 includes the following steps:
[0052] Step S141: Convert the spatiotemporal aligned data into a standard data table format to generate data with a unified format;
[0053] Step S142: Based on the preset field relationship table, rename and classify the fields in the uniformly formatted data to generate structured environment data.
[0054] In this embodiment of the invention, the received "spatiotemporal aligned data" is typically a data list containing multiple records, each of which is a dictionary, an object, or an unstructured document. An internally predefined "standard data table format" specifies the fixed field names, field order, data types, and storage units that each data entry should have. During conversion, records in the "spatiotemporal aligned data" are read one by one. For each record, its internal information items (e.g., unified timestamp, location coordinates X, Y, and Z, sensor number, monitoring parameter type, monitoring value, etc.) are extracted and sequentially filled into a row of the table according to the field order and data type specified in the "standard data table format." For example, the unified timestamp is filled into the "collection time" column, the monitoring value into the "parameter value" column, and the location coordinates into the "coordinates X," "coordinates Y," and "coordinates Z" columns. If the original record contains redundant fields not defined in the "standard data table format," these fields will be discarded during the conversion process. Finally, after all records have been converted, these rows are organized into a two-dimensional table, which is the "uniformly formatted data". This conversion process ensures that all data follows a unified internal storage structure, facilitating subsequent database loading, batch processing, and querying.
[0055] The system contains a "field relationship mapping table," which defines how to map the original field names in the "formatted data" to the unified and intuitive business field names ultimately exposed to external applications (such as data analysis platforms and monitoring interfaces). The system reads the two-dimensional table of "formatted data" and obtains the "field relationship mapping table." Then, each column (i.e., each field) of the table is renamed according to the mapping table. For example, the original field "coord_X" can be mapped to "east coordinate," "param_value" can be mapped to "measured value," and "sensor_id" can be mapped to "device identifier." Simultaneously, the mapping table can also define field classifications. For example, "east coordinate," "north coordinate," and "altitude" fields can be classified into the "location information" category, while fields such as "temperature value," "humidity value," and "ammonia concentration value" can be classified into the "environmental parameters" category. Field classification information is appended to the data in the form of metadata or reflected in the table structure design within the database. After completing field renaming and classification, the generated dataset is called "structured environmental data." It not only has standard, readable field names, but also clear business classifications, which enables data to be stored in the database in a standardized table structure, or provided to the outside world in a standardized data structure through the application programming interface, greatly enhancing the readability, maintainability and interoperability between systems.
[0056] Preferably, step S2 includes the following steps:
[0057] Step S21: Extract the measurement values corresponding to each monitoring item in the structured environmental data to generate the current monitoring value set;
[0058] Step S22: Read the preset standard range corresponding to each monitoring item and generate a standard range parameter table;
[0059] Step S23: Compare the current set of monitored values with the standard range parameter table item by item to generate a list of monitoring item deviation status;
[0060] Step S24: Based on the list of deviation statuses of the monitoring items, generate a status label for each monitoring item to form a single environmental status evaluation result.
[0061] In this embodiment, the system retrieves the latest generated structured environmental data containing information from each monitoring point from the system's data storage area. The system stores the monitoring data in the form of a data table, which includes four main fields: acquisition time, monitoring point number, monitoring parameter type, and monitoring value. Based on the acquisition time field, all valid monitoring records within the most recent evaluation period are extracted. Then, the records are grouped according to the monitoring parameter type, with monitoring values of the same type grouped together. For each parameter type group, a representative value for the parameter at the current moment is determined according to a preset calculation rule. This calculation rule either selects the value from the monitoring point located at the geometric center of the sheepfold within the group, or calculates the weighted average of all values within the group. Finally, each monitoring parameter type and its corresponding calculated representative value are combined into an ordered data pair, and all monitoring parameter type data pairs are integrated to form the current monitoring value set. This set records the current status of various key environmental parameters within the sheepfold.
[0062] An environmental standard database was pre-established, storing standard value ranges for various environmental parameters for different breeds and growth stages of sheep. These standard ranges were set based on animal husbandry research and breeding practice experience. Based on the information of the sheep being raised in the current sheepfold, the corresponding standard parameters were retrieved from the environmental standard database. For each monitoring parameter, its upper and lower limits of the appropriate range were obtained. Then, the parameter name was associated with its corresponding upper and lower limits, and a standard range parameter table was constructed using the parameter name as an index. This parameter table was loaded into memory at runtime, providing a query basis for standard determination.
[0063] Each data pair in the current set of monitored values is processed sequentially. Each data pair includes a monitoring item name and its current value. For each data pair, the corresponding upper and lower standard limits are looked up in the standard range parameter table based on the monitoring item name. Next, the current value is logically compared with the found upper and lower limits. The comparison result is categorized into three cases: the current value is greater than the upper standard limit, the current value is less than the lower standard limit, and the current value is between the upper and lower limits. Based on the comparison result, the deviation status of the monitoring item is determined, described as "exceeding the upper limit," "below the lower limit," or "within the range." The deviation status determination results for all monitoring items are recorded along with the monitoring item name, current value, and standard range information to form a monitoring item deviation status list. This list systematically reflects the deviation between the actual status of each environmental parameter and the standard requirements.
[0064] The list of deviation states for each monitoring item is processed item by item. Based on the deviation states recorded in the list, a standardized state label is assigned to each monitoring item. The label naming rules are as follows: if the deviation state is "within range," the state label is defined as "normal"; if the deviation state is "exceeding the upper limit," the state label is defined as "too high"; and if the deviation state is "below the lower limit," the state label is defined as "too low." The state label and the corresponding monitoring item name together constitute a basic evaluation unit. After processing, the evaluation units of all monitoring items are summarized to form the final single-item environmental state evaluation result. This result is an ordered set containing multiple evaluation units, each unit clearly identifying whether an environmental parameter meets the standard and its deviation direction, providing a structured basis for subsequent control decisions.
[0065] Preferably, step S23 includes the following steps:
[0066] Step S231: Read each value in the current monitoring value set one by one, compare it with the corresponding item in the standard range parameter table, and generate the comparison result;
[0067] Step S232: Based on the comparison results, mark the status of each monitoring item as being within the standard range, exceeding the upper limit, or below the lower limit, forming a list of monitoring item deviation statuses.
[0068] This embodiment loads the current monitoring value set, which is typically a list containing several entries. Each entry explicitly includes a monitoring item identifier and its corresponding current monitoring value. Each entry in the list is read sequentially. For the entry being processed, a search is performed in the standard range parameter table loaded into memory based on the monitoring item identifier in the entry. The standard range parameter table is also indexed by the monitoring item identifier, and each entry explicitly records the standard lower limit and standard upper limit value corresponding to that monitoring item. After finding the corresponding item, the current monitoring value in that entry is compared with the found standard lower limit and standard upper limit values, respectively. This comparison process is executed sequentially: the current monitoring value is compared with the standard lower limit value to determine if it is less than the lower limit; if it is not less than, it is compared with the standard upper limit value to determine if it is greater than the upper limit value. Finally, for each monitoring item, a comparison result is obtained, which clearly indicates the positional relationship of the current monitoring value relative to its standard value range, i.e., "less than the lower limit," "greater than the upper limit," or "between the upper and lower limits." This comparison result provides the basis for the next step of precise status labeling.
[0069] The system receives the comparison results for each monitoring item generated in step S231. An internal state mapping rule is defined, mapping comparison results "less than the lower limit" to "below the lower limit," "greater than the upper limit" to "exceeding the upper limit," and "between the upper and lower limits" to "within the standard range." Based on this rule, a corresponding state description is assigned to the currently processed monitoring item. A structured record is then created, containing at least the following information: monitoring item identifier, current monitoring value, the corresponding lower and upper standard limits read from the standard range parameter table, and the newly assigned state description. This record is added to the "Monitoring Item Deviation State List." After completing the above reading, comparison, state labeling, and record creation process for all items in the current monitoring value set, a complete monitoring item deviation state list is generated. This list systematically and comprehensively records the real-time values, reference standard values, and precise deviation states relative to the standards for each monitored environmental parameter within the sheepfold.
[0070] Preferably, step S3 includes the following steps:
[0071] Step S31: Read the status label of each monitoring item in the single environmental status assessment result set;
[0072] Step S32: In the preset control strategy table, find the corresponding control action and device code based on the status label;
[0073] Step S33: Encapsulate the control action and device code into independent data units to generate control instructions for a single environmental parameter.
[0074] In this embodiment, the complete single-item environmental status evaluation result generated by the aforementioned steps is obtained from the system-specified data storage location or through an internal data interface. This result is a list containing multiple evaluation items, each item explicitly containing the name of a monitoring item (such as "temperature" or "humidity") and its corresponding status label (such as "normal," "high," or "low"). This result list is validated to confirm the integrity of its data format. Then, the list is sequentially traversed, reading each evaluation item it contains one by one. For each traversed item, its content is parsed, and the two key pieces of information, "monitoring item name" and "status label," are extracted and temporarily stored in memory. This reading process is performed one by one until all evaluation items in the list have been processed. The purpose of this step is to extract specific state inputs that can be identified by subsequent control logic from the macro-level environmental status evaluation, preparing for item-by-item matching of control strategies.
[0075] A "control strategy table" is predefined and stored. This table is the core of the control logic, clearly specifying which operation should be performed on which device under what environmental conditions. Each row of the table represents a control strategy, typically containing the following key fields: monitoring item type, status condition, target device code, and control action. For each "monitoring item name-status label" combination read in step S31, a matching search is performed in the control strategy table. The matching search conditions are: the "monitoring item type" field in the table matches the current "monitoring item name," and the "status condition" field in the table matches the current "status label." When a unique record that meets both conditions is found in the table, the match is successful. The "target device code" and "control action" information are read from this record. The "control action" specifically describes the operation that the device needs to perform, such as "start," "stop," "set the speed to medium," or "adjust the opening to 30%." The "target device code" is the code used in the system to uniquely identify a specific controllable device in the sheepfold. This step identifies a clear operation target and operation content for each environmental parameter that needs to be adjusted.
[0076] Step S32 receives the matched "control action" and "target device code" for each monitoring item. A unique instruction sequence number is generated for the control instruction of the currently processed environmental parameter, and the current system time is used as the instruction generation timestamp. This information is then combined and encapsulated into a structured, standardized control instruction data unit. This data unit typically contains the following fields: instruction sequence number, instruction generation timestamp, target device code, and control action. The control action field is further subdivided into action type and action parameters; for example, the action type is "set speed," and the action parameter is "medium speed." After encapsulation, this data unit becomes a complete control instruction that can be directly sent to the corresponding device actuator or communication middleware. This instruction precisely specifies "who (device code)" and "what operation (control action)" to perform. Once all the monitoring items to be processed in step S31 have completed the matching in S32 and the encapsulation in S33, a set of control instructions is generated. Each instruction in this set corresponds to a specific environmental parameter control requirement, and they are independent and executed sequentially.
[0077] Preferably, step S4 includes the following steps:
[0078] Step S41: Based on the device identifier in the control command, locate the corresponding environmental regulation device in the sheepfold;
[0079] Step S42: Send the control parameters in the control command to the located environmental control device to trigger it to perform a control operation;
[0080] Step S43: Receive the adjustment completion confirmation signal returned by the environmental control equipment after executing the control parameters.
[0081] This embodiment receives one or more independent control commands from the control command generation step. The commands include fields such as device identifier and control action. The commands are parsed to extract the device identifier code. This identifier code is assigned by the system during device registration and is used to uniquely identify a specific physical device within the Internet of Things (IoT). An internal "Device Registration and Network Topology Table" is maintained, storing information on all registered environmental control devices, including device identifier code, device type, physical installation location description, and network address (such as IP address, serial port number, and wireless node address). Using the extracted device identifier code as an index, this table is queried to obtain the accurate network address of the target device, and a logical mapping is established to complete device location. This process ensures that the system knows where to send the command. If the device's current communication link is normal (determined to be online through heartbeat mechanisms, etc.), then the command sending preparation phase begins.
[0082] After locating the target device and confirming its communication link is open, the command sending unit initiates. The unit extracts the complete control parameter portion from the control command to be sent, which typically includes the action type and specific parameter values. Based on the target device's communication protocol type, the control parameters are encoded into a command message that the device can recognize and execute. For example, for a variable frequency fan supporting the Modbus protocol, it is encoded into an RTU message containing a specific function code, register address, and speed setpoint; for a roller shutter motor supporting the MQTT protocol, it is encapsulated into a message with a specified subject. After encoding, the command sending unit sends the command message to the target device's network address via the established network connection. The sending operation is single and explicit, designed to trigger the device to perform a single adjustment action defined by the control parameters, such as opening, closing, or adjusting to a specified speed or opening degree.
[0083] After the command is sent, a timer is started to wait for a response. Once the target environmental control device successfully receives and executes the command, it returns an execution response signal to the system according to the agreed communication protocol. This signal typically exists as a message in a specific format, indicating that the command has been successfully received and executed. The response receiving module continuously listens for return messages from the target device's network address. When a response message matching the expectations is received, the module decodes it to confirm that it is a confirmation signal for the command just sent, and not other status information. This confirmation signal is recorded and associated with the corresponding control command, marking the command as successfully executed. If a correct confirmation signal is not received within the preset timeout period, the command transmission is marked as a failure, and the issue is handled according to a preset strategy (such as a retry mechanism) or a device fault alarm is generated. This step constitutes the feedback loop in closed-loop control, ensuring the reliability of control actions.
[0084] The present invention also provides an IoT-based sheepfold environment monitoring and control system for executing the IoT-based sheepfold environment monitoring and control method described above. The IoT-based sheepfold environment monitoring and control system includes:
[0085] The data preprocessing module is used to acquire real-time monitoring data collected from various locations within the sheepfold, preprocess the real-time monitoring data, and generate structured environmental data.
[0086] The environmental status assessment module is used to generate a single environmental status assessment result by comparing the actual values of each monitoring item in the structured environmental data with the preset standard range of the corresponding monitoring item.
[0087] The control command generation module is used to match the results of a single environmental state evaluation with the preset control strategy table one by one to generate control commands for a single environmental parameter.
[0088] The environmental regulation module is used to control the corresponding environmental regulation equipment in the sheepfold to perform single regulation operations one by one according to the control instructions of the generated individual environmental parameters, until all individual adjustments are completed.
[0089] The above description is merely a specific embodiment of the present invention, enabling those skilled in the art to understand or implement the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the present invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features of the invention herein.
Claims
1. A method for monitoring and controlling the sheepfold environment based on the Internet of Things, characterized in that, Includes the following steps: Step S1: Obtain real-time monitoring data collected from various locations within the sheepfold, preprocess the real-time monitoring data, and generate structured environmental data; Step S2: Based on the actual values of each monitoring item in the structured environmental data, compare the actual values with the preset standard range of the corresponding monitoring item to generate a single environmental status assessment result; Step S3: Based on the evaluation results of individual environmental conditions, match them one by one in the preset control strategy table to generate control instructions for individual environmental parameters; Step S4: Based on the control instructions of the generated individual environmental parameters, control the corresponding environmental regulation equipment in the sheepfold to perform single adjustment operations one by one until all individual adjustments are completed.
2. The method for monitoring and controlling the sheepfold environment based on the Internet of Things according to claim 1, characterized in that, Step S1 includes the following steps: Step S11: Obtain the raw data streams collected by various environmental sensors at various locations within the sheepfold; Step S12: Perform outlier identification and filtering on the original data stream to generate a valid data set; Step S13: Perform timestamp alignment and spatial location calibration on the valid data set to generate spatiotemporally aligned data; Step S14: Perform format conversion and field mapping on the spatiotemporal aligned data to generate structured environment data.
3. The method for monitoring and controlling the sheepfold environment based on the Internet of Things according to claim 2, characterized in that, Step S12 includes the following steps: Step S121: Identify and mark abnormal data points in the original data stream that exceed the threshold range; Step S122: Remove marked abnormal data points from the original data stream to generate a valid data set.
4. The method for monitoring and controlling the sheepfold environment based on the Internet of Things according to claim 2, characterized in that, Step S13 includes the following steps: Step S131: Add a unified reference time marker to each data point in the valid dataset to generate a time synchronization dataset; Step S132: Label the three-dimensional position coordinates of each data point in the time synchronization data set in the sheepfold coordinate system to generate spatiotemporal alignment data.
5. The method for monitoring and controlling the sheepfold environment based on the Internet of Things according to claim 2, characterized in that, Step S14 includes the following steps: Step S141: Convert the spatiotemporal aligned data into a standard data table format to generate data with a unified format; Step S142: Based on the preset field relationship table, rename and classify the fields in the uniformly formatted data to generate structured environment data.
6. The method for monitoring and controlling the sheepfold environment based on the Internet of Things according to claim 1, characterized in that, Step S2 includes the following steps: Step S21: Extract the measurement values corresponding to each monitoring item in the structured environmental data to generate the current monitoring value set; Step S22: Read the preset standard range corresponding to each monitoring item and generate a standard range parameter table; Step S23: Compare the current set of monitored values with the standard range parameter table item by item to generate a list of monitoring item deviation status; Step S24: Based on the list of deviation statuses of the monitoring items, generate a status label for each monitoring item to form a single environmental status evaluation result.
7. The method for monitoring and controlling the sheepfold environment based on the Internet of Things according to claim 6, characterized in that, Step S23 includes the following steps: Step S231: Read each value in the current monitoring value set one by one, compare it with the corresponding item in the standard range parameter table, and generate the comparison result; Step S232: Based on the comparison results, mark the status of each monitoring item as being within the standard range, exceeding the upper limit, or below the lower limit, forming a list of monitoring item deviation statuses.
8. The method for monitoring and controlling the sheepfold environment based on the Internet of Things according to claim 1, characterized in that, Step S3 includes the following steps: Step S31: Read the status label of each monitoring item in the single environmental status assessment result set; Step S32: In the preset control strategy table, find the corresponding control action and device code based on the status label; Step S33: Encapsulate the control action and device code into independent data units to generate control instructions for a single environmental parameter.
9. The method for monitoring and controlling the sheepfold environment based on the Internet of Things according to claim 1, characterized in that, Step S4 includes the following steps: Step S41: Based on the device identifier in the control command, locate the corresponding environmental regulation device in the sheepfold; Step S42: Send the control parameters in the control command to the located environmental control device to trigger it to perform a control operation; Step S43: Receive the adjustment completion confirmation signal returned by the environmental control equipment after executing the control parameters.
10. A sheepfold environment monitoring and control system based on the Internet of Things, characterized in that, For executing the IoT-based sheepfold environment monitoring and control method as described in claim 1, the IoT-based sheepfold environment monitoring and control system includes: The data preprocessing module is used to acquire real-time monitoring data collected from various locations within the sheepfold, preprocess the real-time monitoring data, and generate structured environmental data. The environmental status assessment module is used to generate a single environmental status assessment result by comparing the actual values of each monitoring item in the structured environmental data with the preset standard range of the corresponding monitoring item. The control command generation module is used to match the results of a single environmental state evaluation with the preset control strategy table one by one to generate control commands for a single environmental parameter. The environmental regulation module is used to control the corresponding environmental regulation equipment in the sheepfold to perform single regulation operations one by one according to the control instructions of the generated individual environmental parameters, until all individual adjustments are completed.