Automatic Medicine Dispenser using IoT

Download Full-Text PDF Cite this Publication

Text Only Version

Automatic Medicine Dispenser using IoT

Jyothis Philip[1], Feba Mary Abraham[2], Ken Kurian Giboy[3], B J Feslina[4] and Teena Rajan[5]

Department of Electronics and Communication Engineering, Mar Baselios College of Engineering and Technology, Trivandrum

AbstractThere are several challenges that old people face, and of them is taking their medicines on time. Old people usually forget to take their medication on time and also have a hard time recollecting whether they had their medication, which sometimes could lead to overdose and severe medical complications. There are several expensive medicine dispensers available in the market now. However, most of the elderly people around the world dont even know of such products and still resort to storing the medicines in a box. Several types of medicine dispensers are available commercially worldwide. However, they have several drawbacks that requires to be resolved. These drawbacks can be resolved using a Automatic Medicine Dispenser that is reliable,

affordable and can carry up to 2-3 weeks of medicines, in such a way that, old people wont need to depend on someone else. The

product is designed to make sure that the quantity and timing of the pills to be dispensed can be controlled and monitored using an app, which makes things easier for everyone, including for

children who work abroad. Also, it offers clear c ontact bet ween

the consume r andpar ental f igures as it w ill immediately notify the guardian in case the patient has missed pill intake. Furthermore,

SMD provides the customer with a touchscreen that can be accessed as an application on their cell phone, enabling them to

monitor and control the timetables and use information remo tely.

