An IoT-Based Pill Management System for Elderly

of


Introduction
In the last few years, the average age of the world population has been growing rapidly.Statistics affirm that the number of the elderly in the world is growing by 3.26% per year [1].In addition, according to recent reports of health organizations, world societies are expecting more growth in communities of elderly individuals.Global Age watch index estimates that the aging population will continue to increase to reach 1.4 billion in 2030 and 2.1 billion by 2050 [2].
As the rate of aged individuals grows, the number of individuals suffering from chronic diseases such as diabetes, high blood pressure will continue to rise.These conditions usually require people to take multiple medications regularly to help them complete their daily life activities safely and autonomously.Thus, due to cognitive deficits correlated to age as memory deficits, older people with intricate medication routines often tend to forget about their intakes, timings, and doses.This frequently leads to wrong medication intakes, which can cause serious health consequences.Medication adherence is considered a major medical concern.To support them in medication intake, elderlies often appeal for help.However, relatives and caregivers who frequently help the elderly in remembering their medication intakes face a daily burden while dealing with their own lives and assisting these individuals.In addition, the recent pandemic of Covid-19 has emphasized the importance of providing independent autonomous living to seniors.
In this perspective, multiple tools and solutions were developed to support the elderly in this particular activity.It was found that senior individuals have high acceptability of using smart kits and technological solutions [3].Smart pill dispensers are one of the most preferred solutions [4].A study shows that the demand for smart pill dispensers will keep increasing [5].
The use of IoT paradigm in the healthcare industry has offered various efficient applications and systems with different architectures [29].
In this context, we present an IoT based smart pill management system.It consists of a connected pill dispenser connected with a mobile application installed for four main users.The main users of the proposed system are the patient, the doctor, the pharmacist, and the caregiver.The developed system works on two main modes: the assistance mode and the programming mode.In the assistance mode, the pillbox continuously checks the current time using NTP (network timing protocol).Before 10 minutes of the prescheduled intake, a notification is sent to the mobile phone of the patient in order to notify him/her of his/her intake.When the intake time arrives, the pillbox emits sounds and lights using a buzzer and a LED to alert the patient.An LCD is also used to display directives for the patient.However, if the patient decided to take his/her pill in the 10 minutes that precede the right intake time, the pill dispenser alarms are automatically cancelled.
In the programming mode, the pharmacist schedules wirelessly the pill dispenser and refills the pills compartment one by one using a simple interface on his/her cellphone.The doctor is also able to write and edit prescriptions for his/her patient remotely anytime.For medication adherence monitoring, the proposed system provides all of the users with real-time intakes history.In addition to the gradual assistance in medication reminders, the presented system keeps safe the pills, the patient, and the relatives living with him.
The rest of this paper is structured as follows: Section 2 presents a brief review of the existing pill dispensers.The system architecture as well as its operating logic and modes are presented in Section 3. Section 4 presents the design and implementation of the mobile APP and the pill dispenser.Section 5 contains the results and discussion.Finally, conclusions and perspectives are presented in Section 6.

