Opioid tampering and diversion pose a serious problem for hospital patients with potentially life-threatening consequences. The ongoing opioid crisis has resulted in medications used for pain management and anesthesia, such as fentanyl and morphine, being stolen, substituted with a different substance, and abused. This work aims to mitigate tampering and diversion through analytical verification of the administered drug before it enters the patient. We present an electrochemical-based sensor and miniaturized wireless potentiostat that enable real-time intravenous (IV) monitoring of opioids, specifically fentanyl and morphine. The proposed system is connected to an IV drip system during surgery or post-operation recovery. Measurement results of two opioids are presented, including calibration curves and data on the sensor performance concerning pH, temperature, interference, reproducibility, and long-term stability. Finally, we demonstrate real-time fluidic measurements connected to a flow cell to simulate IV administration and a blind study classified using a machine-learning algorithm. The system achieves limits of detection (LODs) of 1.26 µg/mL and 2.75 µg/mL for fentanyl and morphine, respectively, while operating with >1-month battery lifetime due to an optimized ultra-low power 36 µA sleep mode.