Smart Desktop Medicine Organizer

A coffee machine sized box that automatically organizes your medications and connects your medicine use directly to your doctor/pharmacy.

Similar projects worth following
The main goal of this project is to make managing medications easier and safer than ever before. This is essentially a medication vending machine on steroids (pun intended). The machine has the capability to easily store single pills and dispense them when required. There have been many projects that simply dispense pills after a timer etc. This project is so much more. Here are some of the key features:

Automatic pill organization - Each pill is stored individually and can be independently accessed automatically.

Wifi / Cloud connected - The machine, it's inventory, and its use statistics can be connected to a doctor or pharmacy so care-givers can monitor their patients use of medication.

Smart Medication Control - By being connected to the cloud the machine can check if medications are safe to be used together and warn patients. It can also prevent over doses by limiting the frequency of dispenses.

The machine is powered by a Raspberry Pi and 3D printed Mechanics.

Project Introduction

This project is my solution to the problem of medication non-compliance. Medication non-compliance basically refers to when a drug is not taken properly. This could be because someone forgets to take an important medication, someone takes too much of a medication, or someone takes two or more dedications that should not be taken together. This problem ended up costing Americans over $300 Billion last year in totally avoidable medical bills and ER visits. Among the aging population 30% of all early deaths were from this problem.

My project tries to solve this problem my making it easily to manage medications and prevent medication non-compliance. This is done by storing all your medications in a machine that can dispense individual pill on-demand. By allowing the machine to store the pills:

  • You don't have to worry about mis-reading a pill bottle label and consuming the wrong medication.
  • You are always reminded to take the correct medication at the correct time.
  • The machine knows what medications you are taking and can make sure they don't conflict.

This project takes this concept much further by adding WiFi and allowing it to connect to the cloud. This enables the following functionality:

  • Connecting to pharmacy APIs to get prescription information. Big pharmacies like Walgreens and CVS have APIs where you can get a prescription's info based in its barcode. In theory the machine could even order a refill when it is running low.
  • Connecting drug usage information to doctors and family. Doctors will be able to see a patients drug consumption history and improve diagnosis and future prescriptions.
  • The machine can connect to a drug interaction database that could improve the prevention of incorrect (over) prescription and dangerous drug interactions.

Another key feature that differentiates this project form other medicine reminder projects is the rich UI. Most projects allow the user to set a simple timer, daily, hourly, etc. but this doesn't allow for more dynamic problems such as pain medications. For example, some pain medications have a maximum limit, without a required schedule. The UI for this machine is designed to easily manage this type of use case by locking the dispensing of a drug until the max rate timer has expired. This can be very hard to manage without a robust software UI.

Technical Details

The machine is primarily controlled by a RaspberryPI. The PI runs a web server that serves a web-page to kweb running in kiosk mode with a PiTFT resistive touch LCD interface. The web interface sends CGI commands that control servos within the machine and read an encoder. The PI also has a WiFi dongle that allows for a smart phone to connect to the internal web server and manage the machine remotely. All inventory info and scheduling is stored in a local SQLite database. A custom power management and servo control board was designed for this project as well. Below is a block diagram of the machine.

Here are the software libraries used in this project:

More Details

Here's the extended video about the project. It shows the interface in action and the internal mechanics that make version 1 store and recall individual pills.

  • 1 × USB - WiFi Adapter
  • 1 × 3D Printed Mechanics
  • 2 × MCP1826 Power Management ICs / Linear Voltage Regulators and LDOs
  • 1 × PCA9685 Interface and IO ICs / Display Interface
  • 2 × 4.7 uF caps