Literature review
Existing medication adherence solutions vary from simple electronic devices which are the traditional pill organizers [6] to complex intelligent systems such as pill dispensers.This paper mainly focuses on the review of the recently developed pill dispensers.Medication dispensers as electromechanical organizers are able to dispense the right pills with the right doses for the users [7].By comparing different conceptual and implementation aspects, pill dispensers may be reviewed according to the used pill dispensing mechanism, the developed programming mode of the dispenser, the way pills intakes' reminders are delivered and the developed intakes monitoring method.
To remind the assisted individual of his/her medication, first developed pill dispensers mainly used visual and acoustic reminders such as buzzers to emit sounds and LEDs to turn on lights [8].
The authors of [9] used an eccentric rotating mass (vibrator) along with a buzzer to provide the alarms; while [10] [11] [12] implemented playback modules and speakers for pills reminding, in addition to LEDs and LCDs that provide visual assistance.Others opted for the use of vocal messaging to provide the intakes alarms.In [11] a voice message saying "take vitamin tablet" is announced whenever it is time for the scheduled pills.
The use of smartphones in healthcare as well as Android Applications is found to be a powerful and promising manner to improve consumer-oriented products [26] [27].
There are pill management systems that have associated mobile applications to the pillboxes [12] [13] [14].These systems use mobile notifications to alert the patient about his/her intakes.Others, e.g., [15] used both mobile application notifications along with pill dispenser alarms to alert the patient.However, the user may be confused due to these double reminders and may take his/her pills twice.Furthermore, many of the proposed systems used LCDs or OLEDs screens to display medicines' relative information [16].
The second aspect to discuss pill management systems is the way the pill dispenser is programmed and filled.Most of the developed dispensers require that the caregiver or the patient repeatedly fill the pills and schedule the intake timings [17] [18] [8] [9] [12] [19].Thus, they leave the programming and filling mode unsecured.In this case, the patient has access to the pill dispenser outside the intake hours.Also, anyone may fill the pills and even edit pill schedules.[20] and [21] point out the importance of respecting prescriptions and the consequences of mistaking pills, so it is very important to secure pill dispensers and make pill scheduling and filling process accessible only by health professionals.
To secure the pill dispenser, [15] used an identification protocol based on person identification via camera, thus no information was provided whether the programming mode of the pillbox is also secured.Others like [16] secure the scheduling process but ignore the security of the filling process.In their system, the scheduling is done by physicians through a web application.Thus, no information was given on how the filling is done.In [14] the patient himself/herself is responsible for pill filling whereas it is the doctor who does the scheduling of the intakes.
Another important detail in pill dispensers is the method used for dispensing the medication.The dispensing method used in medication dispensers is very important since it impacts the medication adherence of the patient and also the security of both the patient and the relatives living with him/her as well.
Some of the developed systems use vital signs to dispense the pills only when it is necessary [22] [23].However, this is not adopted for elderly individuals with memory deficits since they do not emit any reminders.The authors of [15] and [24] use ultrasound sensors to detect the presence of the individual before dispensing the pills.If a presence is detected, the scheduled pill will automatically be dispensed.Yet, this may put at risk infants or illiterate adults living with the patient, since it blindly frees the medication.Similar solutions are described in [14] and [25] which automatically open when the intake time comes.In case of non-response from the patient, the pills remain accessible for all the individuals living with him/her.In [18] an infrared sensor is used to detect if the pill has been taken or not.However, if the patient does not respond in 10 min the pillbox locks automatically.
A simple yet efficient technique for pill discard was used by [10] and [12].The tablet compartment opens only if a push-button is pressed.The authors of [15] used a more sophisticated technology, where a PIR sensor and a camera are used.Whenever a movement is detected around the pillbox, the camera is activated and identifies the person around.If it is a correct intake time, the pillbox unlocks and dispenses the medication.This method is the most secure technique for pill dispensing.However, in some cases when the senior is not ready to take his/her pill yet and passes around the pillbox, the pill will be dispensed and will remain accessible to the patient relatives which represents a risky situation.Also, medication remains exposed to ambient factors such as temperature and humidity.Furthermore, the use of cameras may be displeasing for some seniors as they see it as a privacy issue.
For the monitoring techniques, some of the presented systems such as [17] [12] [13] provide no track of the intakes.Others use a variety of methods to this end.The monitoring technique used in [8] [10] [18] relies on sending messages alerts to the patient's caretaker or doctor if he/she does not take his/her scheduled pill.In addition to sending an SMS to the caregiver, [8] uses IR sensors in the compartments, whenever the sensor detects a presence, the pill is supposed to be taken.These two methods are useful yet they do not offer detailed medication tracking.
The authors of [28] used body sensors to develop a health monitoring system for individuals with cardiac risk.Their findings proved the efficiency of using sensors in preserving peoples' health.
In pill management systems, biosensors are also used to report the state of the user and check whether the medications have been taken on time or not.The authors of [25] [13] developed a more suitable solution for intake supervisions.In their system, the pharmacist and the doctor monitor the consumption of the patient via their mobile application.However, the patient has no record of his/her intakes.To confirm the real consumption of pills a load sensor HX711 is used [19].Whenever the patient takes the pill from the pill dispenser, the weight decreases, and the intake is confirmed.However, this pill dispenser is not adapted for elderly use.
Despite the proven efficiency of the cited pill dispensers, they do not completely meet the needs of elderly population.While developing a pill dispenser for elder individuals, it is very important to take into consideration the cognitive deficits that the elderly may suffer such as memory, initiation and planning deficits.Also, it has been noted that some of the used techniques require that the patient interacts directly with the system, but for illiterate seniors or those lucking for skills and abilities, this may not be suitable.In addition, to protect the pill dispenser from unauthorized individuals, particular attention to security and safety issues is required.Through the literature review, it was noticed that few or no smart pill management system regroups all the elderly needs, also no safety measures were developed.In addition, none of them offers a gradual reminding to the users.
The main objective of this paper is to offer the elderly with memory deficiencies a pill management system that offers gradual assistance for medication intake.Even though many pill dispensers were developed, no medication management system offered gradual assistance.Assisting the elderly with a gradual method is an important aspect that helps in medication adherence and technology acceptance.This aspect is often ignored in previous research.The existing pill dispensers use either smartphone notifications or pill dispensers' alarms, the few that reassemble both techniques often cause disturbance to the users.The assistance acts in this pill management system are provided by both the dispenser and the smartphone with gradation.The provided acts respect as well the acoustic and eyesight deficits the elderly may suffer from because of old age.
Through research, multiple pill dispensers are proposed, most of them are similar and do not pay attention to security aspects.Hence, in the present work, the security of the senior using the pillbox as well as the individuals living with him/her are taken into consideration.
Moreover, the existing pill dispensers require physical intervention to be programmed, while the dispenser of this system is wirelessly and securely programmed.The connected pill management system is fully connected and the intake tracking is done remotely.
We developed a pill management system adapted to elderly needs suffering from mild cognitive impairments related to age.In this system, we address multiple issues.Mainly, simple gradual assistance is provided for the users so as to increase their adherence to medication by giving them more time to take their scheduled pills.Our system uses multiple means of assistance.This way individuals with visual or acoustic deficits and also elderly with few skills in operating IT are able to handle productively.The implemented pill dispenser is connected with a mobile application that ensures full medication monitoring for the preauthorized users, and it is manipulated only by health professionals.A secured dispensing mechanism is implemented so that the pills stay out of reach of unauthorized individuals and also from authorized individuals outside their intakes timings intervals.In addition, no privacy-invading technique was used in the development of this system.

