Design and test of intelligent inspection and monitoring system for cotton bale storage based on RFID

To solve the inspection problems in cotton storage, as well as the need for environmental monitoring in the process of modern cotton bale storage, an intelligent inspection and temperature and humidity intelligent monitoring system based on RFID cotton bale was developed by adopting RFID (Radio Frequency Identification) technology, wireless temperature and humidity real-time monitoring technology and handheld terminal intelligent inspection technology. The system was composed of RFID positioning inspection module and temperature and humidity real-time monitoring and transmission module. The artificial neural network (ANN) based on the particle swarm optimization (PSO) algorithm was used to process the monitoring data of the system by Gaussian filtering, and an accurate classification model of RSSI and label position was established. The test results showed that: Through the comparative analysis of the RFID indoor positioning algorithm, the positioning error of the PSO-ANN algorithm was small. In the actual cotton bale warehouse test, the relative error of positioning and monitoring for RFID cotton bale intelligent inspection and monitoring system was less than 6.7%, which effectively improved the working efficiency of inspection personnel and the security of cotton bale storage. The relative error of temperature and humidity was less than 8% and less than 7%, which could display the temperature and humidity information in real time and meet the real-time demand. This study improved the management personnel's effective positioning and inspection of the cotton bale, prevented the loss of cotton bale, reduced the deterioration probability of cotton bale, and effectively improved the storage management level of the cotton bale. It was of great practical significance to realize the networking, automation, and intelligence of cotton bale storage management.

The number and scale of warehousing enterprises in China are showing a trend of rapid growth. At the same time, due to national conditions and development reasons, as well as the physical characteristics and special storage environment of cotton, there are problems such as mildew, fire, theft, etc. [1][2][3] . For a long time, for the safety of cotton in the warehouse, bale warehouse still adopts the methods of manual periodic inspection, which requires a large number of inspectors to put into work. Due to the variability of manual inspection 4 , it is difficult to ensure the quality of decision management, especially the means and methods of large and medium-sized intelligent cotton storage urgently need to be improved. It is very important to carry out real-time inspection and temperature and humidity monitoring of cotton stacks in the process of cotton storage.
For the monitoring and processing of positioning information 5,6 , domestic and foreign experts and scholars have carried out research on multi-sensor fusion technology 7,8 , wireless communication technology [9][10][11][12][13] , and optimization algorithm technology [14][15][16] , which have effectively improved the intelligence level of critical operation monitoring 17 . Since RFID 18,19 has the advantages of non-contact reading of information, large data storage capacity, and small volume [20][21][22] , it could be better applied in monitoring and management of cotton stack storage 23 , and the optimization processing algorithm was adopted to improve positioning 24,25 and environmental temperature and humidity monitoring accuracy 26 . For example, Ullah et al. 27 developed a mathematical model, compared with the cost of the card reader, the proposed RFID system has more significant sensing power Omer Working principle of RFID intelligent inspection system. As shown in Fig. 2, RFID technology is used as the basis to realize real-time collection of the information of the cotton stacks in the warehouse. RFID tags are affixed to the cotton stacks in the storage process. At the same time, the wireless card readers are orderly arranged in the warehouse, and the label information read by wireless card readers are reported to the network card reader. Path optimization is achieved by using the Greedy algorithm, and then the optimal path planning route is transmitted to the handheld terminal.
Principle of temperature and humidity wireless monitoring. As shown in Fig. 3, the wireless monitoring of temperature and humidity mainly collects the cotton stack warehouse in real-time and with high preci- www.nature.com/scientificreports/ sion. The temperature and humidity sensor is arranged in the cotton bale warehouse to send the temperature and humidity value of the cotton bale warehouse to the handheld terminal through wireless transmission.

