Smart Medication Reminder and Adherence Monitoring System Using Raspberry Pi and Arduino
by sach15102006 in Circuits > Assistive Tech
72 Views, 1 Favorites, 0 Comments
Smart Medication Reminder and Adherence Monitoring System Using Raspberry Pi and Arduino
Introduction
Medication adherence is a significant challenge, particularly for elderly patients and individuals managing chronic illnesses. Many people forget to take medication at the correct time, which can reduce treatment effectiveness and increase health risks. Traditional reminder methods such as phone alarms and pill boxes provide alerts but cannot verify whether medication was actually taken.
This project presents a Smart Medication Reminder and Adherence Monitoring System that combines Raspberry Pi, Arduino Nano 33 IoT, MQTT communication, dashboards, notifications, and fault tolerance to create a practical healthcare monitoring solution.
The system automatically reminds patients to take medication, records whether medication was taken or missed, stores adherence history, notifies caregivers, and provides monitoring dashboards.
Project Features
The system provides the following functionality:
- Automated medication scheduling
- Multiple patient support
- LED medication reminders
- Buzzer medication reminders
- Medication acknowledgement detection
- Missed medication detection
- MQTT communication
- CSV logging
- GUI dashboard
- Web dashboard
- Medication adherence graph visualisation
- Email notifications through IFTTT
- Fault tolerance using Arduino backup schedules
- Administrator access control
Hardware Components
Raspberry Pi
The Raspberry Pi acts as the central controller and performs:
- Medication scheduling
- MQTT broker hosting
- Data logging
- Dashboard hosting
- Notification handling
Arduino Nano 33 IoT
The Arduino Nano 33 IoT acts as the embedded controller and performs:
- Reminder activation
- LED control
- Buzzer control
- User response monitoring
- Backup schedule execution
Additional Components
- LED
- Passive buzzer
- Slider switch
- Breadboard
- Jumper wires
- WiFi network
Software Requirements
The following software was used:
Raspberry Pi
- Raspberry Pi OS
- Python 3
- Mosquitto MQTT Broker
- Flask
- Tkinter
- Paho MQTT
- Matplotlib
Arduino
- Arduino IDE
- WiFiNINA Library
- PubSubClient Library
System Architecture
The system consists of two main devices connected through MQTT over WiFi.
Raspberry Pi responsibilities:
- Schedule medication reminders
- Send reminder commands
- Store medication history
- Generate dashboards
- Send caregiver notifications
Arduino responsibilities:
- Receive reminder commands
- Activate LED and buzzer
- Monitor patient acknowledgement
- Report medication status
- Execute backup reminders if Raspberry Pi becomes unavailable
Communication occurs through MQTT topics:
medicine/command
medicine/status
Circuit Connections
LED
LED Positive → Arduino Pin 6
LED Negative → GND
Passive Buzzer
Buzzer Positive → Arduino Pin 7
Buzzer Negative → GND
Slider Switch
Switch Output → Arduino Pin 2
Switch Ground → GND
The switch is configured using INPUT_PULLUP mode.
MQTT Communication Design
MQTT is used because it provides lightweight communication suitable for IoT systems.
Raspberry Pi publishes:
Topic:
medicine/command
Example:
take_medicine
Arduino subscribes:
Topic:
medicine/command
Arduino publishes:
Topic:
medicine/status
Possible values:
taken
missed
Raspberry Pi subscribes:
Topic:
medicine/status
This architecture allows real-time communication between both devices.
Supplies
Raspberry Pi
The Raspberry Pi acts as the central controller and performs:
- Medication scheduling
- MQTT broker hosting
- Data logging
- Dashboard hosting
- Notification handling
Arduino Nano 33 IoT
The Arduino Nano 33 IoT acts as the embedded controller and performs:
- Reminder activation
- LED control
- Buzzer control
- User response monitoring
- Backup schedule execution
Additional Components
- LED
- Passive buzzer
- Slider switch
- Breadboard
- Jumper wires
- WiFi network
Configure Raspberry Pi
Install Mosquitto MQTT Broker:
Verify installation:
Install Python packages:
Configure Arduino
Install:
- WiFiNINA
- PubSubClient
Configure WiFi credentials:
Configure MQTT broker:
Upload the sketch to Arduino Nano 33 IoT.
Medication Reminder Operation
The system follows the workflow below:
- Schedule loaded from CSV file.
- Raspberry Pi waits for scheduled time.
- Reminder command sent through MQTT.
- Arduino activates LED and buzzer.
- User responds using slider switch.
- Status returned to Raspberry Pi.
- Event logged.
- Notification sent.
Possible outcomes:
Medication Taken
- User activates switch
- Status recorded as taken
- Notification sent
Medication Missed
- No response detected
- Status recorded as missed
- Alert notification sent
GUI Dashboard
The desktop dashboard allows administrators to:
- Add patients
- Configure medication schedules
- View medication history
- Start scheduling
- Clear logs
The dashboard also displays:
- Total medications taken
- Total medications missed
- Total no-response events
Web Dashboard
The web dashboard provides:
- Real-time monitoring
- Medication history table
- CSV export
- Medication adherence graph
Launch dashboard:
Access:
The dashboard automatically refreshes every few seconds.
Medication Adherence Graph
Medication history is analysed and displayed as a graph.
Run:
The graph displays:
- Taken doses
- Missed doses
- No response events
This provides a quick visual summary of medication adherence.
Notifications
IFTTT is used for caregiver notifications.
When medication is taken:
medicine_taken event is triggered.
When medication is missed:
medicine_missed event is triggered.
The caregiver receives an email notification immediately.
Fault Tolerance
One of the most important features of this project is fault tolerance.
Before every scheduled reminder, Raspberry Pi sends a backup countdown schedule to Arduino.
Example:
backup_schedule|Linda|Morning Dose|120
This means:
Trigger backup reminder after 120 seconds.
If Raspberry Pi becomes unavailable:
- Arduino continues operating
- Countdown continues locally
- Medication reminder still activates
This ensures the next medication reminder is not missed due to communication failure.
Testing
The following tests were completed:
Reminder Test
Result:
PASS
LED and buzzer activated correctly.
Medication Taken Test
Result:
PASS
Switch activation recorded correctly.
Medication Missed Test
Result:
PASS
Missed dose logged correctly.
MQTT Communication Test
Result:
PASS
Messages exchanged successfully.
Dashboard Test
Result:
PASS
Logs displayed correctly.
Notification Test
Result:
PASS
Emails received successfully.
Fault Tolerance Test
Result:
PASS
Arduino activated backup reminder after Raspberry Pi disconnection.
Results
The system successfully:
- Reminded users to take medication
- Recorded medication adherence
- Logged events automatically
- Generated visual reports
- Notified caregivers
- Continued operating during communication failures
The project demonstrates the practical application of embedded systems and IoT technologies in healthcare monitoring.
Future Improvements
Potential improvements include:
- Smart pill dispenser integration
- Mobile application support
- Cloud database storage
- Multi-user authentication
- MQTT encryption
- Machine learning based adherence prediction
Conclusion
This project demonstrates how embedded systems, IoT communication, dashboards, and fault tolerance techniques can be integrated to solve a real healthcare problem. The Smart Medication Reminder and Adherence Monitoring System provides automated reminders, adherence monitoring, caregiver notifications, and backup operation during failures. The solution improves reliability compared to traditional reminder methods and illustrates the practical use of embedded technologies in healthcare applications.
Assignment Note
This article is part of an assignment submitted to Deakin University, School of Information Technology, Unit SIT210/730 – Embedded Systems Development.