IoT Pill Dispenser

14K4022

Intro: IoT Pill Dispenser

Does you grandma forget taking her pills? Here's a solution.

I decided to make a smart pill dispenser that could remind about medicine and dispense it on press of a button. If in case dose is missed a notification is sent to caretaker.

Device is portable and powered by a Li-Po battery which can be charged over USB cable.

Buzzer and LED is used for alarm.

Here is demonstration video:

STEP 1: Design and Mechanism

Within some time(60 seconds, can be changed) after onset of alarm, press of green button on top operates two servos dispensing a pill. If button not pressed an E-mail is sent using IFTT(Webhooks).

Although pill can be dispensed at any time irrespective of alarm time, for this operation long press the green button.

Two servos operate in a sequence to push one pill down the slot and third servo opens lid just at the right time dispensing pill out.

Above 2 illustrations depict working mechanism and design of project.

Below attached is video of barebones of pill dispenser:

STEP 2: 3D Printing Main Passage

Although I used PVC material but you can have a rough idea from below embedded parts. Dimensions can be adjusted according to your needs.

You can see in main tube there are 2 channels one small and the other slightly bigger. Former channel is for structural rigidity and latter for passing pills.

Tube:-

Connector:-

Pipe:-

STEP 3: Main Passage Construction

You can skip this step in case you'll be 3D printing this component!

I started out with 20mm X 12mm PVC casing because it allows a normal tablet to pass through freely.I cut reasonable length using a hacksaw and went on to making slits for servo motor attachment(Thing that acts as obstruction in path of pills).

An art and craft cutter will give more precision when cutting slits. The distance between 2 slits is equal to length of pill to be used. In my case center to center distance is 15mm.

STEP 4: Rig Servos to Passage

My old trustee "Hot Glue Gun" helped me with this. Use single sided attachment.

Although, I used cello tape to temporarily hold them in place and after testing everything glued them permanently.

STEP 5: Elbow Attachment

As pills would be falling vertically to make them horizontal when dispensing out, I used elbow attachment for 1/2" diameter pipe. Again used hot glue gun to secure everything in place.

STEP 6: Schematics and Soldering Circuit

Above is fritzing schematics of project.

Some clarification:

  • Higher placed servo of main passage is attached to pin D3
  • Lower placed servo to D8
  • Lid servo to D5

Take a descent sized perfboard and place headers as described in photo before soldering everything.

I used lead free solder this time after realizing lead is really dangerous stuff, I suggest you too to use lead free :)

You can make connections even more secure by gluing all wires on backside but do it only after checking everything works fine there should be not short-circuits. Because after gluing its almost impossible to modify connections.

I made my own cable for connecting components to main perfboard using male-female headers and rainbow ribbon cables.

STEP 7: Preparing Battery

I used old samsung phone's battery(Got it for cheap, only 100 Rupees or 1.5 USD). Identify positive terminal and negative terminals of battery and solder 2 wires.

I would suggest to check if battery still charges, old batteries are usually completely discharged. Use TP4056 to charge it up.

STEP 8: Modification of TP4056

Charging status LEDs of TP4056 are SMD and won't be visible outside enclosure of project so I decided to replace them with common through hole LEDs. It turns out they are connected in common cathode configuration. Carefully remove SMDs and solder thin wires. Middle solder pad between two LEDs is the common cathode.

STEP 9: Building Enclosure

I chose thin plywood for building the enclosure. Dimensions have high tolerances. You can make according to your components. It should be portable. I used thin nails and glue to join surfaces.

Construction is pretty simple, a cuboid with cutout for various things.

Charging Status LEDs, Buzzer, Display, charging port, opening etc.

Use Dremel to make cutouts in plywood. Circular opening for PVC elbow is the most challenging to do.

Instead I would suggest to 3D print the enclosure if one has access to.

STEP 10: Fit Everything In

Here comes the most satisfying part of the build, gluing everything in its place and tidying everything up. I just used hot glue gun to secure components in place. Placement of buttons and switches can be seen in pictures above.

