Smart Medication Dispenser with Arduino

This post describes a prototype of a smart medication dispenser, created with an Arduino as the controlling unit. The hardware platform and the software to support all the functionalities were created from scratch. Some of the functionalities include the possibility to connect the dispenser to a smartphone using HC-06 bluetooth module, or to communicate with a remote server through the internet, using ESP8266 Wi-Fi module.

Why creating a medication dispenser?

Nowadays, people take great amounts of medication, in order to have a better life quality. This is specially true amongst older people, who tend to have more complex medication regimens. With the increasing of age, people tend to have more difficulty in following those regimens, which can lead to  errors when taking medication, a problem that can cause serious health consequences.

The objective of this project was to create a prototype of a smart medication dispenser to help manage the treatments of older people. Besides that we wanted to have a solution that caregivers could easily use and that allowed them to remotely accompany the compliance to the treatment.

 

Some solutions in the market

Since the lack of compliance to medication regimens is a problem identified a long time ago, there are already some solutions available in the market. So, the aim of this project was not to reinvent the wheel but rather to develop an incremental solution that could mitigate some of the limitations found in those products, and also to add some innovative features.

So, we tried to develop a flexible and open solution, that could be used in multiple environments and integrated by other parties in their services.

 

Functionalities

  •  Possibility of defining 28 alarms for medication dispenses. For each alarm, it is possible to define the firing date and time, without limiting the number of alarms per day. Each alarm has a compartment associated in the physical structure of the dispenser, where the pills are stored for each dose.
  • Possibility of defining a maximum tolerance time for the user to retrieve the medication. After that time, if not dispensed, the dose is considered failed.
  • Possibility of configuring the alarms using a simplified mode (called daily mode) where the caregiver just needs to specify the firing time of the alarms for a day. The configured alarms will repeat every day, making it adequate for regular regimens.
  • Possibility of managing PRN medication (medication taken only when needed), by defining a minimum safety interval between doses.
  • Medication dispensing is done just by pressing a button.
  • Alarms are signaled by a flashing light and a beeping sound. The intensity and the “on/off” pattern of both visual and audio signals can be configured accordingly to the user’s preferences.
  • Recording pertinent information of operation, such as dispense time of medications or attempts of getting dispenses outside the configured time.
  • Bluetooth support, allowing communication with a smartphone, tablet or computer.
  • Wi-Fi support, allowing communication through the Internet. This allows the remote configuration of the dispenser and sending notifications to the caregiver.
  • GSM support, allowing the sending of remote notifications through SMS and the possibility to make voice calls to/from the dispenser.
  • Possibility of direct interaction with the dispenser, using its keypad and display, to configure it and to access registered information.
  • Creation of a generic API that simplifies the interaction of external devices with the dispenser, allowing its configuration and download of recorded information.

 

Architecture

In order to simplify the development process and to facilitate changes in the code, a modular architecture for the dispenser was developed, as shown in figure 1.

arq

Figure 1 – Dispenser’s architecture.

The processing module is the entity that controls all the others modules and was implemented using an Arduino Mega 2560 board. The choice of Arduino was related to the support given by its community, which offers a vast amount of libraries and tutorials, making the development much easier.

The information recording module was implemented using Arduino’s EEPROM. The Mega Board offers 4 KB of non-volatile memory, which was enough to support all the functionalities, such as storing the time when a medication compartment is dispensed.

The alarms are signaled using a LED and a buzzer and the user just has to press a button when an alarm fires in order for the pills of that dose to be dispensed.

The keypad and the display are used as a direct interface with the dispenser, where the caregiver can configure it or access registered information. Besides that, the display can be used to show a message to the user, associated with the alarms. For example, we can write a message such as “Take the pills with water”.

The mechanical actuation was implemented using a stepper motor, which is used to move a circular structure divided in the medication compartments, as shown in figure 2. This approach is used by many of the commercial solutions available.

The stepper motor used was a 28BYJ-48, which is a very cheap choice that operates at 5 V and has a precision of about 0.088º per step.

circular.png Figure 2 – Medication dispenser circular structure.

We decided to implement the feedback mechanism with an extrusion in the circular structure, which marks a reference compartment. This extrusion will be detected by an optocoupler (model ITR9608 from Everlight).

Since dispensing the medication at the correct time was a crucial requirement, we decided to use a DS3231 Real Time Clock, in order to complement the time-keeping algorithm used.
The remaining modules will be described below.

 

Bluetooth module

The bluetooth module was implemented using HC-06, a cheap serial-bluetooth bridge for microcontrollers. This device allows the emulation of a serial communication over bluetooth, which is used by the dispenser to communicate with devices such as computers, smartphones and tablets without using wires.

