Design of a Smart Medical Box for Automatic Pill Dispensing and Health Monitoring †

: Medication non-adherence or mismanagement in medicines schedules such as missing doses, taking the wrong amounts, or having medicines at incorrect times is a serious problem, especially in elderly patients or patients with serious illnesses, and may lead to deadly consequences. This paper proposed a smart medical box that dispenses not only medicines at prescribed schedules but also has a basic health monitoring system for the patient’s temperature, oxygen level, and heart rate detection, thus relieving the patient from visiting a doctor. This device is Raspberry Pi-controlled, having an added security feature of biometric recognition so that the medicine is dispensed to the correct patient. Moreover, the user is notiﬁed once their medicine has been dispensed via SMS. The main aim of this project was to keep the device cost-effective, user-friendly, simple, and beneﬁcial for the elderly population.


Introduction
Continuous advances in the public health sector and medicine are resulting in a miraculous increase in life span and more population division of older adults.This is creating a challenge for the whole world in terms of managing efficient care for elderly people.A recent study showed that the estimation of the annual gain of adults from age 65 and above will drastically exceed 10 million every year around the globe, and more than 60 countries will have around 2 million people in this group by 2030 [1].Most of the pill-dispensing machines designed so far contain compartments as per the requirement of the product and are dispensed by anyone.This device proves to be reliable, easy to use, and very useful in the coordination of personal medication management, especially for older adults.

Literature Review
Medicine dispensers are used to give patients medicine according to a predetermined schedule.The use of pill boxes is an old and common method to remind people about their medicines.Some previous work in this field is as follows; Jabeena Aftab, et al. [1] used Arduino (AT mega328P) for a simple electronic reminder system with a rectangle box subdivided into three equal sub-boxes where each sub-box contains an LED and a buzzer.It used LCD (Liquid Crystal Display) to display the pillbox, a GSM (Global System for Mobile Communications) for sending messages, and an RTC (Real Time Clock Module) for keeping track of the time [1].
Othman, Nurmiza Binti, et al. [2] proposed a pill dispenser with an alarm via smartphone notification.It consists of a power supply of 5 V, a button, an RTC Module, and an IR sensor to count the medicine which is going to be dispensed.Additionally, Arduino Eng.Proc.2023, 32, 7 2 of 6 Mega 2560 was used and all the outputs and inputs of the system were connected to it.It used a relay model for the indirect connection of the Raspberry Pi and the vibration motor to the Arduino 'Instapush' application [2].
Jayamani et al. [3] presented an automatic pill dispenser and consumption monitoring system where a PIC 16F877A Microcontroller was used.This method used Proteus and Mikroc software for the simulations [3].Our project aimed at introducing a biometric recognition mechanism that improves the system's performance by dispensing the medicine to the concerned person only.The novelty of our project is that besides pill dispensing, it is capable of performing a basic health check on the patient.The previous works proposed medical boxes which can only be used by one person.So, due to biometric verification, multiple users can use it, which is an advantage over the already available designs along with basic health checks at home.

Problem Statement
Mismanagement of medication can escalate health issues and can have deadly consequences, especially in elderly persons.This problem needs to be addressed effectively by devising a system through which patients can independently take medicines at prescribed times.

Methodology
A Smart Medical Box is a microcontroller-based machine that controls different sensors and motors.Three stepper motors are used for operating the three compartments.The medicines are stored in the compartment for three different times for instance morning, afternoon, and night.An embedded system is used for the alarm and clock module, and an ultrasonic sensor for hand detection [4].When the patient's hand is detected, the stepper motors will operate, which in turn dispenses the medicine.The heart rate, oxygen, temperature, and biometric sensors are used for basic health monitoring.The patient's medical record along with their previous health record is stored in the database [5].A GSM (Global System for Mobile Communication) is used for sending alert messages to both patients and doctors for medicine time.There is a touch LED attached to the box through which the users will interact with the machine such as adding/removing medicines and checking basic health.When the user clicks on the screen, the keypad appears, and they can easily enter the details.The block diagram is shown in Figure 1a.
Othman, Nurmiza Binti, et al. [2] proposed a pill dispenser with an alarm via smartphone notification.It consists of a power supply of 5 V, a button, an RTC Module, and an IR sensor to count the medicine which is going to be dispensed.Additionally, Arduino Mega 2560 was used and all the outputs and inputs of the system were connected to it.It used a relay model for the indirect connection of the Raspberry Pi and the vibration motor to the Arduino 'Instapush' application [2].
Jayamani et al. [3] presented an automatic pill dispenser and consumption monitoring system where a PIC 16F877A Microcontroller was used.This method used Proteus and Mikroc software for the simulations [3].Our project aimed at introducing a biometric recognition mechanism that improves the system's performance by dispensing the medicine to the concerned person only.The novelty of our project is that besides pill dispensing, it is capable of performing a basic health check on the patient.The previous works proposed medical boxes which can only be used by one person.So, due to biometric verification, multiple users can use it, which is an advantage over the already available designs along with basic health checks at home.