STEP 11: Lid and Hinge

I also added front cap that moves aside whenever medicine is to be ejected, this is one of the main components that prevents any kind of dust or germs from creeping inside passage.

Now enclosure was almost ready, except a hinge for refilling pills. I used two thin nails to make a working hinge as shown in video.

STEP 12: Setting Up IFTTT

The only part left was programming the device and setting up ifttt applets.
I used 2 events:

  1. One for indicating that pill was dispensed
  2. Other one if alarm was missed hence dose was not taken

To set up ifttt service:

  • Go to https://ifttt.com/
  • Create an account
  • Go to homepage
  • Click on "Create" button on top right corner(This will take create new applet)
  • Click on Big "This" button followed by If
  • Search for Webhooks and select it
  • Enter event name and remember it
  • Now click on Big "That" button followed by then
  • Select any convenient notification system, I chose email (type it in searchbox) and connect the email id to which alert is to be sent.
  • Next compose the template for email (Simple dose missed text is enough)
  • Open Webhooks and open documentation to get you KEY.

You can refer to Taifur's instructable for better instructions except Maker in his tutorial is webhooks now and I chose E-mail instead of SMS.

You can chose any notification system. More power to you!

Make sure to remember webhooks key that is to be used in code.

STEP 13: Editing and Uploading Code

Now for making these work one has to edit code provided below.

Enter you ssid name and its password as indicated in code.

Also replace the key found on documentation page of webhooks in address1 and address2 along with their event names.

Event names are different for each event but key is same.

Also enter the alarm time code(values of integers hour_1 and min_1) Now the code is good to be uploaded.

Below is the code attached after modifying the parameters. Upload it and you are good to go!

STEP 14: Final Thoughts

Although I loved this machine, it works flawlessly each time.This is in no way a perfect device.

A lot can be improved in it. I am working on second version of it improving on:

  • Pocket design
  • 3D printed enclosure
  • Neat wire management inside enclosure using printed circuit boards

I will put in efforts to turn this idea into really awesome version 2.

I hope you liked my instructable! Please comment down any suggestions you have!

And don't forget to vote! ;)

15 Comments

I'm getting an error: expected primary-expression before 'for'

bro in the coding section it is throwing an error as "HTTPClient::http.begin is declared with an attribute error,obselete api please let me know how to rectify this error.
Ohmygosh I would literally buy one of these from you. These are like $1500 on the market because of all the approval and accuracy checks they need to go through; as someone with ADHD I just need something to dispense things, and I can verify if it's correct or not. Would you be willing to build/sell an individual one of these??
After you click on it, Dialog box will open up asking you to move in folder! Click on "OK"
If you still face any problem, please feel free to message me
This is a very challenging project that you did a great job on. It has a lot of potential for many other applications that a few people have already commented on like the pet feeder and multiple pill dispenser. It could also be scaled up a bit larger to be used as a parts dispenser/counter, cereal dispenser, etc.
It is very impressive! You may have a great future in gizmo design.
Could this also be used as a pet feeder for a hamster? If so I may make this.
A great prototype!
Whilst this project is good I am afraid I don't know many old wrinklies that only take one tablet.
I have to take 7 in a morning and 5 at night. I think maybe some thoughts on making several tablets dispense at one time would be good The basic idea is excellent please keep up the design work and good luck. I look forward to seeing mark 2.
Yeah that's quite a good idea. At my place, I have rarely seen somebody take more than 2 types of pills, usually one is for Blood Pressure and other for joint pains(Second one also not frequently). I had just pvc pipes and plywood to work with. Once I get my hands on 3D printer, I'll surely make a mechanism that could dispense multiple types of pills. Its not much difficult to do so. Thanks for the suggestion :)
This is a GREAT thing and so Very much needed !! Please keep up the wonderful work on this one. I would love to have this for my parents and in-laws NOW!!
I will certainly follow you. Thank You !!