Hardware system design
As shown in Fig. 4, the system hardware is mainly composed of integrated temperature and humidity sensors, RFID positioning system devices, and intelligent inspection terminal equipment.   www.nature.com/scientificreports/ RFID inspection module. As shown in Fig. 5, RFID positioning inspection is mainly composed of RFID tag, network card readers, wireless card reader, location service platform, and handheld terminal. RFID tag is an active electronic tag used to locate the cotton stack. Fixing the electronic tag on the cotton stack and installing a card reader around or on the top of the room, the real-time monitoring of the position of the indoor cotton stack can be realized and the specific position and distance of the electronic tag within the effective range can be determined.
Location server. The location server is shown in Fig. 6. Each positioning base station accesses to the location server and receives the label information from each positioning base station. Through data analysis and signal field strength calculation, the location information of each label is obtained and finally sent to the management platform, which sends the inspection information to the handheld terminal. The technical parameters are shown in Table 1.  Figure 5. Block diagram of the hardware structure of the RFID inspection system.  www.nature.com/scientificreports/ shown in Table 2, the card reader antenna can be extended to 50 m (9600 bps), can measure the field strength of the wireless signal of the electronic tag, and calculate the actual distance of the tag. The network card reader is with 10-26 V wide voltage power supply, and consumption current does not exceed 500 mA (12 V).
Electronic tag wireless card reader. As shown in Fig. 8, the wireless card reader is connected to the network card reader as a sub-station of the card reader. After reading the label information, the card reader reports the location information to the service platform. The specific location of the electronic tag within the effective range can be determined. The distance between the electronic tag and the antenna is calculated by measuring the field strength of the tag wireless signal. The relationship between the distance and the wireless signal strength is parabolic. As shown in Fig. 9, the specific conversion formula of the distance measurement formula is: In the formula, D is the distance converted according to the signal strength, in cm; RSSI is the signal strength, and the absolute value is in dBm; P is the parameter, which is related to the antenna; L is the parameter, which is related to the antenna.

The cotton stack positioning algorithm
ANN is a highly complex algorithm inspired by biology, which can solve complex nonlinear problems through modeling. Reference 40 optimized the structure of ANN, determined the best vector network, improved the stability of the ANN algorithm, reduced the positioning error, but did not filter out the noise data in the experiment. Therefore, to improve the positioning accuracy, the data was processed by Gaussian filtering in this paper, and   www.nature.com/scientificreports/ a positioning algorithm based on PSO optimization ANN(PSO-ANN) was proposed, and environmental noise was preprocessed by the Gaussian filtering to compensate for the positioning defects of ANN, thus improving the prediction effect of ANN and the learning speed of ANN.