System design
Figure 1 presents the overall system units and the main users.The proposed system is used by four main users: the patient, the doctor, the pharmacist, and the relative of the patient.It is composed mainly of a mobile application developed under Android Studio and a connected pill dispenser.The communication between all users and the pillbox as well as the communication between the users are done wirelessly using their mobile application and Wi-Fi through WebSockets.Only two actors, the patient and the pharmacist, interact physically with the pill dispenser.
Figure 2 shows the block diagram of the designed system.It shows the main components and modules of the pill dispenser.The block diagram was designed to be used as a template while developing the system.The five main modules that compose our system, namely the hardware assistance modules, the control unit, the dispensing module, and the software module will be discussed in Section 4.
The ESP8266 is considered as the communication unit of this system since it provides the connection between the mobile applications and as it is responsible for the communication between all actors and the mainboard.Arduino UNO controls all of the hardware components of the pill dispenser, i.e., the pill dispenser mechanism and the hardware assistance part.A power supply is used to make the pillbox portable.The software assistance part is the patient mobile application.It communicates mainly with the considered Wi-Fi module.

Operating logic
Figure 3 shows the operating logic of the proposed system.
To operate in assistance mode, the smart pillbox needs to be programmed and filled at the start.
The box checks the actual time using the internet.Before 10 minutes of a scheduled intake, the system emits a notification through the mobile application on the main user's smartphone to prepare him/her for his/her intake.In the 10 minutes that follow if the patient decides to take his/her pill, he/she can easily unlock the box by confirming his/her presence using the touch button.If so, the pillbox opens the right compartment.If the user confirms his/her intake, the box locks up, sends feedback to the mobile application and passes to a standby mode where it keeps checking the actual local time.If the intake is not confirmed, the smart pillbox will automatically lock and notify the user through his/her phone to complete the intake process.If no response is given, the intake will be saved as a non-completed task.
In the case when the 10 minutes elapse and the patient did not confirm his/her presence, the smart pillbox automatically emits sounds, lights, and displays messages on its screen.
If after the pill dispenser alerts the patient does not confirm his/her intake, the smart pillbox goes into a standby mode and saves the intake as a non-completed task.