Problem Statement
Mismanagement of medication can escalate health issues and can have deadly consequences, especially in elderly persons.This problem needs to be addressed effectively by devising a system through which patients can independently take medicines at prescribed times.

Methodology
A Smart Medical Box is a microcontroller-based machine that controls different sensors and motors.Three stepper motors are used for operating the three compartments.The medicines are stored in the compartment for three different times for instance morning, afternoon, and night.An embedded system is used for the alarm and clock module, and an ultrasonic sensor for hand detection [4].When the patient's hand is detected, the stepper motors will operate, which in turn dispenses the medicine.The heart rate, oxygen, temperature, and biometric sensors are used for basic health monitoring.The patient's medical record along with their previous health record is stored in the database [5].A GSM (Global System for Mobile Communication) is used for sending alert messages to both patients and doctors for medicine time.There is a touch LED attached to the box through which the users will interact with the machine such as adding/removing medicines and checking basic health.When the user clicks on the screen, the keypad appears, and they can easily enter the details.The block diagram is shown in Figure 1a.We are using the rotating disk dispenser design shown in Figure 1b.This design is still not 100 percent feasible, but it has minimum limitations and can fulfill the maximum goals of our project.We utilized a disk with a hole big enough to catch a single pill only.If Eng. Proc.2023, 32, 7 3 of 6 the size is not exact, then more than one pill will be dispensed, which is the main problem.As there are a lot of pills in the box at a time, there is almost no chance that the pill will not be aligned with the hole.Therefore, the problem of only one pill dispensing at a time is resolved.We incorporated disks that are interchangeable with holes of varying lengths for different pill sizes.The size of the holes is according to the standardized pill sizes [6].

Software Implementation
The software contains coding on a Raspberry Pi using Python, catching, retrieving, and manipulating raw data from the sensors, simulations, and calculations of motor driving circuitry, an ultrasonic sensor for hand detection, biometric verification of patients, and maintaining and updating the database.We used a biometric sensor, R307, which was directly interfaced with Raspberry Pi with the UART interface.The patient needs to put their thumb on the sensor for biometric verification.For Heart Rate and SPO2, we used MAX30102 with its I2C interface protocol.DS18B20 was used for measuring the temperature, and the patient needs to hold it in their hand for measurements.The ultrasonic sensor HC-SR04 was used for hand detection.All the abovementioned sensors were incorporated with the Raspberry Pi directly and readings were shown on an LCD.The SIM800L GSM/GPRS module was used for alert messages, whose circuitry is shown in Figure 2. The GUI was designed on the 'Qt' software to provide a user-friendly interface, PCB on 'Proteus', and the rotating disk dispenser on 'AutoCAD'.We are using the rotating disk dispenser design shown in Figure 1b.This design is still not 100 percent feasible, but it has minimum limitations and can fulfill the maximum goals of our project.We utilized a disk with a hole big enough to catch a single pill only.If the size is not exact, then more than one pill will be dispensed, which is the main problem.As there are a lot of pills in the box at a time, there is almost no chance that the pill will not be aligned with the hole.Therefore, the problem of only one pill dispensing at a time is resolved.We incorporated disks that are interchangeable with holes of varying lengths for different pill sizes.The size of the holes is according to the standardized pill sizes [6].