PSO-ANN positioning method.
In this study, PSO was used to optimize the initial weight and threshold parameters of ANN, and Gaussian filtering was used to preprocess the noise barriers in the storage environment, which reduced the label positioning error and made up for the ANN positioning defect. In the real-time positioning of cotton bales, the signal strength will reflect, diffract and scatter in the storage environment and the common model of signal path loss in the storage environment is where RSSI(d) is the RSSI obtained by the reader, P(d 0 ) is the RSSI with a reference distance of d 0 , n is the proportional coefficient of the path loss, and X is the randomly distributed Gaussian noise. PSO-ANN has outstanding performance in terms of efficiency and positioning accuracy. The PSO particle continuously updates its speed and position. The update formula is where V id (t) is the iterative velocity of the particle at the t time iteration,X id (t) is the iterative position of the particle, c 1 and c 2 are the learning factors, usually c 1 and c 2 have the same value, the value range is [1,3], r 1 and  www.nature.com/scientificreports/ r 2 are It is a uniform random number in the range of 0-1, P best is the best position of each particle during the update process, and G best is the value of all particles Best location.
Cotton stack positioning model. For cotton bale storage location, it is necessary to construct the mapping relationship between RSSI and location (Loc) preprocessed by Gaussian filtering, that is,GRSSI j → Loc j , where GRSSI j is the RSSI value of the j time tag received by each reader, and Loc j is the first. The position coordinates of j labels. In the application process, . . GRSSI n j } ; Loc j is the coordinates of the j-th reference label, that is Loc j = {x j , y j } . Therefore, PSO-ANN was used in this paper to find the positioning target mapping connection f : GRSSI j → Loc j that is f (GRSSI j ) ≈ Loc j . Since the above mapping relationship was non-linear, PSO-ANN was selected to solve this problem in the process of positioning the bale. The structure of the positioning algorithm is shown in Fig. 10.
Gaussian filtering. To reduce the noise error, the collected data were processed by Gaussian filtering with the formula as follows: In the formula, σ 2 is the variance, A is the expected value, and where n is the number of times to measure the RSSI value, and RSSI j is the RSSI value measured for the i-th time.
According to the 2 σ Gaussian distribution criterion, remove the data with a small probability and easy to be disturbed, and keep the data as the effective date for the position positioning of the positioning system. This method can filter most erroneous data, so the accuracy of the system's monitoring results is improved.
Optimal layout of the network card reader. The signal sent by the RFID reader to the tag decreases with the increase of the propagation distance. Since the RSSI value measured at a certain point during positioning will fluctuate constantly, and the fluctuation of the RSSI value generally follows the Gaussian distribution, the positioning result is related to the Euclidean distance of the signal space between the positioning tags. The layout of the card reader during storage can be equivalent to plane optimization, and the position of the reader on the plane distribution can be optimally solved by PSO algorithm. The solution process is shown in Fig. 11.
The specific steps of PSO-ANN are as follows: (1) Set the relevant parameters according to the actual input samples of the ANN: the number of nodes in the input layer is set to n, the number of nodes in the hidden layer is set to s, and the number of nodes in the output layer is set to m. (2) Set the PSO-related parameters: the initial position of the particles is X 0 , the initial velocity is set to V 0 , the number of particles is N, the maximum number of iterations is m, the learning factors are c 1 and c 2 , and the values are equal. (3) Calculate the fitness value of each solution according to formula (7), and obtain P best and G best .
where N is the total number of training samples, L is the number of output neurons in the network, y ij is the expected output value of the i-th output node, and y ij is the actual output of the i-th output point.  www.nature.com/scientificreports/ (4) Output the optimal global solution of the PSO algorithm, and calculate the current fitness value fi of all particles. If f i < P best , P best is the individual optimal, X i = P best , otherwise f i is the individual optimal. If f i < G best , then G best is the global optimal solution, X i = P best , Otherwise, f i is the optimal solution, where X i is the current position of the particle. The optimal solution, where X i is the current position of the particle. Temperature and humidity sensor. As shown in Fig. 12, it is a block diagram of the temperature and humidity sensor. To monitor the temperature and humidity in the cotton bale warehouse, a wireless temperature and humidity monitoring module, the sensor chip 1-SHT20 temperature and humidity sensor and sensor chip 2-LIS3DH three-axis acceleration sensor were selected in the system, with battery model CR2032, transmit power − 20 to + 4 dBm. The 1-s broadcast interval can work continuously for 1 year. The default output is 0 dBm, and the transmission distance is 50 m. ThenRF52832 wireless Bluetooth transmission technology is used to monitor temperature and humidity, and the maximum rate supports 400 kbps; size: 48 mm in diameter, and 23 mm in height. Through the design of the temperature and humidity module of the RFID cotton bale intelligent inspection system, the temperature and humidity sensor was redeveloped and designed, in which the temperature conversion formula is: www.nature.com/scientificreports/ where T is the temperature value, ℃; S oT is the temperature data read from SHT20 by the main control chip; d 1 and d 2 are temperature conversion coefficients. Relative humidity conversion formula: where RH linear is the relative humidity; The humidity data read by S oRH from 1-SHT20 by the main control chip; c 1 , c 2 and c 3 are humidity conversion coefficients. Because the measurement of humidity is affected by temperature, the temperature compensation of the sensor should also be considered when measuring humidity. The compensation formula is: where RH true is absolute humidity; t 1 , t 2 are temperature compensation coefficients. Combining the design of the temperature and humidity module, the temperature accuracy S oT is 14 bits, and the humidity accuracy S oRH is 12 bits. Substituting the coefficient results into Eqs. (8)-(10), we can get:

