Morphine, as one of the most important narcotic drugs, significantly affects the nervous system and increases euphoria, which raises the likelihood of its misuse. Therefore, its measurement is of great importance. In this work, a new electrochemical sensor based on a nanocomposite of CuS/g-C3N5/AgNPs was developed for modifying Screen printed carbon electrodes (SPCEs) and used for the measurement of morphine through cyclic voltammetry and differential pulse voltammetry. Various analytical methods initially characterized the nanocomposite. The prepared sensor, which also has an extensive surface area, achieved a detection limit of 0.01 µM for morphine in a concentration range of 0.05–100 µM at pH 7. Besides its excellent capability in measuring morphine in real samples, the sensor exhibits good stability, reproducibility, and repeatability. The presence of CuS, due to its excellent high surface area alongside silver nanoparticles, leads to an increase in the conductivity of the g-C3N5 modified electrode, resulting in an increased oxidative current of morphine at the surface of the prepared sensor. Therefore, measuring low concentrations of morphine with this sensor was made possible. Additionally, measuring morphine without interference from various species is a strong point of the electrochemical sensor for morphine detection, and combined with the simplicity and ease of the method, it allows for morphine measurements to be conducted in the shortest possible time.