View all 14 components

  • 2015 Hackaday Prize Semifinals Video

    Joe09/20/2015 at 03:13 0 comments

    Here's my official semifinals video. Enjoy!

  • Useful APIs

    Joe09/16/2015 at 01:37 0 comments

    There are a surprising list of APIs for both drug info and barcode lookups. I thought I would put a list of some of the APIs I'm looking into...mostly so I don't forget which ones I have found to be the most useful. The ones in bold seem to have the most promise so far.

    Pill shape identification:

    Barcode lockup database:

    Pharmacy APIs

  • Android App

    Joe09/14/2015 at 01:14 0 comments

    Here I talk about the android app I am working on and the progress I have mede to the UI.

  • Scheduling Complete

    Joe09/07/2015 at 20:03 0 comments

    With the fundamental hardware working I have moved on to improving some of the software. The lowest hanging fruit in this case was the scheduling system. You may have noticed in my earlier demo that I have a dummy schedule and the scheduling page has some GUI display problems. Over the weekend I have added a scheduling and log table to the database. A schedule can be created using the form shown below:

    Every time a medicine is dispensed it is logged with the time, medicine, and user. The scheduling system checks every minute for schedules that may need to be taken. For example if the schedules needs to be taken once per day at 1PM the log table is checked to see if the medicine has been logged as taken from 1PM today and after. If there is no matching log a message is displayed automatically to the user and the machine plays a sound and spoken message:

    Users are given the option to Vend, Snooze, or Cancel. Snoozing will ask again in 5 minutes. Vending will dispense a pill for the user and log it. Canceling will not vent the pill and log the pill as not taken. There may be cases where the user will have not choice to cancel depending on the prescription. This has not been implemented yet. I am, however interested in the big data aspects of this type of log. This data could give us information about what methods are more likely to get a user to take a pill, or which/when medicines are more likely to be ignored.

    The new schedule view screen pools the schedules database and get a list of all schedules. It then takes the list and extrapolates the next 10 dates for each med which is displayed on the machine:

    All of the complexity is done on the server side (web server in the machine vs. web browser on the machine). This allows for a smart-phone app (in development) to access this data via an easy HTTP-GET / JSON interface. I have finally added a GIT repo for all the code in this project.


  • Pill Loaders - The Many Options

    Joe08/30/2015 at 23:42 0 comments

    Here I start out talking about the two thrusts of the project: The hardware and the software, and compare them to a smart phone and it's cloud ecosystem. Next I talk about loading pills into the machine automatically and various ways I am exploring to do this. Enjoy!

  • ​Prescription API Problems

    Joe08/29/2015 at 18:48 0 comments

    For the cloud integration portion of this project one of the goals is to use prescription APIs for various pharmacies (CVS, Walgreens, etc.) to lookup medicine data from a scanned barcode. This is proving more difficult that I originally expected. Here's some of the information I have gathered so far:

    Walgreens Pharmacy Prescription API: Walgreens has a great API for mobile devices (Android/iOS) that allows patients to request refills by either choosing a medicine on their Walgreens account or by scanning a Walgreens barcode. I was able to create an account and get an API key but after reading the fine print: "Prescription APIs are currently only available for integrations on mobile & tablet native applications." This means that I can't do any refill magic (based on inventory in the machine) from my server on the cloud. This isn't the end of the world here because I can still make an android app that interfaces with the Medicine Organizer device as well as the Walgreens prescription API. I can't refill prescriptions from the machine itself, but I can from a smartphone. I have already started to work on a phone app for scanning barcodes and interfacing with the machine. Once I have the basic framework setup I will look into integrating this API into the app.

    CVS Prescription API: In theory, CVS should have a a similar API to Walgreens. The documentation is sparse and after several attempts to create a developer account I finally saw an account created success screen. I did not receive an activation email nor can I login with the account I created. FAIL!!! CVS I guess does not have their act together and I will not be pursuing this API any further for now.

    eMC: In Europe they have things figured out! There is an online database that has standardized information about every drug available in the EU (thanks for the tip IT-Wizard). The electronic Medicines Compendium (eMC) is an easily searchable database of drugs that supposedly can be searched via barcode. I have been able to search by drug name but not barcode. I also can't find an API that will allow me to access this information from my cloud server etc.

    I think what this survey shows is that there is a lot of potential to improve the standardization of access to drug information. A new project goal (for 10+ years form now): create an open-access drug database with API for the world that includes information such as:

    • Drug facts
    • Drug interactions (with other drugs)
    • Recommended dosage information (to compare with doctor's prescription)
    • Every drug will have a unique ID number

    I think eMC is a good place to start but the differences in American vs. EU health care systems will pose a challenge.

    Near term goals:

    1. Integrate Walgreens API into smartphone app in interface with machine
    2. Dig deeper into eMC to see if there is an easy way to extract drug info. Perhaps using curl scripts.

  • Custom Servo and Power Board

    Joe08/07/2015 at 03:58 0 comments

    In the original design I wanted to use a custom made optical encoder. I decided to spin my own board for this and figured I might as well integrate regulators and a PWM chip to drive the servos. Below is the board layout. On the side back side in blue are the infrared photodiodes that I originally planned to use as an optical encoder through the rotating barrel. There are 8 Servo connection at the top that drive the motors. There are two regulators: one that powers the servos and one that powers the Raspberry Pi. The regulators can be enabled/disabled to shutdown the Pi and save power. They are separated to avoid brownout on the Pi's supply when multiple motors are consuming a lot of power.

    Here's the parts list:

    • 5 RR1206 IR photo diodes
    • 2 MCP1826 5V regulators
    • 1 PCA9685 PWM IC
    • 2 4.7 uF caps
    • 1 10uF cap
    • 2 1uF caps
    • 5 10k pots
    • 8 220-ohm resistors
    • 3 10k resistors
    • Male headers

    Here's the associated schematic:

  • The M&M Test

    Joe08/04/2015 at 02:01 0 comments

    Hi Everyone,

    I'm posting a quick video here of the machine in action. To make things more obvious I am using M&Ms instead of pills because they are colored.

  • Project Overview Video

    Joe08/02/2015 at 02:50 0 comments

    Here's a video of me describing the motivation for the project and an overview of the machine.

  • The most difficult part: 3D printing tolerances

    Joe07/31/2015 at 01:07 0 comments

    The most critical part of this machine is the 3D printer mechanics that actually hold and organize the individual pills. I went through several iterations of this before settling on the current version (that I already want to improve). The first version was a snake of sorts that would slide around the base of the box and could align one of the many individual storage boxes above a pill insertion port. The main challenge I had wasn't getting the pills in but getting them out efficiently.

    I went through a couple iterations of the snake version but couldn't converge on anything that worked reliably and could make sure the pills never fall out of their containers by accident.

    The latest version I ended up using for this project is based on a rotating barrel. As you can see below in the blown out view, a barrel (blue) with 16x4 slots rotates in a drum (orange). The drum keeps the pills in their individual slots while it rotates. There are holes in the barrel at the bottom and top. Pills can enter the barrel at the top and doors can open to allow the pill to simply fall out with gravity when selected by doors (pink). The selector at the top (green) slides back and forth to select which of the 4 holes to insert the pill into when loaded.

    The biggest challenge with actually building this is the tolerances in my 3D printer. For example, when I print the circular barrel it actually ends up being more oval shaped. This makes it hard to maintain a tight tolerance from the drum to the barrel to make sure the pills don't fall out when rotating. Also, the doors at the bottom have to fit perfectly in place to make sure the pills don't get caught at the joints when the drum is rotating. After it was all printed I ended up having to manually un-warp some of the prints and shave off some of the extra material to get the doors at the bottom to fit perfectly.

    If you want to explore the design in 3D you can download an STL of the blown out design here: machine blown out.stl?dl=0 and a 123D design file here:

View all 11 project logs

Enjoy this project?



bob5731 wrote 01/25/2021 at 15:26 point

Can I get the STL files  split up?

  Are you sure? yes | no

Moritz Walter wrote 09/15/2015 at 09:14 point

Totally amazing quadruple-skull-worthy project! I'd be a bit concerned that pills that are dispensed less frequently than others would be partially ground to dust by the rotational dispenser movements of the more frequently dispensed pills by this particular rotary mechanism design, but either way, this is an awesome piece work!

  Are you sure? yes | no

Joe wrote 09/15/2015 at 23:49 point

Thanks! I agree, grinding away at the pills is a concern of mine. In one of my videos I talk about a different way of storing them in horizontal discs that don't move nearly as often. I think it will help with this problem and many others. Once I get version one here all worked out I think I'll take a look at making those imporvements.

  Are you sure? yes | no

IT-Wizard wrote 08/28/2015 at 10:15 point

TIP: To separate all individual drugs one by one, you can mimic the bingo cage.

I have made this :

  Are you sure? yes | no

Joe wrote 08/29/2015 at 18:17 point

I really like that idea. I think this works really well for pills that are all the same size. This could be especially difficult when the pills are smaller or oddly shaped. How do you ensure you only pick up 1 pill at a time in that case?

  Are you sure? yes | no

IT-Wizard wrote 08/29/2015 at 20:11 point

An optocoupler (opto-isolator) can detect when a pill is passing by.  Maybe you can make different container for most common shapes.

  Are you sure? yes | no

Joe wrote 09/01/2015 at 01:10 point

I have also been tipped off about this: This market segment has been moving fast over the last couple months.

  Are you sure? yes | no

IT-Wizard wrote 08/27/2015 at 19:34 point

Nice to see it working. Actually, I have kind of a similar idea but it is still on paper.

It is true that feeding the machine with one pill at the time, will be painful.  But if you are able to build an automatic feeder, you can put it directly inside your desktop organizer replacing the turning wheel.

At the end, elder people devices must have the easiest interface with the lowest operations.

Here in Belgium, we have all medicines available on the market gather in one database : the compendium. With a bar-code reader, you would have all the information you need in one single operation.

I am happy to see that I am not the only one working in that field.

  Are you sure? yes | no

John Pfeiffer wrote 08/15/2015 at 01:20 point

The fact that seeing this on this afternoon reminded me to take my *morning dose* of medications proves how much I need something like this.  Awesome project.  I look forward to seeing how it comes along!

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates