The aim was to evaluate and optimize the performance of sensor monitors in measuring PM2.5 and PM10 under typical emission scenarios both indoors and outdoors. Parallel measurements and comparisons of PM2.5 and PM10 were carried out between sensor monitors and standard instruments in typical indoor (2 months) and outdoor environments (1 year) in Shanghai, respectively. The optimized validation model was determined by comparing six machining learning models, adjusting for meteorological and related factors. The intra- and inter-device variation, measurement accuracy, and stability of sensor monitors were calculated and compared before and after validation. Indoor particles were measured in a range of 0.8-370.7 μg/m3 and 1.9-465.2 μg/m3 for PM2.5 and PM10, respectively, while the outdoor ones were in the ranges of 1.0-211.0 μg/m3 and 0.0-493.0 μg/m3, correspondingly. Compared to machine learning models including multivariate linear model (ML), K-nearest neighbor model (KNN), support vector machine model (SVM), decision tree model (DT), and neural network model (MLP), the random forest (RF) model showed the best validation after adjusting for temperature, relative humidity (RH), PM2.5/PM10 ratios, and measurement time lengths (months) for both PM2.5 and PM10, in indoor (R2: 0.97 and 0.91, root-mean-square error (RMSE) of 1.91 μg/m3 and 4.56 μg/m3, respectively) and outdoor environments (R2: 0.90 and 0.80, RMSE of 5.61 μg/m3 and 17.54 μg/m3, respectively), respectively. Sensor monitors could provide reliable measurements of PM2.5 and PM10 with high accuracy and acceptable inter and intra-device consistency under typical indoor and outdoor scenarios after validation by RF model. Adjusting for both climate factors and the ratio of PM2.5/PM10 could improve the validation performance.