Index Terms Pill, liquid medicine, medicine dispenser app


    Studies show that many people irrespective of age become forgetful when it comes to consuming medicines. This, seen mostly in the elderly, leads to many other life risks.

    This is where medicine dispensers come into play. There are different types of dispensers all of which are just implemented using solid medicines. Most of them are jut simple with no reminders etc. This paper proposes a dispenser that can dispense both solid and liquid medicine, has an app integrated with it and helps to set alarms.

    One of the biggest problems in the health care industry is medication adherence. Often elderly people fail to take their medication on time and for elders with more than one medication, the chances of overdosing are considerably high. This could easily lead to catastrophic events such as permanent disability or even death. Hence, it is evident that it is a widespread problem and needs a solution. It was revealed that, in a study conducted at the University of Washington, 30.7 percent of participants disliked and 18.3 percent liked at least one drug.



    Fig. 1.1: Medicine Storage methods

    Pill makers created special bundling so as to recognize their item from those of their rivals and fabricate brand unwaveringness. Bundling configuration regularly fused a "memory help" to help ladies in following their every day pill routine, just as styled cases to enable pills to be carefully conveyed in packs and handbags. A medicine dispenser is a device which at a predetermined time dispenses the required or the already set medication to the patient. It has proved its efficiency in improving medication adherence.

    The paper aims at designing a dispenser which is non-invasive in nature and which is cost effective. In the Automatic Medicine Dispenser (AMD), when it is time to take the medicine, the device can either be designed to release the pre- measured dose into a small compartment which can be easily opened, or can manually be sorted into small compartment by the patients caretaker upon which the patient is notified when it is time. The patient is notified usually through a loud alarm signal. If the patient doesnt take the medication out of the dispenser within a specified time, it would send out more loud signals to catch the attention of the patient.


    1. Overall technology

      Fig. 2.1: Basic block diagram of AMD

      Fig.2.1 shows the basic building blocks of the AMD. The information entered into the AMD app, Medcare, is sent to be stored in the arduino via an Iot gateway namely firebase.

      This is done by connecting the arduino to the network via nodeMCU. When the time for a particular medicine to be dispensed comes, the arduino sends the signal to the respective component to dispense the respective medicine.

    2. Arduino technology

      An Arduino board is a kit based on a one form microcontroller. The Harvard architecture is used for the software construction of the arduino where the program code and data are provided with separate memory. These are thetwo memories found in an Arduino. The data memory has the data stored in it and the flash memory has the code. Arduino technology has the advantage of directly uploading the program without using a hardware programmer. This is seen to be used in many controlling or communication devices. Arduino is an open source electronics platform.

    3. Firebase

    It is nothing but a set of tools that are used to create, develop and evolve your application. It takes care of a large portion of those processes and services that programmers would often create on their own, but wouldn't want to, because they often like to focus on the application. The cloud hosts the processes and services like databases, authentication etc. The client SDKs provided by Firebase communicate directly with these backend services, without the need for establishing any middleware between the service and your application

    You will only need to write code to query the information from your client's application database while using one of the Firebase database option. This is a stark change from the usually tried and tested app development methods which usually includes writing both the backend and frontend software. The frontend code invites API endpoints which the backend presents, and the job is done by the backend codes. However, with Firebase, the usual backend goes through, putting the work into the client. Firebase Authentication deals with getting your clients signed in and recognized. This product is fundamental to getting configuration done properly, particularly in the event that you have to limit access to per- client data (which is what each application would want to do). The special thing about Firebase Authentication is that it makes it simple to perform secure logins, which is amazingly hard to execute effectively all alone. Firebase Realtime Database and Cloud Firestore gives database services. Firebase brings in SDKs to use in your application to make direct data easily accessable, expelling the requirement for that annoying middleware segment.

    What's extremely unique about these databases is that they give you "realtime" updates to information as it changes in the database. You utilize the customer SDK to set up a "listener" at the location of the information your application needs to utilize, and the "listener: gets summoned with that information more than once, every time a change is noticed. This lets you keep your application's presentation new and updated, without surveying the information of intrigue.


    1. Internet of Things (IoT) Technology

      The Internet of Things (IoT) is the network of devices suchas automobiles and home appliances containing electronics, software, actuators, and connectivity that enable these things to interact, communicate, and exchange information via the internet. They have unique identifiers (UIDs) and can transfer any amount of data across the network.

      The IoT eosystem is composed of web-enabled smart devices, using senors and processors to collect or send data from their environments. The data is send or received by connecting to the IoT gateway and is analyzed in the cloud. All these devices does most of the work independently, without human intervention other than for setting up.

      Fig. 2.2: IoT Architecture

      The IoT includes expanding Internet connectivity to any spectrum of traditionally stupid or non-internet-enabled physical devices and everyday items beyond conventional devices, such as desktops, laptops, smartphones and tablets. These devices, integrated with technology can communicate and interact over the Internet and can be monitored and controlled remotely. An IoT ecosystem involves web-enabled smart devices that use integrated processors, sensors and communication equipment to collect, send and act on the information they obtain from their settings. These systems link to an IoT gateway that sends information to the cloud or to a local place and shares these information with other devices. The Internet of Things (IoT) is basically connecting the physical things with the internet and identifying other devices.

      The fact that an object that an represent itself digitally becomes higher than the object itself makes IoT an important pathway. The object no longer relates solely to its customer but is now linked to adjacent objects and information from the database. If we had pcs that knew everything about activitiesusing information that they collected by itself, it would be possible to keep a tab on and count and most important decrease the wastes, losses and costs. It will easy to understand when to upgrade, fix or recall items and whether they're new or past their peak. Many people agree that there are links between computers , tablets

      and mobile phones. IoT portrays a world where you can communicate smartly and link just about everything. Often, these devices communicate with other similar machines and act on data from each other. The systems do much of the work without human intervention, except for setting them up, commanding them or giving them access to information for which individuals communicate with the systems. A complete IoT framework incorporates four particular segments: sensors/gadgets, connectivity, information processing, and an UI.

      • First of all, sensors or gadgets gather information from its environment. This can be as subtle as measuring the temperature, or as complex as a comprehensive video feed.

      • Next, through a pathway this information is passed onto the cloud onto which the sensors are connected to. This connection is established through many ways including Bluetooth, cellular connectivity, satellite, low-power wide-area networks (LPWAN), WiFi, or connection via the Ethernet. All of these methods have different characteristics, ie. varying power consumption, range and bandwidth. Choosing which connection is the most viable comes down to the particular IoT application with them all having the same objective of passing the information to the cloud.

      • Once this data gets to the cloud, the software performs functions that processes the information received. This could be anything simple like checking if the received value is same as the one required or if it is within an acceptable range or anything complex like using video feed to capture or identify the required target.

      • Finally, in some way, the data is represented to the user like through a user alert (text, notification, e-mail, etc.).

    The Internet of Medical Things (IoMT) is the use of IoT for research and observation purposes related to restorative and healthcare purposes, information assessment and examination. "Smart Healthcare", what IoMT was billed as, is for making healthcare services digitized interfacing accessible therapeutic assets and medicinal services administrations.

    IoT gadgets can be used efficiently to empower remote healthcare checking and emergency notifying systems. These healthcare gadgets can range from blood pressure and heart rate monitors to advanced systems capable of monitoring implants, such as pacemakers, hearing aids or even electronic wristbands. A few of the hospitals have started implementing smartbeds, those that are capable of detecting the presence of a patient and also when he/she wishes to get up. It can also modify itself to support the patient and to provide him pressure when medical attendants are not around. The fact that the U.S can spare more than $300 billion in human services consumptions yearly by expanding revenue and diminishing cost was shown in the Goldman Sachs report of 2015."Moreover, the utilization of cell phones to help therapeutic follow-up prompted the formation of 'm-health', utilized "to analyze, transfer and store health statistics from various assets, including sensors and biomedical acquisition frameworks".


    1. Servo Motor

      An electrical rotary actuator which has the ability to precisely push an object by controlling the angular position and velocity defines a servo motor. It pairs the functions of a regular motor with a senor for position feedback. The motor runs through servo mechanism. It is made up three parts namely an output sensor, a controlled device and a feedback system. The feedback system is a closed loop that can control the shaft's movement and final position using a positive feedback. PWM signals that are generated from the control wires control the servo motor. It has a maximum and minimum pulse and its length determines how much the motor will turn. From its initial position, it can rotate 90 degrees towards any of the two directions. The angle of rotation of the servo depends on the length of the pulse of the Control PIN which is a significance of pulse width modulation principle . In short, it can deduced that it is made up of a DC motor which is controlled by several gears and a potentiometer.

      Fig. 4.1: Servo Motor SG-90

      Table 4.1: Technical Specifications of Servo Motor

    2. Centrifugal Pump

      The centrifugal pump is a relatively cheap submersible pump motor of limited size that can be powered from a 2.5~6V power supply. With very low current consumption of 220ma it may take up to 120 liters per hour.

      Fig. 4.2: Mini Submersible Pump

      Table 4.2: Technical Specifications of Mini Submersible Pump

    3. Arduino Uno

      It is based on Microchip ATmega328P and also an open source microcontroller board. It is developed by Arduino Uno consists of various set of digital and analog I/O ports which can be interfaced into various shields and other circuits. Arduino Uno comprises of various components such as crystal oscillator, voltage regulator and serial communication. It has 14 digital and 6 analog pins. 6 pins of the 14 digital I/O pins in the board are capable of PWM output. The 6 analog pins can be programmed with Arduino IDE (Integrated Development Environment) using Type B USB cable. The USB cable can power the Arduino Uno or an external voltage of 9 volts can be used to power the device. The hardware versions of some Arduino Uno are available on the Arduino website. All the pins can be used for the I/0 communications with the help of the software control (using pinMode(), digitalWrite(), and digitalRead() functions). All of them operates at a voltage of 5 volts. The 6 analog inputs is able to provides 1024 different values because of its 10 bit resolution.

      Fig. 4.3: Arduino Uno

    4. Real Time Clock Module

    A Real Time Clock provides precise or instantaneous time and date which can be used as a reference in various applications.It is an electronic device in the form of an integrated chip which is powered by a lithium battery. Therefore even during power of the system is off, the RTC keeps running. It is the main component in real time systems like attendance systems, digital camera, digital clock etc and also in applications where time stamp is needed. The design of such systems where time is a factor, either time is generated internally by programming timers o the controllers or an RTC is used. RTC module contains a 32.768 kHz XTAL combined with a CMOS based oscillator and an RTC IC, all embedded inside a miniature surface mount device ceramic package.

    Fig. 4.4: DS3231 Precision RTC Module Table 4.3: Technical Specifications of RTC


    • It counts seconds, minutes, hours and year

    • Has a digital temperature sensor with ±3°C accuracy

    • Has two time-of-day alarms

    • Has programmable square wave output

    • Low power consumption

    • Has a CR2032 battery backup with two to three year life.

      A. System design


    1. NodeMCU

      The name Node MCU is combination of the two words node and MCU which is short term for Microcontroller unit. The firmware and the prototyping design suites are both open source platforms. A Node MCU is a very low cost platform form for IoT. The hardware is based on the ESP 12 module. It is a single board microcontroller with an operating system of XTOS. The CPU of the microcontroller is the ESP8266. The Lua scripting language is used by the firmware. The Node MCU supports 32-bit ESP module. Node MCU has a WiFi integrated board, the ESP8266, and therefore the Node MCU finds its use widely in the IoT fields. Fig.7 shows the image of NodeMCU with integrated ESP8266.

      Fig. 4.4: NodeMCU with integrated ESP8266

      Table 4.4: Technical Specifications of NodeMCU

      Fig. 5.1: Detailed block diagram with the components used in the AMD

      Fig.8 shows the detailed block diagram with the components used in AMD. The main components used are a servo motor, a centrifugal pump, an arduino UNO, a nodemcu and a real time clock module (RTC). The information the user adds into the app is sent to the arduino simultaneously through the nodemcu via firebase. Instantaneous time and date is calculated by the RTC connected to the arduino. The moment they becomes equal to the ones entered by the user, the arduino commands either the servo, in the case of pills, or the centrifugal pump, in the case of liquid, to dispense the medication.

      1. Hardware Integration and Working

        The whole system is encased within a rigid outer structure that prevents any sort of damage that might hinder the performance of the system. The user has to install the MedCare application in their respective mobile devices. Upon installation the user is required to register first. For every user registration, a new database is created within the Firebase servers. Upon registration, the user will only be required to login from there on. The user can select the type of pill or liquid that has to be dispensed. The option of selecting the quantity of liquid medicine to be dispensed is also provided upfront.

        The user can then select the time and date at which the medicine has to be dispensed. When the user clicks the 'Ok' button, a 14 digit string value is created according to the selected date, time and type of medication. For example, a selection of Paracetamol,11:30am, 20 June, 2020 will generate '20200620113001'. The corresponding string value is sent from the app to the Firebase server where it is stored in the respective user's database. This value is then send to the Arduino via the nodemcu and the values are stored in an array.

        The first 12 digits of all the string values in the array are constantly compared to the output time values from the RTC module and only when any one of it is equal, the last two digits of that particular string value are checked to accurately dispense the required medicine at the exact time required. Based on the value of the last two digits, a signal from the Arduino is given to the servo motor to dispense the pill or to the centrifugal pump to pump out the required amount of liquid medicine. The servo motor is programmed such that only one

        pill falls at a time. Also, the pump will be activated by the Arduino only for an adequate amount of time depending on the quantity of liquid to be dispensed. Once the dispensation is completed, a buzzer is activated to alert the consumer to take the medicine on time. An ultrasonic sensor can be used to detect the presence of the pill or liquid and hence can be used to notify the caretaker that the patient has missed the medication. This notification can be sent when the sensor detects the presence of the medicine after a predetermined interval of time. A floating power supply may be used to prevent any power surges that can malfunction the Arduino or other components.

        Figure 5.2: Complete Circuit Diagram

      2. AMD Mobile Application

    Fig. 5.3: Mobile app showing the string value

    The AMD app is designed on the Android studio. The app is made to connect to the arduino via firebase which allows us to send or receive data to and from the internet without human intervention.

    The app contains four widgets:

    • A spinner used as a drop down to select the medication.

    • A CalenderView to select the date and year.

    • A TimePicker to the select the time in a 24hr format.

    • An Update button to generate the string.

    Fig. 5.4: Mobile app showing the date and time selection page


    The result of the automatic medicine dispenser is the accurate and automatic dispensation of pills and fluid medicines according to as set by the user. For accurate dispensation of fluid medicines, the pump had to be calibrated using trial and error to find out how long the pump should work to pump out different quantities of liquid medicine. A study was done on water based and as well as with syrup based liquid medicines. The tables below provides the collected data.

    For water based liquid medicines:

    Table 6.1: Results from study on water based liquid medicines

    For syrup based liquid medicines:

    Table 6.2: Results from study on syrup based liquid medicines

    The tabular data shows that the centrifugal pump will pump out exactly 2ml of a syrup based liquid medicine in 7.25 seconds and so on. This data is crucial in determining how long the pump must be switched on using the Arduino.

    Furthermore, the main objective of the project is to ensure that the device knows what to dispense and when to do it, in accurate amounts. Proper communication of data is needed to fulfil this requirement. Figure 5.2 shows the string value generated whenever the user selects a medicine to be dispensed at whatever date and time. This data needs to be stored within the Arduino to ensure proper dispensation of medicines. Figure below shows the Firebase database being updated in real-time when a new string is generated.

    Fig 6.1: The Firebase Database page

    This data is fetched by the Nodemcu and is send to the Arduino via serial communication. The Figures below shows the Arduino IDE result after the Nodemcu program is run.

    Fig 6.2: Output from NodeMCU

    The following figures shows the Arduino IDE result once the Arduino Uno program is run. The output from RTC is displayed as well as the data from the nodemcu is stored and compared to the RTC value simultaneously. When equal, the appropriate action is taken. Results for both pill dispensation and liquid medicine dispensation are show below.

    Fig 6.3: Output from RTC

    The first two displayed values are from the RTC and the third displayed value is the one set by the user.

    Fig 6.4: Pill Dispensation Results

    Fig 6.5: Fluid Medicine Dispensation


