The measurement of chemical oxygen demand (COD) is very important in the process of sewage treatment. The value of COD reflects the effectiveness and trend of sewage treatment to a certain extent, but obtaining accurate data requires high cost and labor intensity. To1 solve this problem, this paper proposes an online soft measurement method for COD based on Convolutional Neural Network-Bidirectional Long Short-Term Memory Network-Attention Mechanism (CNN-BiLSTM-Attention) algorithm. Firstly, by analyzing the mechanism of the aerobic tank stage in the Anaerobic-Anoxic-Oxic (A2O) wastewater treatment process, the selection range of input variables was preliminarily determined, and the collected sample dataset was subjected to correlation analysis. Finally, pH, dissolved oxygen (DO), electrical conductivity (EC), and water temperature (T) were determined as input variables for soft measurement prediction of COD.Then, based on the feature extraction ability of CNN and the advantage that BiLSTM is able to capture the backward and forward dependencies in time series data, combined with the attention mechanism that can assign higher weights to the key data, a CNN-BiLSTM-Attention algorithm model was established to soft measure COD in the effluent from the aerobic zone of the A2O wastewater treatment process. At the same time, root mean square error (RMSE), mean absolute error (MAE), mean absolute percentage error (MAPE) and coefficient of determination (R2) were utilized Three indicators were used to evaluate the model, and the results showed that the model can accurately predict the value of COD and has a high accuracy. At the same time, compared with models such as CNN-LSTM-Attention, CNN-BiLSTM, CNN-LSTM, LSTM, RNN, BP, SVM, XGBoost, and RF etc., the results showed that the CNN-BiLSTM Attention model performed the best, proving the superiority of the algorithm model.The Wilcoxon signed-rank test indicates significant differences between the CNN-BiLSTM-Attention model and other models.