Since the 1960s, levodopa (LDA) has been the standard drug for treating of Parkinson's disease. In this study, a novel benzothiadiazole-based conjugated microporous polymercoated graphene heterostructure (CMP-rGO) was synthesized and used to construct a sensitive photoelectrochemical (PEC) sensor capable of detecting LDA. Under optimal experimental conditions, the intensity of the photocurrent produced by the sensor was linear from 0.005 to 40 μM, and the limit of detection of the sensor was 0.0027 μM. The sensor showed good repeatability, stability, and selectivity for LDA detection. Finally, the constructed sensor was used to detect LDA in levodopa tablets, human serum samples, and urine samples and satisfactory results were obtained. Therefore, the PEC sensor provides a novel platform for the detection of LDA in real samples and broadens the applications of conjugated microporous polymers in PEC sensing.