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

Screenshot 2026-06-04 at 2.13.42 am.png
Screenshot 2026-06-04 at 2.13.42 am.png

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:

  1. Automated medication scheduling
  2. Multiple patient support
  3. LED medication reminders
  4. Buzzer medication reminders
  5. Medication acknowledgement detection
  6. Missed medication detection
  7. MQTT communication
  8. CSV logging
  9. GUI dashboard
  10. Web dashboard
  11. Medication adherence graph visualisation
  12. Email notifications through IFTTT
  13. Fault tolerance using Arduino backup schedules
  14. Administrator access control


Hardware Components

Raspberry Pi

The Raspberry Pi acts as the central controller and performs:

  1. Medication scheduling
  2. MQTT broker hosting
  3. Data logging
  4. Dashboard hosting
  5. Notification handling

Arduino Nano 33 IoT

The Arduino Nano 33 IoT acts as the embedded controller and performs:

  1. Reminder activation
  2. LED control
  3. Buzzer control
  4. User response monitoring
  5. Backup schedule execution

Additional Components

  1. LED
  2. Passive buzzer
  3. Slider switch
  4. Breadboard
  5. Jumper wires
  6. WiFi network


Software Requirements

The following software was used:

Raspberry Pi

  1. Raspberry Pi OS
  2. Python 3
  3. Mosquitto MQTT Broker
  4. Flask
  5. Tkinter
  6. Paho MQTT
  7. Matplotlib

Arduino

  1. Arduino IDE
  2. WiFiNINA Library
  3. PubSubClient Library


System Architecture

The system consists of two main devices connected through MQTT over WiFi.

Raspberry Pi responsibilities:

  1. Schedule medication reminders
  2. Send reminder commands
  3. Store medication history
  4. Generate dashboards
  5. Send caregiver notifications

Arduino responsibilities:

  1. Receive reminder commands
  2. Activate LED and buzzer
  3. Monitor patient acknowledgement
  4. Report medication status
  5. 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

Screenshot 2026-06-04 at 2.13.42 am.png

Raspberry Pi

The Raspberry Pi acts as the central controller and performs:

  1. Medication scheduling
  2. MQTT broker hosting
  3. Data logging
  4. Dashboard hosting
  5. Notification handling

Arduino Nano 33 IoT

The Arduino Nano 33 IoT acts as the embedded controller and performs:

  1. Reminder activation
  2. LED control
  3. Buzzer control
  4. User response monitoring
  5. Backup schedule execution

Additional Components

  1. LED
  2. Passive buzzer
  3. Slider switch
  4. Breadboard
  5. Jumper wires
  6. WiFi network

Configure Raspberry Pi

Screenshot 2026-06-05 at 4.52.56 pm.png

Install Mosquitto MQTT Broker:

sudo apt update
sudo apt install mosquitto mosquitto-clients
sudo systemctl enable mosquitto
sudo systemctl start mosquitto

Verify installation:

sudo systemctl status mosquitto

Install Python packages:

sudo apt install python3-pip

pip install paho-mqtt
pip install flask
pip install matplotlib
pip install requests


Configure Arduino

Screenshot 2026-06-05 at 4.52.56 pm.png

Install:

  1. WiFiNINA
  2. PubSubClient

Configure WiFi credentials:

const char* ssid = "Your WiFi";
const char* password = "Your Password";

Configure MQTT broker:

const char* mqtt_server = "Raspberry Pi IP Address";

Upload the sketch to Arduino Nano 33 IoT.

Medication Reminder Operation

Screenshot 2026-06-05 at 4.52.56 pm.png

The system follows the workflow below:

  1. Schedule loaded from CSV file.
  2. Raspberry Pi waits for scheduled time.
  3. Reminder command sent through MQTT.
  4. Arduino activates LED and buzzer.
  5. User responds using slider switch.
  6. Status returned to Raspberry Pi.
  7. Event logged.
  8. Notification sent.

Possible outcomes:

Medication Taken

  1. User activates switch
  2. Status recorded as taken
  3. Notification sent

Medication Missed

  1. No response detected
  2. Status recorded as missed
  3. Alert notification sent


GUI Dashboard

Screenshot 2026-06-05 at 4.52.56 pm.png

The desktop dashboard allows administrators to:

  1. Add patients
  2. Configure medication schedules
  3. View medication history
  4. Start scheduling
  5. Clear logs

The dashboard also displays:

  1. Total medications taken
  2. Total medications missed
  3. Total no-response events


Web Dashboard

Screenshot 2026-06-05 at 4.52.56 pm.png

The web dashboard provides:

  1. Real-time monitoring
  2. Medication history table
  3. CSV export
  4. Medication adherence graph

Launch dashboard:

python3 web_dashboard.py

Access:

http://<RaspberryPiIP>:5000

The dashboard automatically refreshes every few seconds.

Medication Adherence Graph

Screenshot 2026-06-05 at 4.52.56 pm.png

Medication history is analysed and displayed as a graph.

Run:

python3 medicine_chart.py

The graph displays:

  1. Taken doses
  2. Missed doses
  3. No response events

This provides a quick visual summary of medication adherence.

Notifications

Screenshot 2026-06-05 at 4.52.56 pm.png

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

Screenshot 2026-06-05 at 4.52.56 pm.png

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:

  1. Arduino continues operating
  2. Countdown continues locally
  3. 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:

  1. Reminded users to take medication
  2. Recorded medication adherence
  3. Logged events automatically
  4. Generated visual reports
  5. Notified caregivers
  6. 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:

  1. Smart pill dispenser integration
  2. Mobile application support
  3. Cloud database storage
  4. Multi-user authentication
  5. MQTT encryption
  6. 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.