Smart Pill Dispenser

This project originates from a previous version I made in high school for my grandfather, who takes the same medications every day. However sometimes he forgets to take them, and most of the time only my mother or his caregivers know exactly which pills he needs and whether he has already taken them.

Sometimes other family members and I help refill his medication, but we don't always know his exact routine. Even if the medicine is the same (it might vary depending on the doctor's future prescriptions), its appearance can vary between pharmacies, so it's hard to tell doses apart just by how they look.

This is why I decided to make a smart pill dispenser for my final project. The concept changed through the weeks but at the end resulted in a motorized dispenser that can hold up to 15 single doses. The device doesn't dispense automatically on purpose to avoid dispensing without the user's knowledge. So when the RTC reaches a programmed alarm time, the buzzer keeps the reminder active until the user either confirms the dose or postpones it. After confirmation, a 28BYJ-48 stepper motor advances the carousel to release the scheduled medication. Dispensing occurs thanks to gravity when a compartment aligns with the opening.

The project is powered by a XIAO ESP32 that controls the mechanism, synchronizes the OLED display, reads the buttons, and hosts its own WiFi Access Point where family members or caregivers can connect to set the alarms and check dose logs. The enclosure is made of 3D printed PLA parts, a laser cut acrylic cover, and CNC routed plywood.

Summary

Use case People who forget or skip taking their medication and have long-term routines with fixed schedules.
Interaction Alarm stays active until confirmation or postponement via button press or web interface.
Capacity 15 doses, each compartment holds five or more pills.
Components XIAO ESP32, RTC DS3231, OLED SH1106, push buttons, passive buzzer and magnets.
Motion 28BYJ-48 stepper motor with ULN2003 driver, powered by a USB wall adapter.
Fabrication 3D printed PLA, laser cut acrylic and cork, CNC routed plywood, PCB milling
Automatic pill dispenser final prototype

Presentation Deliverables

Project summary presentation slide

Design Development

At this stage I was still exploring different ideas. I wanted something meaningful, functional, and connected either to a real problem or to a personal interest.

Electronics Programming through Fab Assignments

The electronic part of the project changed a lot through the Fab Academy weeks. My first approach was a Wokwi simulation to test an alarm logic, then I learned the basics about PCB design (I built 3 different ones, the first to learn, the second with more intention and the third one for testing/final project). With the board ready, I learned about the RTC and I2C communication, then I integrated some outputs (buzzer and stepper motor) and finally I created a local web interface to configure the alarms and check the status of the dispenser.

Final Build and System Integration

After the weekly assignments, I continued working on the final prototype through a separate integration workflow. This part focused on testing the stepper motor, repairing and adapting the hardware, organizing the wiring, assembling the structure, and validating the complete dispenser behavior.

Questions Answered

1 Adjusted

Can the gear and carousel move one compartment reliably with 512 steps?

No. In the final calibration, one compartment needed around 1030 steps to align correctly and dispense reliably.

2 Yes

Will the pills fall by gravity through the acrylic opening without getting stuck?

Yes. The final mechanism lets the pills fall by gravity through the acrylic opening when the carousel aligns with the exit.

3 Can improve

Is the buzzer loud enough inside the dispenser enclosure?

It works, but it could be improved. A stronger buzzer or a small amplifier could make the alarm louder and easier to hear.

4 Yes

Does the magnetic cover hold well while still being easy to remove for refilling?

Yes. The magnets hold the cover in place, but it can still be removed easily when the dispenser needs to be refilled.

5 Yes

Can the XIAO power the OLED, RTC, buzzer, and stepper driver from one USB-C charger?

Yes. The complete system worked from one USB-C charger during the final integration tests.

6 Yes

Can the XIAO host the caregiver interface while still running the alarm and motor logic?

Yes. The XIAO can run the access point interface while controlling the alarm, OLED, buttons, and motor. A future improvement would be testing a WiFi web server or a combined version that can send Telegram messages to relatives if the dose is not taken.

7 Not now

Is the optional line follower useful enough to include?

