- •Novel UV–Vis–NIR spectroscopy system built to scan single corn kernels in motion.
- •Random forest model classifies single kernels by aflatoxin level with high accuracy.
- •BGYF, discoloration, brokenness associated with aflatoxin contamination.
Aflatoxin contamination in corn poses threats to consumer food safety and grower economic stability. Current industrial methods for aflatoxin management in corn focus on the bulk aflatoxin level, which can lead to either acceptance of lots with contaminated corn kernels (consumer food safety risk) or rejection of lots with mostly harmless corn kernels (grower economic loss). This dilemma may be resolved by utilizing spectroscopy to classify single corn kernels. Hence, our research aims to investigate the potential of using a custom-built UltraViolet-Visible-Near InfraRed spectroscopy system (UV–Vis–NIR) to classify single corn kernels by aflatoxin level. Single kernels from cobs inoculated with aflatoxin-producing Aspergillus flavus (240 kernels) and uninoculated cobs (240 kernels) were i) scanned individually for reflectance from 304 nm to 1086 nm by an increment of 0.5 nm; ii) ground; iii) measured for aflatoxin by ELISA. Using the spectra and the aflatoxin concentration, a random forest model was trained on 80% of the kernels to classify single corn kernels above or below 20 ppb of aflatoxin and was tested on the remaining 20% of the kernels. Among 480 kernels, 374 kernels had <20 ppb of aflatoxin and 106 kernels had ≥20 ppb of aflatoxin. The random forest model had a sensitivity of 87.1% and specificity of 97.7% in the training set and a sensitivity of 85.7% and specificity of 97.3% in the test set, which is higher than previous models where kernels were in motion and comparable to models where kernels were stationary. Spectral regions around 390, 540, and 1050 nm are found to be important for classification. This study demonstrated the custom-built UV–Vis–NIR spectroscopy system showed considerable potential in classifying single corn kernels by aflatoxin level while the kernels are in motion.