INTELLIGENT AUTOMATED MONITORING INTEGRATED WITH ANIMAL PRODUCTION FACILITIES

ABSTRACT Increasing population and demand for animal-derived products has raised the need for improved efficiency in managing and controlling animal production. Given this context, the project aimed to develop a device that aids decision-making in animal production. A hardware system was designed for instant measurement of thermal well-being levels, light intensity, and air gas concentration. This hardware integrated DHT11 sensors, an LDR photoresistor, and an MQ-135 sensor. To validate the system, a 30-day experimental study was conducted in an industrial pig farming setting. The collected data was sent to the Thingspeak server using the HTTP protocol. Data management, filtering, and organization were optimized using developed treatment algorithms. The system presented information on air humidity, temperature, ammonia concentration, CO2 levels, luminosity, and enthalpy through interactive images on a dashboard. In the case of a risk situation, the system automatically notified users with an "ALERT" message, facilitating prompt and efficient management response, and minimizing losses. The sensor calibration process yielded a high coefficient of determination (r2 = 0.98). Thus, the developed IoT device represents a viable solution, providing precise environmental conditions to support producers and enhance their efficiency and sustainability.


INTRODUCTION
Despite the economic recession in Brazil in 2014 and the overall decline in agricultural commodities, there has been an increase in the production and export of animal protein.Projections from the USDA (2020) indicate that beef, pork, and chicken production will rise by approximately 14%, 16%, and 20%, respectively, over the next 10 years.These projections reflect the growing demand and the need for more efficient and competitive animal production facilities that incorporate improved thermal insulation to mitigate climate effects (Andreazzi et al., 2018).Integrated monitoring systems are necessary within these facilities to track variables that impact thermal comfort and animal well-being, including temperature, relative humidity, luminosity, and toxic gas concentrations (Rodriguez et al., 2020).
Regardless of recent technological advancements, producers remain vulnerable to industrial monopolies, and the rising costs associated with animal nutrition hinder production competitiveness.To address these challenges, new technologies, such as the Internet of Things (IoT), databases, artificial intelligence, and drones, can empower small-scale producers and contribute to a sustainable future (Van Hilten & Wolfert, 2022).The concentration of greenhouse gases in the atmosphere is expected to intensify climate change and global warming (Malhi et al., 2021).Therefore, enhancing animal production, ensuring biosecurity, and prioritizing animal welfare are crucial in the face of increased demand.The digital transformation of precision agriculture, through the integration of technologies like IoT sensors and AI models, holds promise for improving efficiency and meeting global animal welfare standards (Klerkx et al., 2019;Lampridi et al., 2019).
Engenharia Agrícola, Jaboticabal, v.43, n.2, e20220225, 2023 According to Dhanaraju et al. (2022), the successful integration of these technologies in animal production requires a focus on four fundamental pillars: ecosystem conservation, optimized management of natural resources, sustainable development, and the adoption of information and communication systems.This can involve wireless sensor networks, cameras, drones, satellites, remote or autonomous vehicles, and process management and control platforms.
Although the market has demanded increased productivity and efficiency, and theoretical models have incorporated cutting-edge technologies like intelligent remote sensing integrated with artificial intelligence (Ryu & Tai, 2022), there are still significant challenges to achieving digital transformation in agriculture.These challenges include a shortage of specialized labor and limited support for maintenance.Thus, the present study aims to address these difficulties by developing a digital platform for remote monitoring of gases and climate variables.
With this objective in mind, the study constructed, calibrated, and modeled a sensor network system for realtime monitoring of luminosity, humidity, temperature, and gas concentrations.This system provides notifications to producers in the event of risky climatic conditions within the animal housing.

Experimental Site and Experimental Data
To calibrate the humidity, air temperature, light intensity, and gas concentration sensors, data were collected over a 30-day summer period, from 01/02/2022 to 01/31/2022, in a commercial swine production shed located in Dourados-MS, Brazil.The shed's coordinates are latitude 22.24º 13' 18.54" S, longitude 54.78 ° 48' 23.09" W, and altitude 430 m.The climate type is classified as monsoon Am, characterized by hot and rainy summers and dry winters according to the Köppen classification system.The average annual precipitation is 1400 mm³, and the average annual temperature is 22 ºC (Beck et al., 2020).
Temperature and relative humidity values were recorded every 5 minutes, 24 hours a day, and then averaged hourly and daily.Lighting and gas levels were recorded three times a day, specifically at 7:00 am, 3:00 pm, and 5:00 pm, enabling the determination of daily averages for each time point.

