Introduction: RFID Medication Dispenser

This instructable was created in fulfillment of the project requirement of the Makecourse at the University of South Florida (www.makecourse.com)

Have you ever had the need to organize your meds for the month but want a way to restrict access to them so only you can get to them? Well this medication dispenser is for you! Made using a Arduino, RFID card reader, Hitachi 16x2 LCD screen and a stepper motor for the control system and a few 3d printed and laser cut parts, 28 days of medication can be stored within it and access can be restricted to only those with the RFID card in hand. In this instructable, I will show how the control system is wired and programmed, as well as how the 3d printed and laser cut parts are created using Autodesk Inventor.

Step 1: 3D Printed Parts

The first step is to create the parts which will dispense the medication. The first part I made was the dispense wheel, since it was at the heart of the design. The idea was to be able to fit about 5 average sized capsules into each each slot and have 28 slots so that 4 weeks worth of meds could be leaded into the dispenser. This led to the wheel being 138 mm across and 28 mm tall, with each slot being 35 mm long. The solid inner part of the wheel is necessary so that pills do not become wedged between the slots. A small slot for the stepper drive shaft also needs to be placed in the back of the wheel so that it can be driven. The stepper i used had a slotted shaft that was 3 mm by 5 mm, but you should measure accordingly as to make a sure fit.

Next I made the base shroud for the wheel which holds the medication in the wheel and also has the slot for the medication to fall through when turned to the correct position. Since the shroud needs to fit the wheel tightly but also free movement, I went for a 1 mm clearance on each side, resulting in a inside diameter of 140 mm. The shorud also needs to be a little taller than the wheel so that the lid will fit down over it, so the side walls are 30 mm tall. Since the slots are 13 mm across as the ends, the slot at the front of the shroud needs to be 13 mm. A cutout on the bottom of the shroud is necessary because the wheel mounts directly on the stepper motor which is on a motor mount connected directly to the base box. This center cutout hole was 70 mm in diameter. A rectangular protrusion is made on the back so that a hinge for the lid may be attached to the shroud. For this is simply went to Ace hardware and got the second smallest hinges they had, which were 3/4'' wide made of brass. The rectangular protrusion only needs to be big enough to accomdate the hinge. Finally, holes were made on the sides of the square base in order to attach the base shroud stands. These can be omitted if you wish to drill them later.

The next parts were the mounts for the stepper motor and base shroud. The stepper mount was 79mm tall and 45 mm wide at the base with 29 mm between the two side mounts, and a 45 degree angle sloping down from the top. Holes are made in order to match up with the mounting holes for the stepper motor and to attach the mount to the base box. The shroud mounts were slightly taller, totaling 83 mm tall and 35mm across with the same 45 degree angle. Holes were made to match up with holes in the shroud and the base box.

The lid was made using a laser cutter and 1/8'' plywood. The design was also made in inventor, making the wheel 140 mm in diameter to match with the shroud and adding a rectangular outset at the top so that the hinge can be mounted.

The final part is the base box, which holds the arduino, LCD screen, RFID reader, power switch, battery, and allows everything to be mounted to it. For the Make course, we were all given a box and I simply modified this in order to hold everything, however, if a new box can be 3D printed it is ideal as the parts will fit perfectly.

Step 2: Assembling the Dispenser

To assemble the dispenser, first the stepper mount needs to be mounted in the center of the base box lid. The stepper motor can then be attached to the mount. Holes will need to be drilled so that the mount can be attached and the stepper motor wires can feed through the lid. Next, the shroud mounts need to be attached to the shroud and placed on the lid, but not yet attached. The dispense wheel can now be fitted onto the stepper drive shaft. Making sure there is even space between the wheel ad the walls of the shroud and the wheel is free to move within it, mark the mounting holes for the shroud mounts on the base box lid. This ensured a perfect fit between the moving and stationary parts. After the holes have been marked, the holes in the lid may be drilled to mount the shroud. The dispense wheel may now be placed onto the drive shaft again and secured with glue if there is play between the shaft and wheel. The final step if to attach the hinge and lid to the shroud, which simply screw together.

Step 3: Wiring the Control System

For the control system for the dispenser, the LCD screen, Stepper motor and RFID card reader are all connected to the Arduino. All of these devices are powered using a 9V battery paired with a Texas Instruments UCC283T voltage regulator. Since the voltage regulator is connected to the positive and negative rails of the breadboard, all of the devices except the RFID card draw their power from this. The RFID card reader uses 3.3 volts and thus draws its power from the Arduino's 3.3V output. Shown is the Fritzing diagram of how everything is wired up. One exception to the diagram is the way in which the LCD screen is connected. Since the LCD screen used has a YWWrobot 1602 controller boeard attached, which uses the PCF8451 port expander chip, only the power, ground, SDA and SCL lines are required for its connection. The SDA and SCL lines are for the I2C bus and are specifically marked on the arduino. Another exception to the diagram is the connection of the stepper motor. Shown in the diagram, the motor is connected using a ULN2003 darlington array IC. In the actual setup, this chip is still used however it is part of a stepper motor circuit which has LEDs to note which stepper coil is being driven at a given time. A toggle switch was also added in line with the battery and mounted on the rear of the base box, in order to easily turn the control system on and off.

Step 4: Programming the Arduino

Now it is time to program the Arduino so that the dispenser can function. This is achieved by writing code in the Arduino IDE and including the libraries for each of the devices used so that keywords can be used to control each device. After inlcuding the libraries, the pin numbers for the reset and slave select pins for the RFID reader must be set using the #define statement. We then initialize the card reader and LCD display, set the gear ratio for the stepper, and pass the output pin numbers to the stepper function. We then come to the setup function, where the backlight for the LCD is turned on and the speed for the stepper is set. The main loop immediately follows this, where the program constantly checks for a new RFID card while displaying "Scan a RFID card" on the LCD. If a card is successfully read, the stepper motor is run for 73 steps which corresponds to one division on the wheel and the LCD displays "Dispensing". Once the stepper finishes running, the program returns to the top of the loop, where the program continues checking for RFID cards and LCD displays "scan a RFID card". A full explanation of code is given in the attached video, where each line of code is discussed. The code is also attached, which can be opened in the Arduino IDE and the comments read for a better understanding.

Step 5: Installing the Control System

The final step is to install the control system into the base box. This was accomplished by first mounting the LCD into a cutout slot in the front of the box. Since the cutout hole was bigger than the LCD display and looked ugly, a laser cut frame was made and placed around the LCD. Next, the RFID card was mounted next to the LCD display o the front of the box. It is important that the RFID reader is mounted flush against the side of the box, as the range is limited and the card needs to be able to be read from outside the box. The Arduino, breadboard and battery can then be mounted inside the box. I used one of the plastic standoffs inside the box in order to mount the Arduino and simply stuck the bread board to the bottom of the box using the adhesive attached to it. The battery was then secured to the side of teh box using tape, which allows easy replacement as necessary. The final step is to mount the switch in the side of the box, which is held in place by sandwiching it between the sides of the box with two nuts.

Step 6: Finishing Up

Now that the Dispenser has been assembled and the control system programmed and mounted, we are ready to secure the lid of the box to the base. We now have the finished dispenser! The only remaining step is to power on the dispenser and align the slots of the wheel with the slot in the shroud, which can be down by turning the stepper through while it is running. Enjoy your new pill dispenser!