Development and assessment of a low-cost embedded system for evaluation of animal thermal comfort

Technologically advanced animal production requires more controlled environments, aiming to maximize animal performance and, consequently, the profitability of the activity. To do that, it is necessary to instrument, evaluate and diagnose the various rearing environments. Hence, Precision Animal Production is inserted in this context and aims to effectively meet the general needs of the animal, so that it reach its full productive potential, correcting the divergences between the environment and its well-being to guarantee its comfort. Since Brazil is a country with tropical climate, which is a major obstacle, the proposal of this project is to develop a prototype for embedded system of thermal comfort analysis at low cost. Using sensors and the microcontroller Arduino to manage data, this work fulfilled its objective, with a prototype device (WGV-1c) capable of measuring dry bulb temperature, wet bulb temperature, black globe temperature, relative humidity, BGHI and THI with production cost below that proposed by the market.


Introduction
The challenge of the contemporary production of agricultural products is intrinsically linked to optimizing processes and production costs. Ensuring thermal comfort, considering that the intense incidence of solar radiation and the high temperatures observed practically throughout the year in the Brazilian semiarid region can cause stress, causing the animals to decline in production, can increase animal production (Leitão et al., 2013). Therefore, keeping animals away from their thermoneutrality zone compromise their production due to a nutritional rearrangement, since, in situations of discomfort, they prioritize the energy expenditure for euthermia (Mayorga, 2019).
In turn, excessive heat causes a reduction in food intake, which leads to a negative energy balance, but instead of mobilizing fat reserves, the animal uses primary glucose and muscle proteins as fuel. (Rhoads et al., 2013) The orthodox methods of measuring and monitoring climatic conditions in animal production still require the recording and activation of thermal control systems manually. However, these practices can result in errors. Thus, the improvement of the automation and information technology industry makes the control of animal sheds more versatile and precise by reducing human intervention. (Chen & Chen, 2019) Therefore, measuring and correcting the climatic factors that affect animals can guarantee better quality of life and increase their production. However, for this purpose, the device used to assess animal thermal comfort in Brazil still has a high cost of acquisition.
Thus, this work aim to develop a low-cost device (WGV-1c), able to measure the indexes of THI and BGHI, with equipment available in the national market, but in an alternative way and with possibility of adaptation for the control of small establishments.