Hardware Development
The hardware employed for data monitoring and cloud-based publishing was developed by integrating the ESP32 microcontroller with the DHT11, MQ-135 sensors, and the LDR photoresistor.The ESP32 programming was carried out using the Arduino IDE (Integrated Development Environment), and it followed a specific sequence of processes.First, the necessary libraries were imported, including the DHT11, Thingspeak, Wire, and ESP8266 Wi-Fi libraries.Next, global variables were defined, and the access credentials (API Key) for the cloud server were configured.Then, the setup function was responsible for configuring pinouts, initializing variables, specifying conditions, and activating the necessary functions.On the other hand, the loop function executed the tasks outlined in Figure 2 within a cycle of 180 seconds.This cycle ensured the repetition of structured tasks at regular intervals.To publish the data in the cloud, the implementation utilized the ESP-MESH network architecture standard (ESPRESSIF, 2016).Unlike traditional architectures, ESP-MESH does not rely on a single point of connection and operates independently of the Wi-Fi signal coverage.This approach provides a more flexible and robust network framework for seamless data transmission and cloud integration.

Hardware calibration
The developed hardware was calibrated using data collected from wireless dataloggers equipped with RHT-Air sensors, which have an INMETRO Certificate (Standard).The calibration process involved recording air temperature (T) and relative humidity (RH) data over a period of seven days.A calibration curve was determined using the least squares method and is defined by [eq.( 1)], as follows: Y -adjustment curve, and x -voltage collected by the sensor.
The calibration functions and their associated uncertainties were determined using Python programming language.The statistical regression method was applied, utilizing the least squares approach.In this method, the adjustment curve (Y) was calculated based on the voltage (x), assuming the linearity of the measurement and the normal distribution of errors.

HTML software development
The designed hardware was integrated into a digital information system.The HEADER element played a role in adding links, configuring the header, and importing libraries.The NAV element structured the navigation menu of the platform, consisting of five options: home, variables, contacts, who we are, and restricted area.
The visual and responsive information sections of the Hypertext Markup Language (HTML) body were separated and classified using individual DIV tag IDs.The INPUT element was used to create a custom data request form, and the FOOTER element provided footer information for the HTML web application.
Data treatment and organization involved using concise and standardized commands.Specific dates were requested by filling in the input form (INPUT), specifying the desired period's initial and final dates in the format YYYY-MM-DD%20HH:NN:SS.
Data retrieval and processing from the server were accomplished by initializing request functions in the Javascript environment.The new XMLHttpRequest() function was used to send requests to the HTTP server, ensuring data filtering occurred only after the confirmation of information receipt.The request status was monitored, and the document.getElementById()function returned the filtered information for the specified element using its identification (ID).
For implementing interactive graphics, the condition's veracity was assessed based on the confirmation status of received forms.If the response was equal to 200, the sequence of tasks was initiated, as depicted in Figure 3.After processing and filtering the data, graph plotting functions were initiated and configured to display temperature and gas levels inside the shed over time.The internal light intensity of the shed was visualized using a donut graph.
The WEB application was structured and categorized with elements, tags, and attributes to configure various sections, paragraphs, footer, font, function activation, and other basic settings.The style of the HTML elements was defined through the "estilos.css"script, which applied different formats to the specified tags and elements.
Automatic notifications were implemented through the IFTT platform based on comfort and thermal stress ranges, as classified by Silva et al. (2022).For pigs, an "ALERT" was triggered when the enthalpy exceeded 63.1 kJ*kg -1 .Evaluating thermal comfort parameters using the ambience index allowed for determining optimal environmental conditions for animal husbandry, as discussed by Cesca et al. (2021).
The recorded luminous intensity and gas concentration in the air were solely stored for informational purposes.According to Hennig-Pauka & von Altrock (2023), these variables hold direct interpretational value in assessing the quality of pig housing systems.Moreover, independent sensors were responsible for recording these variables, ensuring they did not impact the algorithm responsible for the enthalpy alert.
Consequently, the software was programmed to calculate the average enthalpy using Equation 2, as studied by Silva et al. (2020).If the value exceeded 63.1 kJ*kg -1 , an autonomous notification with the message "ALERT" was displayed on the Dashboard and sent via email.Instantaneous values related to luminous intensity and air gas concentration in the shed were also presented.