The goal of this interface was to allow the development of remote applications that could be used to guide the caregiver in the configuration and information retrieving processes, avoiding the need to use the keypad and the LCD display of the dispenser. Figure 3 shows a custom application that we developed for android, using an API we created over a serial protocol, which allows the configuration of the device.

1                 Figure 3 – Android application. Menus are in Portuguese.

 

Wi-Fi module

The possibility of connecting the dispenser to the internet was implemented using the ESP8266 module. This tiny and cheap device is a microcontroller that can connect to the internet using Wi-Fi. It can be used to develop standalone applications or as a serial to Wi-Fi bridge, which was the case.

Once connected to a router, the ESP8266 can establish or receive socket connections, allowing it to easily change data with a remote server/client. Although HTTP communication can be implement on top of the socket interface, we opted to implement a byte oriented protocol, to decrease the overhead. This communication is supported through a Python API we developed.

Through this interface, we allow the dispenser to send remote event notifications to a server, which then can be sent to the caregiver. Besides that, we allow the caregiver to remotely configure the dispenser.

Figure 4 illustrates an architecture that allows the dispenser to communicate over the internet.

wifi

Figure 4 – Architecture that illustrates the exchange of data through the internet.

GSM module

The GSM module was implemented using the SIM900 device. It can receive AT commands though its serial port, allowing for a microcontroller to control it. Those commands include sending SMS and making/receiving phone calls.

So, the SIM900 is used by the dispenser to send textual messages to the caregiver, informing him of events that occur during the operation, such as doses taken or missed. Besides that, since the SIM900 is a relatively expensive device, we decided to allow the dispenser to receive and make phone calls. Using this interface, the caregiver can call the user to check if everything is alright, which is a pertinent functionality if the user is not able to use a phone. The user can also start a call, which is important in case of an emergency.

In order to answer or start a call, the user just needs to press a button, which is a fairly simple interface.

 

The result

The mechanical structure of the final prototype was impressed using a 3D printer, as shown in figure 5.

aa.png

Figure 5 – 3D structure of the prototype. Menus are in Portuguese.

The final circuit of the dispenser is shown in figure 6, and the power supply circuitry, which supports battery and power grid supply, is shown in figure 7.

Picture12.png

Figure 6 – Dispenser’s main circuit.

supply

Figure 7 – Dispenser’s power supply circuit.

This video shows the Android app controlling the circular structure that has the medication:

This video shows the process of turning on/off the LCD or just its back light, to save energy:

There are more videos on my youtube channel.

Special thanks to:
My coordinator, professor Renato Nunes, for helping me through the whole project;
My friend Pedro Marques, for designing the 3D structure of the dispenser;
Glintt Engineering, for offering me the 3D printings.

Advertisements
This entry was posted in Microcontrollers and tagged , , , , , . Bookmark the permalink.

10 Responses to Smart Medication Dispenser with Arduino

  1. wb8nbs says:

    If you want to make money from this, make it big enough to dispense cat food.

    Liked by 1 person

    • antepher says:

      It’s a very good idea, it would be very useful for people who are not at home the whole day or can’t take their pets when they go on vacation!
      The problem is the price of the physical structure, creating the molds would need some serious investment.

      Like

  2. topsl says:

    You are right, turning the prototype into a product is a big step and requires appropriate funding. This does sound like a very good idea though, with a range of practical applications. I think it would be worth speaking to someone knowledgeable about the process.

    Liked by 1 person

    • antepher says:

      That’s true, it would need a big investment in molds and in testing, since it deals with medication.

      Nevertheless, the electronics of this project costed about 60 euros, from which 20 euros are the price of the GSM module, which is not mandatory.
      Besides that, all of the components were bought in small quantities and I couldn’t use SMD components due to the lack of proper soldering tools.
      I think it’s a reasonable price for a prototype and taking into account the cost of other products in the market.

      If someone with knowledge about the process could give his opinion, I would appreciate 🙂

      Like

  3. Pingback: Arduino Bluetooth with HC-06 | techtutorialsx

  4. Pingback: Real Time Clock: DS3231 | techtutorialsx

  5. Pingback: ESP8266: Reading temperature with the DS3231 RTC | techtutorialsx

  6. Pingback: Buying cheap electronics at Ebay: Part 2 | techtutorialsx

  7. Pingback: ESP8266: DFRobot WiFi Bee board | techtutorialsx

  8. Pingback: ESP8266: DFRobot WiFi Bee board – ToberWell

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s