Disclosed is an implantable medical device configured to detect opioid overdose symptoms, such as a critically low respiratory rate, and automatically release opioid overdose medication into the body of a user. The embedded device may use a ultrasound- or photoplethysmographic-based technique for monitoring the respiratory rate of the user. Additionally, the embedded medical device can communicate with a paired mobile device and automatically contact medical services and/or emergency contacts when opioid overdose is detected.