Sensor calibration
Before the collection of experimental data, the monitoring system underwent a calibration process.The air temperature (T) and relative humidity (RH) sensors were placed in close proximity to an automatic data acquisition system, which included wireless dataloggers with RHT-Air temperature and humidity sensors.These sensors were certified by INMETRO.
The concentration of gases in the air was calibrated using a gas detector called MULTIGAS ULTRA (EX + CO + O2 + H2S + CO2 + NH3), which holds RBC/INMETRO certification.
The luminous intensity sensor was calibrated by comparing its readings with those obtained from a digital luxmeter with a datalogger and USB KR852.The luxmeter was certified and calibrated by INMETRO.
During the calibration process, data was recorded from each sensor (including the developed sensors) at a frequency of every 5 minutes, 24 hours a day, for a duration of 7 days, from 12/06/2021 to 12/12/2021.This data collection period allowed for the generation of calibration curves, which were subsequently incorporated into the developed sensors.The aim was to ensure that the information recorded by the developed sensors aligned with that recorded by the calibrated standard control instruments certified by INMETRO.
Using the collected data, regression curve models were generated using an MS Excel® spreadsheet.Linear calibration equations (Equation 3) were derived to ensure that the developed sensors would provide reliable measurements consistent with the calibrated standards set by INMETRO.

Field data collection and use
After the calibration process, the developed sensor was deployed to collect data continuously for 30 consecutive days, on an hourly basis, within a commercial pork production shed.These newly collected data, integrated with the adjustment equation derived from calibration, were utilized to calibrate and test the visual aspects of the software.
The collected data was analyzed using MS Excel® spreadsheet and the ActionStat supplement.The data underwent normality testing and subsequent quantitative descriptive analysis to examine their distribution and provide a summary of their characteristics.
Through observation, it was assessed whether the information displayed on the sensor's screen coincided with the activation times of the cooling systems within the commercial warehouse.Additionally, the recorded information was compared with that obtained from certified sensors installed within the warehouse itself.This evaluation enabled refinement of the information presentation on the device's screen.The constructed prototype accurately showcased the response variables, namely thermal comfort (enthalpy), light intensity, and concentration of gases in the air.

Experimental data analysis
In this investigation, the collected data was subjected to analysis using normal distributions and analysis of variance.Several statistical tests were utilized, including the Anderson-Darling test, F test for variances, and t-test for equivalent or non-equivalent variances.
The Anderson-Darling test was employed to determine whether the data followed a normal distribution.The test involved formulating a Null Hypothesis (H0) that assumed the data followed a normal distribution and an Alternative Hypothesis (H1) that suggested otherwise.A significance level of 5% was considered for the test.
Following that, the F test was conducted to examine whether the variances between the different data sets were equal.The variables under comparison included air temperature, relative humidity, light intensity, and gas concentration for both the developed sensor and the Engenharia Agrícola, Jaboticabal, v.43, n.2, e20220225, 2023 calibrated standard equipment.If the calculated F value was greater than 0.05, it was concluded that there was no significant difference between the variances.
The t-test was used to analyze variations between two samples of the data sets, considering the hourly scale of the data.Specifically, the variables air temperature, relative humidity, light intensity, and gas concentration were compared between the developed sensor and the calibrated standard equipment.
Overall, the statistical methodology adopted in this study facilitated the assessment of data conformity to normal distributions, the examination of variances for equality, and the identification of significant differences between their means.

Statistical analysis
When applying the Anderson-Darling test, there was insufficient evidence to reject the null hypothesis (H0).Thus, the results indicate that all the data conforms to a normal distribution and no transformation is required.
Table 1 presents the F-test results for variances between the data obtained from the developed Sensor and standard Sensor, focusing on temperature, humidity, and gas concentration.The p-values obtained were found to be less than 0.05, indicating statistical significance.Thereby, the variances between the data are likely the same for all the variables analyzed.2022) conducted research on finishing pigs and concluded that pig performance parameters are not affected by photoperiod or any lighting program.As a result, the luminous intensity sensor of the Developed Sensor was not utilized for data collection.Instead, it was solely employed for direct observation to verify its accuracy of operation and record this information for future application in environments where monitoring of lighting conditions is crucial, such as poultry farming.