Software Implementation
The software contains coding on a Raspberry Pi using Python, catching, retrieving, and manipulating raw data from the sensors, simulations, and calculations of motor driving circuitry, an ultrasonic sensor for hand detection, biometric verification of patients, and maintaining and updating the database.We used a biometric sensor, R307, which was directly interfaced with Raspberry Pi with the UART interface.The patient needs to put their thumb on the sensor for biometric verification.For Heart Rate and SPO2, we used MAX30102 with its I2C interface protocol.DS18B20 was used for measuring the temperature, and the patient needs to hold it in their hand for measurements.The ultrasonic sensor HC-SR04 was used for hand detection.All the abovementioned sensors were incorporated with the Raspberry Pi directly and readings were shown on an LCD.The SIM800L GSM/GPRS module was used for alert messages, whose circuitry is shown in Figure 2. The GUI was designed on the 'Qt' software to provide a user-friendly interface, PCB on 'Proteus', and the rotating disk dispenser on 'AutoCAD'.The driver IC (L293D) was used for motor driving circuitry as a two-phase motor driver.L293 and L293D are quadruple high-current half drivers.The sequences used were 0101, 0110, 1001, and 1010.The circuit was then implemented on PCB.The circuit diagram is shown in Figure 2b.

Hardware Implementation
The hardware consists of a power source, circuit boards, stepper motors, a fiber body for the hardware, pill containers, and dispensing path for the pills.
In the hardware, the calculations for motor driver circuitry, disk size, time for the medicine to dispense out of the bottle, and power supply are required.The SIM800L GSM/GPRS module was used to carry out characteristic, just as a regular mobile.It The driver IC (L293D) was used for motor driving circuitry as a two-phase motor driver.L293 and L293D are quadruple high-current half drivers.The sequences used were 0101, 0110, 1001, and 1010.The circuit was then implemented on PCB.The circuit diagram is shown in Figure 2b.

Hardware Implementation
The hardware consists of a power source, circuit boards, stepper motors, a fiber body for the hardware, pill containers, and dispensing path for the pills.
In the hardware, the calculations for motor driver circuitry, disk size, time for the medicine to dispense out of the bottle, and power supply are required.The SIM800L GSM/GPRS module was used to carry out any characteristic, just as a regular mobile.It can receive and send any GPRS information using TCP/IP, HTTP, etc.We used a helical GSM antenna due to its small size, which can save a lot of space on the project [7].We integrated all the components for the final outcome, which is shown in Figure 3.
can receive and send any GPRS information using TCP/IP, HTTP, etc.We used a helical GSM antenna due to its small size, which can save a lot of space on the project [7].We integrated all the components for the final outcome, which is shown in Figure 3.

Design Calculations
In the IC L293D, the calculated current consumed by the coil is 384 mA.In a bipolar stepper motor, the step angle is 1.8 degrees with 200 steps.After summing the currents of sensors, motors, and the Raspberry Pi, the total current was 3.525 mA.Therefore, we could easily use the power supply of 5 V, and 5 A to power the device directly from the power source.For the disk size calculations, we used a bottle with a diameter of 5.8 cm, along with a disk diameter of 5.4 cm, shaft size of 5.8 mm, and the disk hole for the motor was 5.6 mm.
The diameter of the medicine to dispense was calculated as approximately 1.3 cm to 1.5 cm.Therefore, the size of the slit was selected to be 2 cm as shown in Figure 4.The time for the medicine to dispense was calculated using the second equation of motion with the distance of medicine given as 1.5 cm.
The time was calculated as 39 ms.Therefore, the motor was rotated at a speed so that the hole and slit did not interface more than one time.

Design Calculations
In the IC L293D, the calculated current consumed by the coil is 384 mA.In a bipolar stepper motor, the step angle is 1.8 degrees with 200 steps.After summing the currents of sensors, motors, and the Raspberry Pi, the total current was 3.525 mA.Therefore, we could easily use the power supply of 5 V, and 5 A to power the device directly from the power source.For the disk size calculations, we used a bottle with a diameter of 5.8 cm, along with a disk diameter of 5.4 cm, shaft size of 5.8 mm, and the disk hole for the motor was 5.6 mm.
The diameter of the medicine to dispense was calculated as approximately 1.3 cm to 1.5 cm.Therefore, the size of the slit was selected to be 2 cm as shown in Figure 4.The time for the medicine to dispense was calculated using the second equation of motion with the distance of medicine given as 1.5 cm.
Eng. Proc.2023, 32, x 4 of 6 can receive and send any GPRS information using TCP/IP, HTTP, etc.We used a helical GSM antenna due to its small size, which can save a lot of space on the project [7].We integrated all the components for the final outcome, which is shown in Figure 3.

