Abstract:Straw, as the primary agricultural waste in China, is the main material for biochar production. The fixed carbon, volatile matter, and ash content are key indicators that influence biochar quality and guide the parameters of pyrolysis processes. Aiming to address the need for rapid detection of these indicators in straw carbonization production lines by designing a straw composition detection module. Utilizing near-infrared spectroscopy, a method for detecting straw components was developed. A portable spectral sensor was selected and a diffuse reflectance detection path was designed. A spectral collection unit was established to capture spectra of coarse-cut straw in the 1100~2500 nm range. By applying Savitzky-Golay convolution smoothing(SG), multiple scattering correction (MSC), standard normal variate (SNV) preprocessing, and partial least squares regression (PLS), quantitative prediction models were developed for fixed carbon, volatile matter,,and ash content by using full wavelengths and feature wavelengths selected by competitive adaptive reweighted sampling (CARS). Results indicated that models based on feature wavelengths outperformed those using full wavelengths. The optimal models for fixed carbon, volatile matter, and ash content were SG+MSC-CARS-PLS, SG-CARS-PLS, and SG+MSC-CARS-PLS, with prediction set correlation coefficients R2 of 0.891 6,,0.931 7, and 0.929 7, respectively. The root mean square errors of prediction set (RMSEp) were 1.46%,1.39%, and 0.42%, yielding relative prediction deviations (RPD) of 2.54, 3.44, and 3.18, demonstrating accurate prediction capabilities. Furthermore, an online detection module for straw composition was designed. The module was divided into three units: the spectroscopic acquisition unit, the power supply unit, and the control and transmission unit. The pre-built model for predicting straw composition was embedded in the module. Based on the Raspberry Pi 4B development board and its built-in Wi-Fi module, it enabled functions such as online spectroscopic acquisition, model computation, and data transmission for straw. Through prototype testing, it was demonstrated that the module design and window location selection could capture near-infrared spectroscopic curves that met the requirements for online analysis. By using the slope/intercept calibration method, the laboratory model was transferred to the production line for online application. The prediction accuracy of fixed carbon,,volatile matter, and ash content was improved, fulfilling the requirements for online analysis and providing data support for the regulation of pyrolysis process parameters.