Operating modes
The developed pill dispenser operates in two main modes: scheduling and filling mode, and assistance mode.

Scheduling and filling mode
The programming mode is strictly reserved for health professionals, in our scenario it is reserved for the pharmacist.After accessing his/her account on the mobile app through specific credentials, the pillbox switches automatically to the programming mode.The pill dispenser connects with the pharmacist's app on a local network.It shows directive messages on its screen in order to assist the pharmacist.Through a simple user interface, the pharmacist can easily manipulate the pill dispenser.
The mobile app shows at first the prescription for the pharmacist so that he/she can verify the availability of the medications before proceeding to the next step.Then, by a simple touch on the screen, the pill dispenser is unlocked.
The programming mode contains two modes: the filling part and the scheduling part.
When the pharmacist enters the filling mode, he/she can easily choose which compartment he/she wants to fill by entering its number on the interface shown on his/her phone.The prescribed doses of each medicine are taken into account while filling the pillbox.
When the filling mode is validated, the pharmacist accesses the scheduling mode where he/she plans the intakes timings.The pharmacist refers to the patient's preferences while scheduling the intakes.
To validate the process of filling and scheduling, the pharmacist is asked to confirm or cancel the new modifications.In the end, the pillbox locks up and switches automatically to the assistance mode.

Assistance mode
In the assistance mode, the pillbox is either in standby mode or in reminding mode.In standby mode, the pillbox screen is off to gain battery life and to not disturb the patient during his/her daily life activities.The smart dispenser remains connected to the internet.
When the right time of a pill comes, the screen turns on and starts displaying messages, a LED is turned on as well and a sound is emitted from the buzzer to draw the patient's attention.
The senior is asked to confirm his/her presence before unlocking the pill compartment.After confirmation, the senior is again asked to confirm his/her intake.Confirmations are done by a simple touch on the touch button implemented on the top of pillbox.
The connected pillbox sends feedback to the mobile application using WebSockets.The feedback represents the history of the patient's intakes.

System implementation
The system we propose is composed of two main parts, i.e., the hardware part which is the smart pill dispenser, and the software part which is the mobile application.Both parts are connected which offers an intuitive interface and ease of configuration for the system.

Software development
The software part of the system consists of a mobile application developed under Android Studio.The mobile application contains multiple accounts for the four main users.Each one of them has access to it through their private accounts using preregistered credentials.The functionalities that the mobile app offers differ from a user to another according to his/her role.To understand the different functions of the application, the following section details the different possible interacts between the pill dispenser and the mobile app and also between the users and the system.

Interaction between patient and mobile app
The patient interacts with the mobile app through a simple interface adapted for elderly individuals.The patient can read his/her updated prescription and can consult his/her scheduled intakes.Through his/her account, the patient may anytime ask for help by a simple click on the 'ASK for help' button.An important feature that our system offers is the possibility for the patient to check the history of his/her intakes.In case the elder forgets whether he/she took the pill or not, this feature turns out to be very helpful.

Interaction between doctor and mobile app
The mobile application offers the possibility for the doctor to directly write and edit the patient prescriptions remotely.In addition, the doctor is able to consult the history of the patient's intakes in real-time and also his/her pills schedule.

Interaction between relative and mobile app
One of the main purposes that smart pill dispensers were developed for is to reduce the burden of caregivers and relatives.With our mobile application, the caretaker is able to monitor the medication adherence of the elder while completing their regular daily life activities.Through a simple interface, the relative may consult the history of medication intakes, and also the scheduled intakes.

Interaction between pharmacist and mobile app
The mobile app on the pharmacist side provides him/her with the most interesting feature of our system.Through his/her specific credentials, the pharmacist is able to lock and unlock the pillbox, rotate the pills container, and also schedule the intake of the elder.The interfaces of the pharmacist account are all simple and intuitive.The mobile app on the pharmacist's phone connects locally with the pill dispenser.This offers more security for the filling and scheduling mode of the pillbox.

Hardware circuit and components
For the realization of the prototype, multiple components have been used.The overall used materials and their connection is shown in Figure 4.
The hardware of the proposed pill dispenser may be divided into assistance module, dispensing module, and communication module.