Developed Sensor Calibration
Scatter plots (Figures 4.a and 4.b) were generated during data analysis, and linear regression was applied to the mean data.The calibration process demonstrated a strong correlation with a high coefficient of determination, which is typical of well-executed calibration studies (Sanches et al., 2022).In their work, Sanches et al. reported R 2 values of 0.98 for both the humidity and temperature calibrations in the respective instruments.In Figure 4, it is evident that the values of RH (Relative Humidity) and T (Temperature) are increasing and surpassing the minimum comfort limits for animal production.Antunes et al. (2022) conducted studies in a similar region and reported that the ambient temperature reached 38 °C during the hottest periods of the day.
Regarding gas concentration, a scatter plot was created, and linear regression was applied to the mean data (Figure 5).The calibration process involved adjusting the data using a determination coefficient, resulting in an R 2 value of 0.89.The adjustment curve for gas concentration calibration, determined using the least squares method for the exponential case, is represented by [eq.( 4)]:  = 185.93 . (4) Wherein: CS -gas concentration adjustment curve (ppm), and PA -gas concentration collected by the sensor (ppm).

Developed Prototype Analysis
When considering the potential for global monitoring of multiple warehouses simultaneously, the IoT project showcased a cost advantage over individually installed commercial systems that necessitate on-site monitoring.Pereira et al. (2020) examined the application of the Internet of Things (IoT) for monitoring environmental variables within poultry sheds and concluded that IoT implementation can achieve cost savings of up to 13% compared to traditional commercial equipment, while maintaining calibration levels.Therefore, the architecture of the developed project, as depicted in Figure 6, represents an optimized solution for production management.
Engenharia Agrícola, Jaboticabal, v.43, n.2, e20220225, 2023 To handle data retrieval, filtering, and publication, functions such as XMLHttpRequest() and getElementById were employed.These functions were responsible for processing incoming form data and presenting the information on the Dashboard.Baig et al. (2022) developed a monitoring and control Dashboard based on the ESP32 microcontroller, Blockchain technology, and sensors.The Dashboard in our study, illustrated in Figure 8, stood out due to its capability to automatically notify users of potential risks to animal welfare based on environmental conditions.Furthermore, it monitored parameters such as humidity, temperature, luminosity, and CO2 air pollution levels.The observation of enthalpy in this study aligns with the findings of Silva et al. (2020), enabling the evaluation of well-being levels in the environment, as depicted in Figure 8.The activation of the "ALERT" stage occurred when the enthalpy reached 63.1 kJ*kg -1 , coinciding with the times when the shed cooling system was initiated.This provides evidence for the efficiency of the developed prototype.Machado et al. (2021) conducted a study to assess the comfort levels of pigs using the Enthalpy index and emphasized its accuracy in reflecting the physiological state of the animals.
Data classification was performed using standard request commands through the hosting server (ThingSpeak for IoT Projects).In this classification, field1, field2, field3, and field4 represented temperature, humidity, luminosity, and gas concentration, respectively (Figure 9).They also utilized the ThingSpeak hosting server for IoT Projects with the aim of enhancing quality and human well-being.Based on their studies, we can say that the developed prototype not only incorporated the conventional structure but also featured the capability to notify users about potential risks in animal housing based on prevailing climatic conditions.

CONCLUSIONS
Upon completion and calibration, the sensor developed in this study shows real-time monitoring capabilities for luminosity, humidity, temperature, and CO2 gas concentration.Through cloud connectivity, users are promptly notified about the climatic conditions, ranging from comfort to potential risks, within the animal housing environment.
Implementation of remote intelligent monitoring, coupled with real-time notifications to producers, facilitates Figure 1 depicts the electrical circuit diagram illustrating this integration.

FIGURE 1 .
FIGURE 1. Electrical circuit of the developed board.Source: The Authors.

FIGURE 2 .
FIGURE 2. Structure of repetitions of the loop function.Source: The Authors.

FIGURE 3 .
FIGURE 3. Data request and filtering tasks.Source: The Authors.
parameters of the linear equation, and P -Calibrated Standard Sensor (INMETRO).

FIGURE 6 .
FIGURE 6. Global monitoring architecture.Source: The Authors.Table 3 presents a comparison between the microcontroller employed in the monitoring and automatic notification project and microcontrollers typically used in IoT systems, focusing on their respective values.TABLE 3. Comparison between the ESP32 system developed with market technologies.Dourados/MS, Brazil -2022.

FIGURE 9 .
FIGURE 9. Request parameters and data filtering.Source: The Authors.

TABLE 1 .
F test for statistical comparison of variances.

TABLE 2 .
Data comparison by t parametric test.