With the use f the SMD, the medication adherence will definitely improve, especially in elderly patients and patients with chronic and period medicine, which in turn will ensure better treatment effectiveness. Insurance companies will definitely benefit from the SMD as it will be instrumental in their customers living a healthier and better lifestyle away from the catastrophic accidents caused by missing their medicine or the right dosage. Finally, the users interface which is the same on all operating systems and devices is clear, user-friendly, intuitive and easy to use, even for the elderly patients. The design is flexible and also gives the user, the liberty to add more containers and is also open to further enhancements in the future..


  1. Wissam Antoun, Ali Abdo, Suleiman Al-Yaman, Abdallah Kassem, Mustapha Hamad and Chady El-Moucary, Smart Medicine Dispenser (SMD), 2018 IEEE 4th Middle East Conference on Biomedical Engineering (MECBME), pp. 20-23, 2018

  2. A. V. Dhukaram and C. Baber, "Elderly Cardiac Patients' Medication Management: Patient Day-to-Day Needs and Review of Medication Management System," 2013 IEEE International Conference on Healthcare Informatics, pp. 107-114, 2013

  3. World Health Organiztion, , accessed on Juy 21, 2017.

  4. S. L. Gray, J. E.Mahoney, and D. K.Blough, Medication Adherence in Elderly Patients Receiving Home Health Services following Hospital Discharge. Annals of Pharmacotherapy, 35(5), pp. 539-545, 2001.

  5. How does IoT work?- explanation of IoT Architecture & layers

  6. SQLite_fig1_2 71891972 [

  7. C. Frcaú, I. Ciocan, N. Palaghi and R. Fizeúan, "Weekly electronic pills dispenser with circular containers," 2015 IEEE 21st International Symposium for Design and Technology in Electronic Packaging (SIITME), pp. 125-129, 2015.

  8. N. B. Othman and O. P. Ek, "Pill dispenser with alarm via smart phone notification," 2016 IEEE 5th Global Conference on Consumer Electronics, pp. 1-2, 2016.

  9. 6-alar ms

Leave a Reply

Your email address will not be published. Required fields are marked *