Methods
The study was conducted in the prototyping laboratory of the Federal University of Sergipe (10º 55' 56" S, and 37º 04' 23" W) and aimed to develop an embedded system for measuring the indexes: Black Globe and Humidity (BGHI) and Temperature and Humidity (THI).
The construction of the embedded system has the following steps: block diagram, material budget, circuit diagram, and the prototyping of the system. Figure 1 shows the block diagram and the programming flow. Sensors collect the data of dry bulb, wet bulb, and black globe temperature, and the relative humidity on the field. Then, the data were managed by the microcontroller of the Arduino Mega. The data collected by the sensors were stored in a file in Notepad format, through the W5100, Ethernet Shield, which supports a microSD card.
The output data were separated by semicolons, so when opened through spreadsheet software they could be managed easily by delimiting the columns by semicolons and changing the decimal separator from dot to comma, whereas the numeric 'float' came in English standard.
It was possible to monitor in real time the environment data by the display, which showed: date, time, dry bulb temperature, wet bulb temperature, black globe temperature, THI and BGHI, which were respectively calculated by the equations proposed by Buffington et al. (1981) (Eq. 1) and Thom (1959)  where: Tdb -Dry bulb temperature (ºC); RH -Average relative humidity of the air (%).
Data downloading can be done by web wire, only needing to connect and enter at the Shield address.
The programming approach to the embedded system with Arduino Mega was developed through the developer IDE, using libraries provided by the manufacturers of the sensors and the logical sequence of data.
Following the programming flow (Figure 1 B), the data were updated on the display every minute and recorded every 20 minutes on the microSD card.
The layout of the system was developed aiming to provide efficiency and ergonomics, so the display was at the operator's reading height and the sensors were at the height of the assessed animal. Therefore, the radiant energy falling on the animal was measured, making the system efficient and ergonomic.
The support of the system sensors and the microcontroller shelter, were separated. Connectors were used to facilitate system maintenance or sensor replacement.
The materials used for the development of this project were purchased at the regional market or recycled, aiming for an acquisition with accessibility and low cost.
The budget contained the acquisition prices of all items, and the parameters for obtaining the THI and BGHI indexes followed the standard required by the norms: ISO 7243 (1989) and ISO 7726 (2001), which suggest a measurement range from 20 to 120 ºC, with accuracy of at least ± 0.5 ºC for 20 to 50 °C and ± 1 °C for 50 to 120 °C for temperature sensors.
The circuit diagram designed to assemble the prototype of the embedded system is represented in Figure 2. The circuit operation depends on the power of the sensors and the logistics operation of the data in the master/slave format, by the I2C (Inter-Integrated Circuit). To arrange the wire of the prototype, the following colors were defined for the circuit: VCC was red, GND was black, OneWire data were yellow, SLC and SDA of I2C was respectively green and orange. In that way, it was arranged with the display, the real time clock, and the four sensors (T1, T2, T3, and Umi). T1, T2, and T3 were the sensors DS18B20, which measured the temperatures, Umi was the sensor HTU21d, which measured the humidity; for the clock, the real time clock DS3231 was used to control the time and date of the system, and the display was a 20x4 display with I2C board.
The prototype of this work had a network configured with a downloadable Web page at the address of the W5100, Shield Ethernet, and since it is connected to a router, the remote access becomes possible. An HTML page was created and programmed to open as soon as the IP address of the W5100 Ethernet module is called at the URL of a connected device's browser.
The calibration was done by analyzing the data collected from the sensors and comparing them with the data of the meteorological station obtained by Cunha (2019), by crossing the data in a linear function. The adequacy of the function will validate the accuracy of the system. The validation of the system, with it working, was done at the Federal University of Sergipe.

Results and Discussion
The establishments that operate based on animal production precision are structured in the automatic and continuous monitoring of the animals and of the elements or variables related to the production and can enhance the efficiency in production and quality control in animal sheds, making producers more capable of responding to trade pressures on their products (Mayorga et al., 2019).
However, having these appliances at low cost to producers has need justified, mainly due to the fact that the mechanisms of primary temperature control depend fundamentally on the environment surrounding the animal, namely: convection, conduction and radiation, which requires a temperature gradient between the animal and its environment to occur (Collier & Gebremedhin, 2015).
Therefore, choosing controllers with the possibility of managing mechanisms to control the microenvironment has a good impact on optimizing the production cost and gain of productivity, so it was decided to use the Arduino Mega At2560, which was from the same working platform of the microcontrollers used by Neto et al. (2015), Santos (2013), Oliveira (2016) and Oliveira et al. (2015). The models used were: Uno, Mega 2560 and Genuino 101, being used always for the reception of sensor data. Neto et al. (2015) make use of a microcomputer for data management in a database. The data transmission of the others was wireless, that is, using Bluetooth modules and Wi-Fi network modules, which can be connected directly to the network interface. Table 1 shows the budget to develop this embedded system. Observe that the total price was R$ 490.00, whereas the market value has a range from R$ 2,490.00 to R$ 5,990.00. At the lowest values there is no data recording, and the high-cost device has anemometer and graphic display. This work used the temperature sensor DS18B20, which has specifications within the norms. However, Neto et al. (2015), and Santos (2013) used in their papers to construct embedded systems of rural establishments the temperature sensor LM35, whose specifications are: operating range: 55-150 º C, consumes 60mA and warms less than 0.1 ºC, so no calibration is required.
HTU21d, humidity sensor used in this work, has a range of 0-100 % and accuracy of ± 2%, different from the sensor used by Oliveira et al. (2015), who chose the humidity and temperature sensor DHT22, which has a resolution of ± 0.5 ºC (maximum: ± 1.0 ºC) with a range from 40 to 80 ºC (Oliveira, 2015). Santos (2013) used the relative humidity sensor STH21, which has typical accuracy of 0.04 °C, allowing readings in the range from 0 to 100% of relative humidity and temperature in the range from 20 to 100 °C (Santos, 2013).
The prototype was built following the proposed layout, as shown in Figure 3a e Figure 3b. The container should receive distilled water to keep the cotton mesh moistened. The system provides easy maintenance because the sensors can be easily replaced, and modified in a practical way, since the box receiving the Arduino can have the connectors replaced by connectors of more ways or increase the number of connectors in the case of adding new sensors.
With the activation of the prototype developed in this work (WGV-1c) and the Meteorological Station of Cunha (2019) from May 1 to May 9, 2019, 416 data were collected for linear regression. In Figure 4A, 4B, 4C and 4D, respectively, the temperature sensor named T1 (dry bulb temperature), T2 (wet bulb temperature) and T3 (black globe temperature), respectively, and the humidity sensor called Umi were calibrated.
The data from the Cunha (2019) station, and the WGV-1c, developed in this study, were highly correlated. The smallest adequacy given by the R² = 0.948 of T3 was not considered significant. The best adequacy was that of the humidity sensor, which showed a very similar behavior, as proved by the R² = 0.9892.
In his work looking for a mobile application for a black globe temperature collector system, Oliveira (2016), at the intersection of data from his apparatus with the Hobo equipment, obtained significant statistical difference, which was mainly due to the stabilized period of the sensors used by the author.      The data from the Cunha (2019) station, and the WGV-1c, developed in this study, were highly correlated. The smallest adequacy given by the R² = 0.948 of T3 was not considered significant. The best adequacy was that of the humidity sensor, which showed a very similar behavior, as proved by the R² = 0.9892.
In his work looking for a mobile application for a black globe temperature collector system, Oliveira (2016), at the intersection of data from his apparatus with the Hobo equipment, obtained significant statistical difference, which was mainly due to the stabilized period of the sensors used by the author. Santos (2013), who used similar methodology, but with different sensors, found a result close to that of this work, having a good approximation of the data and a good adequacy in the regression curve.
Crossing data through a linear function generates the correlation, the dependence of the data. However, it does not mean that there is proximity between the data. Therefore, to evaluate their accuracy, the data were compared by the record over time, as shown in Figure 5A to 5D.
By analyzing the data collected simultaneously and having paired them, it was observed that the data acquired were very similar. The relative humidity data diverges from those of Cunha (2019), as shown in Figures 5A to 5D. However, evaluating the works of Oliveira Jr.
(2016), Santos (2013) and Neto et al. (2015), it was possible to note that this displacement is common and the difference in data occurs due to the accuracy of the sensors used (± 2% in this research).
The temperature sensors further approximated of the data base, inasmuch as, according to the required accuracy, the data had the desired behavior, fitting the data base curve. Thus, there was no need to calibrate the sensors due to the proximity of the data found.
For the validation of the apparatus, it remained from May 17 th to 24 th 2019 in operation in the aviary shed of the Federal University of Sergipe, belonging to the Department of Zootechnics on the São Cristóvão campus. Figure 6 A shows the coherent behavior of the indices during the validation period, with the expected variation for the times of the day, as shown in Figure 6 B, the BGHI elevated to its peak, recorded at noon, and had lower values during the night and dawn. Regarding the very similar values between the BGHI and THI indices, it can be related to the fact that the shed is covered (roof) and receives a low incidence of direct solar radiation.
The device worked normally without the need for handling and was operated at the end of the period only for downloading the data to evaluate the environment through their processing.

Conclusions
1. Using the materials that complied with the parameters established by norm, with a budget of R$ 490.00, it was possible to obtain a product capable of evaluating BGHI, THI, dry bulb temperature, wet bulb temperature, black globe temperature and relative humidity.
2. This system could be adapted to control sheds of small animal producers, since it was made with a microcontroller, fulfilling its objective.
3. There is a necessity to improve the academic papers on this field, to develop alternatives solutions for small animal producers.