Not for this version. Since the user confirms the dose manually, the sensor adds more complexity than value. It could be useful later in a more automated version.

8 Yes

Can the user understand the blue button interaction without extra instructions?

Yes. The interaction is understandable, and I also added vinyl labels to make the buttons clearer for the user.

9 Future

How can the 16-day ring become modular in a future version?

Magnets and snap fits could help make the ring modular, easier to remove, and easier to replace or adapt in future versions.

Future Improvements

BOM Table

Component Purpose Qty Source Cost MXN Cost USD
XIAO ESP32-C6Main controller1Provided by Fab Lab Puebla / Uelectronics reference price$137$7.61
DS3231 RTC moduleReal time clock1Amazon MX reference price$95$5.28
SH1106 OLED 128 x 64User display1Amazon MX reference price$110$6.11
28BYJ-48 with ULN2003Carousel motor1Amazon MX reference price$80$4.44
Passive buzzerAlarm sound1From a small Arduino starter kit$15$0.83
Tactile push buttonsConfirm and snooze2Purchased$10$0.56
FR1 copper boardPCB substrate1 sheetFab Lab Puebla$60$3.33
PLA filament3D printed partsApprox. 0.7 kgFab Lab Puebla$280$15.56
3 mm acrylic sheetLaser cut cover1 pieceAlready owned$45$2.50
9 mm plywoodCNC routed base1 pieceRecycled material$50$2.78
Cork sheetLaser cut cover for plywood detail1 small pieceAlready owned$15$0.83
Adhesive vinylButton labels1 small pieceFab Lab Puebla$10$0.56
Neodymium magnets 5 x 3 mmRemovable acrylic cover closure18Amazon MX reference price$180$10.00
M1.6 screwsSmall acrylic and OLED center piece assemblyAssortedAlready owned$35$1.94
M6 screwsFastening printed parts to the wooden baseAssorted lengthsAlready owned$45$2.50
90-degree male pin headersPCB connections and modified OLED/header orientation10 pinsFab Lab from the university$25$1.39
240 Ω SMD resistor 1206PCB resistor used in the Week 10 board1Fab Lab from the university$2$0.11
Dupont jumper wiresModule wiring and final electronics integrationAssortedFab Lab from the university$45$2.50
Dupont housings and crimp terminalsButton and modular cable connectionsAssortedFab Lab from the university$40$2.22
Heat shrink tubingButton solder joint insulationAssortedFab Lab from the university$20$1.11
AdhesiveSecuring magnets and cork onlySmall amountLab inventory$20$1.11
USB C 5 V chargerPower supply1Already owned$0$0.00
Total estimated$1,319 MXN$73.28 USD

These are estimated replacement costs, even when some materials were provided, recycled, or already owned. USD values are approximate, calculated with an estimated exchange rate of 1 USD = 18 MXN. The 10 kΩ resistor from the Week 10 test board was not included because it was related to a test feature that was not used in the final project.

Conclusions and Learning Outcomes

One of the biggest things I learned is that there is always something that can be improved. This project started years ago as a high school idea, and I honestly never imagined I would be able to revisit it at this level: with electronics, digital fabrication, programming, networking, documentation, and a working prototype.

I made many mistakes during the process, and the final system can still improve, but it represents a huge step forward for me. Before Fab Academy, I knew very little about programming and electronics, and even now I know there is still a lot to learn. However, this project showed me that learning doesn't happen only by getting things right. It also happens by asking questions, testing, failing, researching by myself, and learning from the people around me. It also changed the way I understand documentation. Sometimes small changes, tiny mistakes, or simple decisions feel unimportant in the moment, but later they can help us or someone else understand the process better, documenting became another way of learning (very tedious but worthy)

I also want to thank my professors and local evaluator from Fab Lab Puebla, my friends and my family that helped and supported one another throughout this journey, making the process a lot more enjoyable.

Final Prototype Gallery

License

Creative Commons BY-NC-SA 4.0

This documentation and project files are shared for learning, remixing, and non-commercial adaptation with attribution.

Credit the author Non-commercial use Share adaptations alike