Design Calculations
In the IC L293D, the calculated current consumed by the coil is 384 mA.In a bipolar stepper motor, the step angle is 1.8 degrees with 200 steps.After summing the currents of sensors, motors, and the Raspberry Pi, the total current was 3.525 mA.Therefore, we could easily use the power supply of 5 V, and 5 A to power the device directly from the power source.For the disk size calculations, we used a bottle with a diameter of 5.8 cm, along with a disk diameter of 5.4 cm, shaft size of 5.8 mm, and the disk hole for the motor was 5.6 mm.
The diameter of the medicine to dispense was calculated as approximately 1.3 cm to 1.5 cm.Therefore, the size of the slit was selected to be 2 cm as shown in Figure 4.The time for the medicine to dispense was calculated using the second equation of motion with the distance of medicine given as 1.5 cm.
The time was calculated as 39 ms.Therefore, the motor was rotated at a speed so that the hole and slit did not interface more than one time.The time was calculated as 39 ms.Therefore, the motor was rotated at a speed so that the hole and slit did not interface more than one time.

Results and Discussions
The prototype of the Smart Medical Box was completely successful and all the modules were in working condition.Initially, the testing was performed on one person by saving their biometric data and medicine schedule, and checking their basic health as shown in Figure 5.All the data were successfully saved and checked with all the required details, which are shown clearly in Table 1 of the database.We can save the data of up to 1000 patients.The module was tested on 13 patients.Therefore, when the patients receive the notification, they verify their biometrics and the required medicine will be dispensed automatically.Additionally, new patients can be added by clicking on the new patient entry where they can add new medicines along with details such as medicine names, number of medicines taken, and number of times in a day they have to take medicines.They can enter the time in hours only, such as 0900 (9 am), 1400 (2 pm), or 2100 (9 pm).An existing user can also add/delete/update the medicines.The details are automatically saved when the user moves to a new page.

Results and Discussions
The prototype of the Smart Medical Box was completely successful and all the modules were in working condition.Initially, the testing was performed on one person by saving their biometric data and medicine schedule, and checking their basic health as shown in Figure 5.All the data were successfully saved and checked with all the required details, which are shown clearly in Table 1 of the database.We can save the data of up to 1000 patients.The module was tested on 13 patients.Therefore, when the patients receive the notification, they verify their biometrics and the required medicine will be dispensed automatically.Additionally, new patients can be added by clicking on the new patient entry where they can add new medicines along with details such as medicine names, number of medicines taken, and number of times in a day they have to take medicines.They can enter the time in hours only, such as 0900 (9 am), 1400 (2 pm), or 2100 (9 pm).An existing user can also add/delete/update the medicines.The details are automatically saved when the user moves to a new page.

Conclusions
The smart medicine box is a standalone medical box that not only dispenses medicines according to a prescribed schedule but also provides the facility of checking basic health conditions of the patient such as heart rate, temperature, and oxygen level.The machine has the advantage of biometric recognition so that the medicine is dispensed to the correct user.This project aimed to make the device user-friendly and cost-effective, especially for elderly patients.The time and amount of the medicine can be changed as per the user's requirements.This medical box is incapable of handling non-oral medication, such as inhalers, eye drops, and creams.Therefore, in the future, we can work on non-oral medications, and develop an app that can be accessed by both patients and doctors.This device can currently store three different medicines per patient, which can be enhanced to as many as the user wants.

Figure 1 .
Figure 1.Methodology for the project.(a) Block diagram; (b) rotating disk dispenser design.

Figure 1 .
Figure 1.Methodology for the project.(a) Block diagram; (b) rotating disk dispenser design.

Figure 5 .
Figure 5. GUI for medicine entry.(a) Add new medicine schedule; (b) medicine schedule.

Figure 5 .
Figure 5. GUI for medicine entry.(a) Add new medicine schedule; (b) medicine schedule.

Table 1 .
Database of the patients.

Table 1 .
Database of the patients.