Medication management is a critical part of healthcare, yet studies reveal that 50% of patients with chronic illnesses fail to take their medications as prescribed. This non-adherence leads to serious consequences, including 125, 000 deaths annually, 10% of hospitalizations, and over $100 billion in preventable healthcare costs.
Traditional methods, like manual pill organizers, often fall short. They rely on memory, offer no reminders, and lack any form of monitoring. For individuals with complex medication schedules—such as morning, afternoon, and evening doses—keeping track of everything can be overwhelming. Missed medications not only disrupt treatment but can also exacerbate health issues, putting lives at risk.
This is where the Smart Pill Dispenser steps in. By automating the process and sending real-time notifications via a web app, it ensures that users take the right pills at the right time. Designed to address the shortcomings of ordinary medication methods, it’s a step towards better healthcare management and peace of mind.
How Does The System Work?The pill dispenser system operates based on user interaction and scheduled timing. It starts by parsing a JSON input from firebase containing the pill schedule, which updates the state of each container with details like pill names, quantities, and scheduled times.
The system continuously tracks the current time and checks if a user presses the button. When the button is pressed, the system verifies whether the current time falls within the grace window of a scheduled dispensing time. If the current time is within this window and the pills have not already been dispensed, the system sends a command to the motor driver to activate the appropriate stepper motor, releasing the pills. It then updates the timestamp to reflect the last dispensing action. If the current time is outside the grace window, the system refrains from dispensing.
Notifications are managed separately, reminding users when it's time to take their pills according to the schedule. This design ensures that pills are dispensed only upon user confirmation and within the prescribed time frame, maintaining flexibility and accuracy.
The Particle Photon 2 serves as the central microcontroller that powers the Smart Pill Dispenser. It controls the dispensing mechanism, handles communication with the web app, and manages the timing and scheduling of pill dispensing. Additionally, it is a powerful yet lightweight device, ideal for real-time applications. It supports both 2.4 GHz and 5 GHz Wi-Fi for reliable connectivity, and its Realtek RTL8721DM processor with an ARM Cortex M33 CPU running at 200 MHz ensures the processing power necessary for high-speed, complex tasks. Its compact form factor and IoT compatibility make it perfect for integration into these devices.
Setting up thePhoton:Open your browser and navigate to setup.particle.io to begin configuring your Photon device. The setup wizard will guide you through the process of linking the device to your Particle account.
- Ensure the Photon is connected and powered on before proceeding.
- When the Photon is detected, it will appear as “P2” in the setup interface. Select this option to continue.
- The Photon will automatically enter DFU mode (Device Firmware Update mode), indicated by a blinking yellow LED.
- Once in DFU mode, the setup wizard will flash the necessary firmware to the Photon, preparing it for operation.
- You can either create a new product or assign the Photon to an existing one in your Particle account.
- Give your Photon a unique name for easy identification in your account.
- The next step is to configure the Wi-Fi settings by entering your network credentials, so the Photon can connect to the internet.
The Particle board can be programmed using either the Particle Web IDE or the Particle Workbench. For this project, we chose the Particle Workbench for its flexibility and advanced features. Setting it up is simple—all you need is Visual Studio Code. You can follow the step-by-step guide provided in the Particle Workbench Quickstart.
When developing the Smart Pill Dispenser, the primary challenge was designing a reliable and efficient pill dispensing mechanism. Initially, creating a unique design from scratch was considered. However, due to the time and complexity involved, an alternative approach was taken: exploring existing designs for inspiration and adaptation.
Through research, a mechanism by Makers UPV on Hackster was identified. This design utilized a 28BYJ stepper motor, valued for its precision and reliability in movement control. The mechanism consisted of two main parts: the pill storage compartment and the rotor part. The rotor part is customizable and needs to be adjusted based on the specific type of pill being dispensed.
The stepper motor in the mechanism is controlled using a ULN2003 motor driver, ensuring smooth and accurate operation. The 28BYJ-48 motor typically consumes 200 mA per coil, and the ULN2003 can handle up to 500 mA per channel, so it easily meets the current requirements.
To implement the design, the mechanism components were 3D printed, and the system was tested by connecting the stepper motor to the Particle Photon 2 microcontroller.
The 2-inch Waveshare LCD display plays a key role in the project by providing vital information to the user. It displays the current time, along with feedback confirming that the pill is being dispensed and showing the pill's name.
This display operates at 3.3V/5V, utilizing the SPI interface for communication. With IPS technology it ensures vibrant colors and wide viewing angles. Driven by the ST7789V, it boasts a resolution of 240 (V) x 320 (H) RGB and a display area of 30.60 (H) x 40.80 (V) mm.
Here's a breakdown of its key pins:
- VCC: Supplies power to the display. It supports both 3.3V and 5V.
- GND: The ground connection for the display.
- DIN: Data Input Pin (MOSI - Master Out Slave In). Used for transferring data from the microcontroller to the display via SPI.
- CLK: Clock Pin (SCK). Synchronizes the data transfer during SPI communication.
- DC: Data/Command Control Pin. Determines whether the incoming data is command (low) or pixel data (high).
- CS: Chip Select Pin. Enables communication with the display when pulled low.
- RST: Reset Pin. Resets the display module when pulled low, initializing it for operation.
- BL: Backlight Pin. Controls the display's backlight. It can be connected to a PWM pin for adjustable brightness.
To enhance usability and aesthetics, we opted for a momentary metal push button switch instead of a standard push button. This switch offers clear visual feedback through its built-in LED. It features four output pins—two dedicated to the LED and two for the signals.
We began by testing the entire system using a breadboard, ensuring that all components worked as expected. The system was powered by a 5V 2A power supply, which provided adequate power for all components. This power supply was sufficient because only one stepper motor and the display operate simultaneously.
Here is the approximate power consumption for each component:
- 28BYJ-48 Stepper Motor: Consumes 1 Watt (5V, 200 mA).
- 2-Inch Waveshare Display: Consumes 0.2 Watts (5V, 40 mA).
- Particle Photon 2: Consumes up to 0.9 Watts (5V, 180 mA).
The total estimated power consumption is about 2.1 Watts, well within the 10 Watt capacity of the 5V 2A power supply, providing a safe margin for stable operation.
The Particle Photon 2 offers various powering options, including the micro-USB port, VUSB pin, and LiPo battery. For this project, we opted for the VUSB method, providing a stable 5V input directly to the board.
Once the circuit was verified to be functional, we finalized the design and proceeded to create the PCB layout, optimizing it for a compact and efficient arrangement of components.
For the PCB design of the Smart Pill Dispenser, we used EasyEDA software. The design consists of a two-layer PCB, which provides a compact and efficient layout. EasyEDA's intuitive interface allowed us to quickly design and test the circuit, ensuring all components were placed effectively while maintaining optimal signal routing and power distribution.
After finalizing the circuit in EasyEDA, you can use PCBWay’s instant quote feature to get our boards fabricated. By simply uploading the Gerber files, you were able to quickly place an order and receive high-quality PCBs with a professional finish
So these are the fabricated PCB'S.
The display and button are connected to the PCB using JST connectors, while the motor driver is directly mounted onto the PCB for a compact and efficient layout. Additionally, a two-pin screw terminal block is included for securely attaching the power supply.
DesignWith all components finalized, we moved on to the design phase in Fusion 360—which unifies CAD, simulation, and CAM in a single cloud‑based workspace, letting us iterate and refine the model with speed and precision.
The structure was divided into two main sections: the upper part, housing the dispensing mechanism, and the bottom part, which holds the PCB with all connected components.
We chose a green‑and‑white color theme to give the dispenser a clean, modern look, then 3D‑printed the enclosure in durable PLA+ filament.
The assembly process began with attaching the momentary button and the display to the upper portion of the dispenser's body.
Next, we prepared each pill dispensing mechanism by connecting the stepper motors securely to them. Then these three dispensers were mounted onto the supporter using M3 screws to ensure stability.
We then attached the pill guide, which directs the dispensed pills along a predefined path to the cup positioned below.
With the mechanical setup complete, we prepared the PCB by soldering the necessary headers, JST connectors, and a screw terminal block, ensuring all components were ready for final integration.
After preparing the PCB, we connected all components to it.
Next, the PCB was secured to the bottom portion, and the upper and lower sections were stacked together, completing the 70 percent assembly of the device. For powering the device, a DC female jack was used.
The pill dispensing mechanism was then secured to the top section, and the remaining stepper motor connections were connected to the PCB.
Here is the final result after assembling the top and bottom cover together. We also 3D printed a cup to collect the dispensed pills.
Now, let’s power up the pill dispenser and see it in action!
Firebase is an integral part of the pill dispenser system, providing reliable back-end services that simplify the development and ensure seamless communication between the web application and the hardware device. Its real-time capabilities and robust features make it an ideal choice for managing and synchronizing schedules, notifications, and user data.
Web AppThe web application acts as an interface for users to configure and manage the pill dispenser system remotely. It provides a seamless and user-friendly platform to set up pill schedules, monitor dispenser activity, and receive notifications. Below are the key features and details of the web application:
1.Pill Scheduling:
- Allows users to create and manage pill schedules with the following inputs:1. Time of dispensing.2. Medication name and dosage.
- Automatically syncs these schedules with the pill dispenser device.
2.Upcoming Schedule Viewer:
- Provides a dedicated section for users to view their next scheduled doses at a glance.
- Lists upcoming doses for the day, ensuring users are prepared.
3.Notifications:
- A Node.js API sends timely reminders to the user for their medication.
- Notifications include details of the medication name, dosage, and scheduled time.
- Alerts are sent via web push notifications.
The Smart Pill Dispenser addresses one of the most pressing challenges in modern healthcare—medication non-adherence—by combining automation, connectivity, and thoughtful design. With 50% of chronic patients struggling to take their medications as prescribed, and the resulting consequences costing lives and billions of dollars, this system offers a tangible and user-centric solution.
From real-time scheduling and notification management via Firebase to precise dispensing powered by stepper motors and the Particle Photon 2, every component has been carefully selected and integrated to ensure reliability and ease of use. The addition of a web app makes the system accessible and configurable from anywhere, bridging the gap between patients and their prescriptions. Furthermore, the modular design and compact PCB layout contribute to a clean and efficient final product that is both functional and aesthetically appealing.
Ultimately, this project demonstrates how embedded systems, IoT, and thoughtful engineering can come together to solve real-world problems. The Smart Pill Dispenser is not just a device—it’s a step toward empowering individuals to take control of their health and improving outcomes through technology.
Comments