Software system design
According to the requirements of reliability, real-time and maintainability of the cotton bale storage intelligent inspection monitoring system, the handheld inspection terminal system software program is written in Java language. The system software design flowchart is shown in Fig. 13a. When the system was started, the initialization program was first performed. After receiving the instruction to be inspected from the platform, the handheld terminal sent the position information of the cotton pile to be inspected to the handheld terminal device through wireless data transmission, and the inspection personnel collected the information of the cotton stack to be inspected to the handheld inspection terminal equipment through the handheld inspection terminal device. The inspection content included image collection of cotton stack, the barcode information of cotton stack, and temperature and humidity, which were uploaded to the platform system by taking pictures. As shown in Fig. 13b in the process of inspection, the handheld terminal device receives the inspection information of the platform, and adopts the greedy algorithm to realize the path optimization. taking The algorithm takes the position of the inspector as the starting point, and indicates the inspection route through signs to realize the optimal path optimization of the inspection personnel., and the algorithm is easy to implement and efficient.

Test and analysis
Simulation comparative analysis. To verify the feasibility of the RFID cotton bale intelligent inspection system, the test area is 25 m × 25 m, and the simulation environment is shown in Fig. 14. In the positioning map, the lower-left corner was the origin of coordinates, with 30 reference labels, and 10 reader antennas were placed in the positioning map to collect RSSI sample values of PSO-ANN. The distances to 10 readers were calculated respectively, and the corresponding RSSI vectors were generated according to Formula (1). The coordinates of the reference tag and its corresponding signal strength vectors were used as the training data of ANN and PSO-ANN so that the trained ANN and PSO-ANN could predict the position of the tag to be fixed. The RSSI vector of the reference label was used as the training data of PSO-ANN and ANN, and used as the input of the positioning model to predict the position coordinates of the cotton rick label. The network was trained by DPS. Through many experiments and simulations, the number of nodes in the hidden layer was 5, 3 of which was hidden layers, and the number of node in the hidden layer was 5. The position coordinates of the cotton stack were neurons of the output layer and were dependent variables, the excitation function was Sigmoid, the parameter was 0.9, the minimum training rate was 0.1, the allowable error was 0.0001, and the dynamic parameter was 0.6. This paper, the positioning errors of ANN and PSO-ANN were compared, and the comparison results are shown in Fig. 15. It can be seen from Fig. 15 that the positioning error of the PSO-ANN algorithm was generally smaller than that of the ANN algorithm, that is, PSO-ANN had better positioning accuracy of the cotton stack. Table 3 shows the other two different localization algorithm the average position error obtained in reference 41 , by comparing the average error of 4 kinds of algorithms. It can be seen that the traditional algorithm positioning effect was inferior to the other three kinds of localization algorithm, and the proposed algorithm error was smaller than the reference 41 of the algorithm, it shows that the proposed algorithm can provide relatively reliable positioning data (Fig. 16).
ANN was easy to fall into local optimum in nonlinear prediction. Optimizing ANN with PSO can greatly improve the learning rate of ANN and find the global optimum solution through iteration. Table 4 compares the effects of different training methods on training efficiency and error. It can be seen from the results in Table 4 that the algorithm proposed in this paper can effectively reduce the training time and improve the positioning accuracy (Table 4).

