Multifunctional environmental sensing is crucial for various applications in agriculture, pollution monitoring, and disease diagnosis. However, most of these sensing systems consist of multiple sensors, leading to significantly increased dimensions, energy consumption, and structural complexity. They also often suffer from signal interferences among multiple sensing elements. Herein, we report a multifunctional environmental sensor based on one single sensing element. A MoS 2 film was deposited on the surface of a piezoelectric microcantilever (300 × 1000 μm 2 ) and used as both a sensing layer and top electrode to make full use of the changes in multiple properties of MoS 2 after its exposure to various environments. The proposed sensor has been demonstrated for humidity detection and achieved high resolution (0.3% RH), low hysteresis (5.6%), and fast response (1 s) and recovery (2.8 s). Based on the analysis of the magnitude spectra for transmission using machine learning algorithms, the sensor accurately quantifies temperatures and CO 2 concentrations in the interference of humidity with accuracies of 91.9 and 92.1%, respectively. Furthermore, the sensor has been successfully demonstrated for real-time detection of humidity and temperature or CO 2 concentrations for various applications, revealing its great potential in human−machine interactions and health monitoring of plants and human beings.