In the production process of modern pig farm, it is necessary to detect the harmful gases that affect the health of pigs in the pig house, so as to facilitate the pig farm to make production decisions. A wireless detection and acquisition system for harmful gases in piggery based on STM32 is designed. The whole design uses STM32 as the main control unit, and combines sensors such as CO2, H2S, NH3 and wireless data transceiver module. The system realizes the functions of collecting, data processing, displaying and alarming the whole characteristic information of pig farm, and is very suitable for the rapid collection of pig house information in the modern poultry production process.
At present, China’s pig raising industry has gradually developed from small-scale to industrialized and intensive farming. The number of pigs in pig farms is often over 1000 or even tens of thousands, so the disease prevention in pig farms is very important. The regulation level of pig farm environment is the key to prevent diseases and an important factor affecting the production level of pig industry. It is also one of the reasons why the level of pig industry in China lags behind other developed countries. Good ventilation environment can greatly reduce the occurrence of swine diseases, thereby improving the survival rate and economic benefits of pig farms; therefore, detection and reduction of harmful gases in pig farms is a very necessary work in large-scale pig farms.
In recent years, many experts, scholars and researchers have developed a variety of technologies and products to detect and control the environment of pig farms based on different technologies, and have been applied in some large-scale aquaculture enterprises. Document [4] Designed an environmental remote monitoring system using Zigbee technology to collect greenhouse environmental data information. Literature [5] Based on PLC technology, an intelligent monitoring system for improving the environmental quality of piggery was developed. However, the system is the overall detection and control of the environment of piggery, and has no function of regulating and improving the small environment of piglets. Literature [6] Based on ARM and ZigBee wireless network, a system for collecting harmful gases H2S, CO and CH4 is developed. The system uses ZigBee for data communication and PC for real-time monitoring of gas concentration. However, the system is designed with special module and has high cost. Literature [7] designs an electrochemical harmful gas detection system based on programmable circuit. It uses a unified hardware platform to detect the concentration of many harmful gases through serial communication protocol.
However, its wireless communication adopts Wi-Fi mode, and its communication distance is short, and it is very vulnerable to interference and influence of external wireless signals. In order to improve the economic benefit of pig raising and speed up the information process of pig raising, and considering that the environment of pig house is not suitable for wiring, on the basis of the existing research, based on wireless data transmission module and embedded technology, a wireless detection and collection and control system of harmful gas in pig house based on ARM control board is designed to realize the environment of pig house. Remote monitoring and centralized remote control [8-11]. The system mainly consists of the following modules: detection, acquisition and processing module of harmful gas (CO2, NH3, H2S) information in piggery, wireless data transmission module, data display, analysis and decision-making module. The specific working process is as follows: the data of harmful gases and temperature and humidity of pigsty environment are processed by CPU, thermostatic element uploaded to PC by wireless data transmission module for display, and the collected data are analyzed and compared with the normal environmental information of pigsty in database, so as to provide data basis for pigsty managers.
The system has the characteristics of simple construction, high precision, good stability and low cost, and is very suitable for popularization and application. The system consists of STM32 control board, CO2 sensor, air temperature and humidity sensor, H2S sensor, NH3 sensor, illumination conversion module, touch screen and wireless serial data transceiver module. As the control center of the system, STM32 control board is responsible for collecting environmental data of pigsty, which is processed by CPU and transmitted to PC according to the self-defined serial communication protocol. The overall structure of the system is shown in Figure 1. The front end of the system adopts the popular STM32F103RBT6 single chip computer (Italian Semiconductor Company), which has the characteristics of high cost performance, low power consumption and low price. Its hardware resources are abundant and the development process is simple. It is very suitable for electronic products of control class. Its integrated development environment (IDE) is KEIL development software based on C language (ARM company). The hydrogen sulfide sensor adopts British Alpha sensor electrochemical gas sensor. The sensor has the advantages of high sensitivity, good linearity and high selectivity. The chemical principle of the sensor is that the electrodes react with the measured gas to produce electrical signals (mainly current) proportional to the concentration of the measured gas. NH3E 100SE type ammonia gas sensor is used. Its measuring range is 0-100 mg/L and working voltage is 5 V. It is easy to connect with the control board and can be directly connected to the I/O port of MCU. The sensor has the characteristics of high resolution, high sensitivity, good linearity and long life. It is very suitable for detecting harmful gases in poultry and livestock breeding environment. The connection diagram with the terminal device is shown in Figure 2. Because the weak signal output by electrochemical sensor can not meet the detection signal requirement of ADC, it needs to be amplified and processed. This system uses high precision operational amplifier ICL7650 (Intersil), which has the advantages of high gain, low input bias current, fast response and low drift. The output signal of the sensor is amplified to the A/D detection range of STM32. The system uses two stages of amplification, and the first stage uses two ICL7650 with high input impedance and common mode rejection ratio. In order to prevent circuit self-oscillation, 150 pF capacitors are connected in parallel at both ends of R2. The detection circuit is shown in Figure 2. Temperature sensor module adopts single bus sensor DS18B20, which can communicate with MCU and cascade with only one wire.
Each DS18B20 sensor has a unique 64-bit photolithographic ROM code when it leaves the factory. There are four resolutions to choose from. The temperature resolution can reach 0.0625 C. The alarm range of upper and lower temperature limits can be set. The internal structure is shown in Figure 3 and the connection with MCU is shown in Figure 4. The air humidity sensor in pigsty adopts voltage output integrated humidity sensor HM1500 (Humeral Company of America). The sensor belongs to general humidity sensor, and its measuring range is (0%-100%) RH. The sensor has high integration, does not need peripheral components, and is very convenient to use.
It is very suitable for the controller with ADC. Voltage signals in linear proportion to relative humidity can be output, ranging from ( 1 to 4) V, with accuracy of ( 3% RH) and sensitivity of ( 25 mV/RH). Its shape is shown in Fig. 5.
The calculation formula of voltage output is: U0 = 1.079 0.256 8RH. [JZ] RH’= RH * [1-2.4 (TA-23) e-6]. Optical circuit, optoelectronic device, etc. The illumination can be converted to current or voltage value, and then connected to A/D converter to digital value, which can be sent to the controller to detect and control the illumination. The illumination sensor uses HA2003 sensor, which is widely used in greenhouse cultivation, forestry and aquaculture. The principle is that after the illumination is changed into voltage value, the voltage value is converted to 0-2 V voltage value or 4-20 mA current value by conditioning circuit. The module has I2C bus protocol, which makes it easy to interface with the controller.
The connection with the control board is shown in Figure 7. Temperature, humidity, illumination and concentration of H2S, NH3 and CO2 in the environment can be used in modern aquaculture. The system has the characteristics of high acquisition accuracy, convenient operation and strong anti-interference, and has high popularization and application value.