Recently, fluorescent carbon dots as optical sensors have drawn tremendous attention due to their attractive optical properties. Herein, we have presented a facile and economical approach to fabricate nitrogen and sulfur co-doped carbon dots (N, S co-doped C-dots) for the temperature and erlotinib sensing applications. The N, S co-doped C-dots, synthesized by one-step hydrothermal treatment of D-glucose and cysteamine hydrochloride, manifested superior optical performances, good water-solubility, and remarkable fluorescence thermosensitivity. When considered as a temperature sensor, the N, S co-doped C-dots owned significant reversibility, high sensitivity, and good linearity. Moreover, based on the inner filter effect (IFE), the nanoparticle-based sensor displayed a wide linear range of 0.33-13.33μgmL−1 (R2=0.998) and provided an exciting detection limit of 0.027μgmL−1 for quantifying erlotinib. More strikingly, the C-dots sensing system could commendably resist the interference from potential foreign substances, and achieved satisfactory recoveries, which indicated the excellent selectivity and sufficient accuracy of the sensor for real sample analyses. As a simple and effective optical nanosensor, the proposed N, S co-doped C-dots hold admirable promise to broaden the applications in pharmaceutical analysis and others fields.