Assistance module
The Assistance module includes all the components responsible for the reminders: • A LED will light up when it is time to take the pills and keep blinking when the user confirms his/her presence.The LED turns off when the user confirms that he/she took his pill.• An LCD screen 20x4 shows preprogrammed messages for the user.The LCD screen displays messages such as: "Please confirm your presence" and "Please confirm your intake".For the energy economy, the used screen remains off unless the pill dispenser enters the programming mode or the assistance mode.• A buzzer is used to emit sounds whenever it is time to take the medicines.• A touch button helps the user interacts with the messages displayed on the LCD screen.When it is time to take his/her pills, the user unlocks the pillbox via a simple touch.

Dispensing module
The Dispensing module is responsible for controlling the dispensing mechanism and the assistance module.
A simple yet efficient safety mechanism is adopted for this prototype.To dispense the pills, multiple components have been utilized: • A servo motor is responsible for locking and unlocking the container.When it is time to take the pills and the user confirms his/her presence, the servo motor will turn up to 45 degrees to give access to the right pill storage.• A stepper motor and its driver are used to rotate the container.The stepper receives signals from the Arduino Uno.Those signals are the addresses of the different compartments.So, whenever an address is received, the stepper motor will rotate and stop at the compartment containing the prescheduled pill.• A container: a basic round plastic component divided into multiple compartments is used to store the pills.

Communication module
The Communication module is composed of one component which is ESP8266 NODEMCU.This is a development board capable of acting as a Wi-Fi module and a microcontroller as well.In this project, the ESP8266 is used to guarantee the connection to the Internet.This is important to synchronize data through all the users' applications and also to get the local hour from NTP server.In addition, it is used to send feedback from the pill dispenser to mobile applications such as the intake state.
The NODEMCU is also used to communicate with the Arduino UNO.It sends specific signals representing coded data.This data represents the compartment address of the container.

Control unit
The Arduino Uno is a microcontroller that has multiple inputs and outputs.It is considered as the control unit of this prototype as it is the component responsible for controlling the dispensing mechanism and the assistance module.

Results
The proposed system was tested with the help of seven individuals, three seniors aged between 64 and 67 years old, one caretaker (a relative of subject C), one doctor, and two pharmacists.All related details are shown in Table 1.
The pill dispenser and the mobile application were given to the three seniors one by one for 3 days long.In addition to the chronic conditions, the seniors have small to mild acoustic and visual deficits.
In the testing process, the pill dispenser was first loaded with the pills of each patient respecting the prescribed amounts and timings.The intakes timings were scheduled with the help of each of the testers according to the respective daily routines.The prototype given to the seniors was initially placed in their living room.The participants were free to move it around as they exercise their daily life activities.
The mobile application was installed on each of the users' phones, and specific credentials were given to them.At the end of the testing period, the users reported full contentment about the experience.They stated that the gradual assistance provided by the mobile application and the dispenser helped them take their medication without any disturbance.They were also enthusiastic about the different assistance acts that the system offers.
They also expressed their satisfaction with the ease of use of the device and the mobile app.In addition, the possibility for them to keep tabs on their intakes helped them in gaining confidence and relieving their stress.
As for the experience of the two pharmacists, they were given the pill dispenser and the mobile application for about 15 minutes each.They expressed right away their appreciation for the overall system.The filling and scheduling process was done efficiently and without any help from the developer.The fact that the pill dispenser can be manipulated only by a health professional was very appreciated by them.Hence, suggestions like increasing the number of compartments in the prototype and taking into account pills conditioning were given by one of subjects (E).To test our pill management system from a doctor's perspective, first the mobile application was installed on a doctor's phone.A specific username and password were then given to him.The doctor reported that he was able to easily fill and edit his patients' prescriptions without any confusion.No help was needed from the developers.He also stated that in some conditions like the recent Covid-19 pandemic, the possibility to edit his patients' prescriptions remotely is a very needed option.Small suggestions like enhancing the aesthetic aspect of the prototype and adding biosensors to monitor health conditions were given.
For the relative of subject C, the pill management system was appointed as lifesaving.The caretaker of patient C declared his full appreciation for the possibility to track her relative intakes remotely without moving on site.Also, the possibility for the elder to contact his caretaker directly via his mobile application was very admired.
Some of the app's screenshots of the mobile application are shown in Figure 5.The first screenshot represents the welcome interface of the mobile application.An error message is displayed at the bottom when a non-registered user attempts to access the application.The screenshot in the middle represents the interface of the pharmacist programming mode.The interface shows the prescription pre-registered by the doctor.The pharmacist can switch between the programming mode and the filling mode using the buttons at the top of the interface.Besides the name of each medication, two text fields represent respectively the number of the compartment of the medication and the scheduled timing of its intake.The buttons "edit" and "program" are used by the pharmacist to modify these data.The button "final view" at the bottom of this interface leads to the third screenshot.In this screenshot a general view of the prescribed medication is shown, each with the corresponding compartment number and the scheduled intake timing.Using the two buttons at the bottom of the interface the pharmacist has two options: go back and edit the entered information or confirm the settings and exit the application.