RFID cotton bale positioning test.
To further verify the practical application effect of RFID positioning inspection system in cotton bag warehouse, a performance test was carried out in December 2020 in Baoding in YIN XIANG cotton industry co., LTD., Hebei province. Figure 17 shows the bale warehouse test site. The cotton www.nature.com/scientificreports/ package storage storehouse was set up with 10 card reader, and Cotton stack RFID and wireless temperature and humidity sensor were placed in the cotton pile. The RFID tag was placed cotton bags to start the location service platform, and the location server, network card reader, and wireless card reader device were powered on, which can effectively monitor the RFID tag and real-time movement, and display the coordinate position information of the tag. The X and Y coordinates detected by the cotton bale positioning inspection system were the measured values, and the positioning tests were carried out for different labels. The label position error is calculated according to the formula: www.nature.com/scientificreports/ where (x 1 , y 1 ), (x 2 , y 2 ) are the coordinates of two points A and B, respectively, where point A is the position of the RFID positioning tag, and B is the origin of the coordinates, The test record data is shown in Table 5.
The test showed that the RFID cotton bale positioning monitoring system, based on the test data of the RFID tag positioning information, showed that the relative error of the system monitoring was less than 6.7%. The reason for the error was that the positioning distance was based on the positioning of the tag by the base station. The accurate distance was calculated by the signal field strength. In the case of a long cotton pile, a slight error   Figure 16. The legend of Table 3. www.nature.com/scientificreports/ would occur. After debugging for many times, the error can be effectively improved by arranging multiple base stations, and the monitoring requirements can be met based on performance and technical indicators required by the system. Fig. 18, in the view of the temperature and humidity monitoring situation, because the warehouse environment is not easy to change, in order to better test the temperature and humidity sensor monitoring effect, the temperature and humidity monitoring device was tested in the National Quality Inspection Center. Through monitoring the temperature and humidity in the constant temperature and humidity box, the temperature and humidity displayed on the display screen of the constant temperature and humidity box were taken as the actual value, and the value displayed on the hand-held terminal of the storage system was taken as the measurement value. The temperature and humidity value of the constant temperature and humidity box was constantly adjusted and recorded, as shown in Table 6. Through the temperature and humidity monitoring effect test of the temperature and humidity monitoring sensor, the test results showed that the temperature monitoring error of the system was less than 8%, which met the monitoring requirements. The error was caused by the uneven temperature value in the temperature and humidity constant temperature and humidity box. By adjusting the time, the error can be effectively improved, effective monitoring can be realized within the expected index range, and temperature monitoring met the monitoring performance index requirements.  www.nature.com/scientificreports/ Humidity sensor test. By adjusting the humidity value of the constant temperature and humidity box, the humidity of the temperature and humidity sensor of the system was monitored. The handheld terminal for inspection was wirelessly connected with the sensor through Bluetooth, and the data was transmitted to the bale inspection system in real-time, and the humidity of the temperature and humidity sensor was tested. When using a constant temperature and humidity box and the temperature and humidity sensor humidity monitoring comparison, testing in different environments. By adjusting the actual humidity value of the constant temperature and humidity box and the measured value monitored by the system temperature and humidity sensor, it can be concluded whether the humidity measurement of the system is normal and accurate. The test results are shown in Table 7.

Temperature sensor test. As shown in
Through the temperature and humidity monitoring effect test of temperature and humidity monitoring sensor, the test results showed that: temperature measurement error was less than 8%, and relative humidity error of the system was less than 6%. The temperature and humidity sensor monitoring device can monitor real-time temperature and humidity monitoring values, and the system ran normally and met the design requirements. The error is caused by uneven temperature and humidity in the temperature and humidity constant temperature and humidity box. By adjusting the time, effective monitoring within the range of expected indicators could be achieved and the requirements of monitoring performance indicators could be met.  www.nature.com/scientificreports/

Conclusion
A scheme based on RFID warehousing intelligent inspection system was proposed in this paper, and the overall scheme design of the system was carried out, mainly including hardware design and software design. The realtime sensor technology, wireless transmission technology, and intelligent monitoring technology was applied to Cotton stack warehousing in the system, which achieved the purpose of monitoring the temperature and humidity of circulation in the cotton stack storage warehouse. Many cotton stack warehouse can be inspected in real time through hand-held terminals, and cotton package information can be uploaded to the platform in real time, which reduced the wiring cost and maintenance difficulty, also liberates the labor, and has a broad application prospect in the cotton industry. An RFID intelligent inspection terminal was developed in the system, which integrated RFID positioning technology and wireless temperature and humidity monitoring technology in the system platform, and adopted the method of particle swarm optimization (PSO) algorithm to optimize artificial neural network (ANN) to process the system monitoring data by Gaussian filtering, and established an accurate classification model of RSSI and tag position. Through the comparison and analysis of the algorithms, the positioning error of the PSO-ANN algorithm was generally smaller than that of the ANN algorithm, that was, PSO-ANN had better positioning accuracy of cotton stacks.
Through the demonstration application and experiment of the National Quality Testing Center, the RFID cotton bale positioning inspection and temperature and humidity monitoring system were tested respectively. The test results showed that the positioning accuracy error was less than 6.7% and the temperature and humidity monitoring accuracy error was less than 8% and 7%. The system can monitor the temperature and humidity of the warehouse and the positioning information of the cotton stack, with high reliability and low cost, and effectively realize the automation, information, and intelligence of the storage management of cotton bale.  www.nature.com/scientificreports/