I can be pretty forgetful. Every time before leaving the house, I have to remind myself to bring my wallet, phone, keys, and glasses, often at least five times. For the most part, I have built routines and processes to help me deal with it, except, of course, for my daily supplements (you know, multivitamins, omega‑3, and that kind of stuff). About three years ago, I decided to finally tackle the problem by making an automatic pill dispenser. As the name implies, it dispenses my daily supplements at whatever time I need them.
I reached a somewhat stable version in a few months. I also created a playlist of videos documenting my designs and thought processes, available here if you would like to watch them: YouTube playlist
Eventually, I was pretty satisfied with the way it worked, so I placed it on a shelf and let it do its job for quite a while as a sort of long-term reliability test. Then, at the start of this year, I decided to push the project over the finish line.
If you are interested in making a pill dispenser yourself, I highly recommend watching this tutorial video, where I cover everything you need and explain how to put it together. This article, however, outlines the changes I made and why I made them.
I have made a few changes, most of them in the electronics department of the project.
The first major change was with the motors. In the original design, I used servo motors with a rather hacky workaround to make them travel further than they were designed to, and their reliability was a bit mixed. For the latest version, I switched to N20 micro geared motors, which do a fantastic job. They are quieter and more reliable. Unfortunately, introducing DC motors required the addition of a DC motor driver. I went with a DRV8833, an H-bridge motor driver designed to drive two DC motors in both directions. However, since the pill dispenser only needs the motors to go in one direction, I can use the same driver to run four motors, which just so happens to be the maximum number of motors supported per pill dispenser unit. What a happy coincidence.
Pill-Detection SensorAnother big change was the sensor that detects when the pills have been dispensed. I initially used a very cheap, off-the-shelf vibration sensor, which did the job, but I had to push the design to get the sensor as close as possible to the area where the pills are dropped, and even then it was not particularly reliable for smaller pills. After scouring the Internet, I eventually came across piezo vibration sensors. They are so thin that I can mount them directly under the cup into which the pills are dispensed, and in my testing they reliably detect pills with a 5 mm diameter (smaller than your standard ibuprofen and paracetamol tablets). Best of all, because the piezo sensor uses an analog input pin, the only other components needed to get it working properly are two resistors.
Real-Time ClockThe last major change in the electronics department was the addition of a real-time clock. My original version simply used the NTP protocol to get the time from the network; however, it ended up spamming the network because I was requesting the time at least once every minute. With the addition of an RTC, I only have to set the time once and then never need to query the network again, meaning that after setup it is possible to run the whole system offline.
Web Interface for SchedulingThe final big change, and probably the one that took me the longest to implement, was adding a web interface for easy scheduling. Throughout the project, the pill dispenser’s settings were hard-coded, which is fine for most hobbyists. The people emailing, messaging, and commenting on the videos knew how to put things together but not how to program them. So I finally forced myself to do it properly. Believe it or not, it was not as difficult as it seemed, especially now with AI being as good as it is at coding. The whole thing took only a few days to reach a polished state, and I even added a dark mode.
Easy SetupNow, setting up the pill dispenser is as easy as assembling the electronics, uploading a script onto the Arduino, and browsing to the IP address displayed in the terminal. From there, you can configure everything, from the RTC and motor speed detection thresholds to the schedules for when your pills should be dispensed.
There are still a few features missing from the code that I hope to add eventually. For now, the pill dispenser has no way of knowing how many pills are in the hopper; if it runs out, the motor will just keep spinning indefinitely. I plan to add a pill count that decreases each time a pill is dispensed.
ConclusionApart from a few minor changes to the model itself, that is everything I changed from the original version I started a few years ago. I was personally very surprised that a design I made while still being new to Fusion 360 actually holds up today, so I would like to give the younger, more confused version of me a little pat on the back.
If you would like to make one yourself, the code is available on my GitHub along with the installation instructions. The 3D files are available for purchase on my Patreon. If you need anything else, give me a shout!
Comments
Please log in or sign up to comment.