Discussion
The results of the initial experiments show that the use of the pill dispenser is an efficient solution for pills intakes reminding.The developed system differs from the existing pill management systems on multiple sides.The existing pill dispensers often ignore or miss to address important aspects such as: security, privacy, acoustic and eyesight deficits, and the safety of the elders.To design this system, multiple acts of assistance were provided to ensure the implementation of all the important aspects of this specific daily activity.Using visual and sound alerts, the system offers a maximum assistance.
While most of the existing systems use either mobile notification or pill dispenser's alarm for medication reminders, the proposed system combines both.It uses both techniques with gradation.This constitutes the unicity of the designed system.Offering assistance gradually helps the elders prepare themselves for their intake without causing any perturbance.From the obtained results providing gradual assistance also encourages the elders to take their medication and hence improves their medication adherence and their technology acceptance.
The initial findings are very encouraging.The results open mainly a discussion on how simple assistive technologies can also improve medication adherence, which is an important medical challenge.Further studies and tests for this approach will be conducted.

Conclusion and future scope
This paper focused on medication adherence issues in oldage individuals.A pill management system based on IoT has been presented.It is mainly made for the elderly suffering from mild cognitive deficits mainly related to age such as: memory deficits, initiation deficits and planning deficiencies.The significant advantage of this system is that it offers gradual assistance through both software application and hardware components.In addition, the visual and acoustic deficits related to age that most elderly suffer from are considered.Thus, multiple acts of assistance through mobile notifications, LED lighting as well as messages display and sound alarms are provided.In order to keep the seniors and the individuals living with them safe, the pill dispenser is equipped with a locking and unlocking mechanism.
The proposed system permits not only the elderly to have an independent and secure life, but also to reduce the burden of caregivers, family members and doctors since it allows them to supervise and monitor the elderly's intakes remotely.The proposed pill management system is programmed wirelessly only by the pharmacist using specific credentials.Furthermore, the user interface is developed to be intuitive and adapted for both literate and illiterate individuals.
As ongoing works, more tests and experiments will be conducted.The pill dispenser, as well as the mobile application will be given to more seniors of different ages, and backgrounds suffering from different diseases.More health professionals, as well as caregivers will also be invited to test the dispenser and its application.The remarks and suggestions given during the experimental phase will be taken into consideration to enhance the user experience.Furthermore, the duration of the experiments will be extended.
In addition, the system will be enhanced with additional features and more attention will be given to the pill dispenser's look, as well as the size and conditioning of the compartments.To enrich the elderly experience, a speaker could be added to provide vocal assistance.Another interesting extension for this system would be the addition of biosensors such as heartbeat sensors to offer health monitoring of the user.In the smart city context, the pill dispenser compartment could be equipped with sensors such as weight sensors or IR sensors, so that the pill dispenser would be able to order pills before running out from the patient.Furthermore, a database is about to be connected for the whole system to be fully operational.Also, a specific printed circuit board (PCB) could be designed to embed all of the components and make the prototype easy to carry.

Figure 1 :
Figure 1: Overall system actors and components.

Figure 2 :
Figure 2: Block diagram of the system.

Figure 3 :
Figure 3: Activity diagram of the proposed system.

Figure 4 :
Figure 4: Circuit of the prototype.