Abstract:In large-scale pig farms, environmental quality is critical for the health and growth of pigs. To achieve optimal and real-time regulation of the pig building environment, an IoT-based pig building environment control system was developed by using an STM32 microcontroller as the core controller. The system included a PC terminal and an APP remote monitoring platform as well as a touch screen on-site monitoring platform, that can realize real-time control of pig building environment. Meanwhile, an optimal control strategy for pig building environment based on double deep Q-Network (Double DQN) was proposed. It was shown that the average temperature and relative humidity could be controlled at (20.53±1.72)℃ and (74.16±7.84)%. Compared with the control strategy on a single parameter of temperature, the temperature, relative humidity, NH3 concentration, and CO2 concentration in the pig building under the control of Double DQN were closer to the expected value (temperature was 19℃, relative humidity was 75%, NH3 concentration was 10μL/L, and CO2 concentration was 800μL/L). The maximum relative error of indoor temperature and relative humidity under the Double DQN control strategy were 3.7% and 2.5% lower than that under the temperature threshold control strategy, respectively. Furthermore, the average delay of sensor data upload and control instruction delivery were 226ms and 140.4ms, respectively, which achieved the control ability of small monitoring and control delay and high stability. Under the Double DQN control strategy, the total operation time of three fans in one day was 28.01h, and the total power consumption was 11.4kW·h, which could save about 7.39% of the power consumption compared with that of the traditional temperature threshold method. Therefore, the proposed IoT-based control system integrated with deep reinforcement learning strategy was helpful to improve the environmental quality of pig building and improve the level of automation and intelligent control of breeding environment.