Pharma-Bot: An AI-Enabled Self Dispensing Pillbox
CWSF · 2026 Health & Wellness Gold Medal
Overview
Many people struggle to take medications correctly, leading to missed doses and potential hospitalizations. Existing pill dispensers require someone to read each label, hand-load pills into compartments, and count out doses, making them hard to use for people with disabilities who don't have caretaker support. To solve this, I designed Pharma-Bot, an AI-enabled self-dispensing pillbox with two components: a software program and a 3D-printed pill dispenser. The software, written in Python, uses a camera and Optical Character Recognition (OCR) to extract key information from prescription labels and tells the dispenser which pills to release, how many, and when. The dispenser has three compartments and uses an Arduino-controlled servo motor to release the correct number of pills. In testing, Pharma-Bot read labels and dispensed pills with high accuracy. By combining smart label reading with automatic dispensing, Pharma-Bot is a low-cost solution that helps people safely manage their prescriptions at home.
Video
This video could not be played here. Watch it on the original project page.
This video could not be played here. Watch it on the original project page.
Video
Video Transcript:
When I was younger, I watched my grandparents struggle to take their medications. This is the same reality for many elderly people and those with disabilities. Mistakes in taking medications send thousands of Canadians to the hospital each year, and in some cases, have fatal consequences. Existing pill dispensers are often expensive, hard to use, and none can read medication labels.
Hi, my name is Lauren Chan, and I'm a grade 7 student. To tackle this problem, I built Pharma-Bot, a low-cost, user-friendly pillbox that reads labels and dispenses pills automatically. It has two main components. The first is a label-reading and scheduling system that uses a webcam to photograph the drug label and applies Optical Character Recognition, a deep-learning technology, to extract the drug name, dosage, and instructions. It then generates a dispensing schedule and sends it to the second component, a 3D-printed dispenser that releases the correct number of pills at the right time, with sensors confirming each dose. In testing, both components worked with high accuracy, making Pharma-Bot an effective solution for reducing medication errors.
Why?
Every day, millions of people struggle to take their medication correctly, leading to serious health consequences and hospitalizations. This is a large yet preventable problem.
My grandparents took care of me when I was younger, and I noticed they struggled with their medications. Pills are small and awkward to handle, sorting them took a long time, and since English wasn't their first language, the labels added another layer of difficulty.
After researching further, I discovered this was a much bigger issue. Over 700,000 Canadians live with dementia, and 1 in 4 Canadian seniors are prescribed more than 10 different medications, making it hard to stay on track. On top of that, roughly 88% of seniors lack sufficient health literacy, and many people with vision impairments can't read prescription labels at all. Physical disabilities can also make opening pill bottles nearly impossible.
Despite how widespread this problem is, most existing pill dispensers are extremely expensive, putting them out of reach for the people who need it the most. They also require significant caregiver involvement to set up, and none include a label-reading feature.
My proposed solution was to create an automated pill dispenser that could:
Extract important information on pill bottle labels.
Build a clear schedule.
Dispense pills are accurate based on found information.
Provide a visual and auditory reminder for the user.
How?
Software
Label Scanning
Pharma-Bot's software, written in Python, performs three functions: extracting information from medication labels, generating a dosing schedule, and controlling the dispenser in real time. The user photographs the medication label on the bottle, which is pre-processed in OpenCV, an image-processing library that sharpens the image and converts it to grayscale to improve accuracy. The processed images are then analyzed by EasyOCR, a Python optical character recognition (OCR) library that converts image text into machine-readable text.
Because OCR output can contain errors, the extracted text is referenced against a database of over 100 common drug names using Levenshtein distance, which identifies the closest match even when a character is misread. Dosage, pill count, and dosing frequency are extracted using pattern matching.
Schedule Creation
The program interprets each medication's dosing frequency and any special instructions, such as "take at bedtime." It generates evenly spaced dose times based on the most frequently taken medication, then consolidates the remaining medications into the minimum number of times per day.
Dispenser
The dispenser was designed in Tinkercad, a modelling program, and then 3D printed. It contains three compartments, each fitted with a rotating plate with a single pill-sized opening. As the plate rotates, the opening aligns with the base, releasing one pill per turn and preventing jams. The electronics are controlled by an Arduino microcontroller and include servo motors to drive the plates, a photoresistor and LED to detect pill release, and infrared (IR) sensors to confirm tray removal.
Integration
The Python software and Arduino communicate over USB: Python handles decision-making, and the Arduino carries it out. When a dose is scheduled, Python signals the Arduino to release the required pills, then monitors sensors for dispensing. Lastly, it sends that user an auditory and visual reminder and monitors for medication tray removal.
What?
Since real prescription pills weren't accessible for this project, candies of varying different shapes and sizes (Mints, Tic Tacs, and Rockets) were used to simulate a variety of pill shapes.
Preliminary Testing
For preliminary testing, I tested the OCR and dispensing system separately, so I could measure accuracy of each component in isolation.
To test dispenser precision, each of the three compartments dispensed different shaped pills at doses of 1, 2, and 3 pills across 20 trials per dosage, for a total of 180 dispensing events. The dispenser achieved an overall accuracy of 98.3%.
OCR accuracy was then tested across several label variables (Fig. [1]). The system reliably identified drug names, dosages, pills per dose, and special instructions. The weakest variable was times per day at 90% accuracy. Errors occurred most frequently when pills per dose and daily frequency were identical. (E.g., take three pills three times per day)
Full Process Testing
The second round of tests evaluated Pharma-Bot throughout the full process, to see how it would perform in realistic conditions. I created 150 simulated prescription labels using common drug names, realistic dosages, and typical instructions in a standard pharmacy format which were then applied to medication bottles. The labels were scanned with a USB camera across 50 trials, with three unique labels assigned to the three compartments in each trial.
Full system OCR reading accuracy was 97.6%, with the system correctly reading the vast majority of drug names, dosages, and instructions. The few misreads usually occurred when pills per dose and daily frequency values were the same number, or when special timing instructions were not captured.
Overall dispensing accuracy was 95.3%, showing that the mechanical and electronic parts worked consistently across different pill types. Looking at each compartment individually, I noticed the performance differences correlated with the pill shapes and colours. The Tic Tac compartment experienced the most jams, since the small, narrow shape sometimes allowed two pills to stand upright in the dispensing pocket. The Mint compartment had more trouble detecting pill drops, likely because the Mints' colour was close to the LED's colour.
So What?
This project showed that Pharma-Bot can reliably extract information from prescription labels using OCR and dispense the correct medication on schedule without any manual information input. Across 150 trials, Pharma-Bot exceeded its performance targets, with 97.6% OCR accuracy and 95.3% dispensing accuracy, compared to the 90% goal set for each.
Comparison to existing products:
Commercial automated pill dispensers do exist, however they all require a caregiver or pharmacist to manually program each prescription into the device. This is a real barrier for elderly or disabled users living alone, who are often the people who need these devices the most. Most commercial dispensers also cost several hundred dollars. Pharma-Bot automates the setup step itself using OCR, and is built from accessible and low cost materials at less than $50.00.
Limitations:
The system occasionally experienced errors, including dispensing jams, pills missed by the detection system, and OCR misreads of label instructions.
Conclusions:
This project showed that an automated pill dispenser is feasible using accessible and low-cost materials. Pharma-Bot has the potential for real world use, such as in nursing homes and also in home care settings, helping elderly and disabled users manage their medications more safely and independently.
What's Next?
Pharma-Bot has shown to be a promising solution for reducing medication errors, however it has room to improve in many areas.
Software:
Improve OCR accuracy for dosing frequency and special timing instructions.
Enhance pill drop detection to reduce missed readings.
Dispenser:
Refine the dispensing mechanism to prevent jamming.
Create a design that can accommodate more pill shapes and sizes.
Expand capacity beyond 3 slots for users managing many medications.
New Features:
Build a mobile app that creates a simpler interface and sends reminders directly to the user's phone.
Add caregiver integration so family or doctors can track medication history remotely.
Thanks
I’d like to thank the science teachers at Zion Heights Middle School for encouraging me to participate and giving me valuable feedback to help me.
I also really want to thank my family who provided me with a lot of support and encouragement to complete this project.
References
Alzheimer Society of Canada. (2024, July 24). Dementia numbers in Canada. https://alzheimer.ca/en/about-dementia/what-dementia/dementia-numbers-canada
Canadian Institute for Health Information. (2022, October 20). Drug use among seniors in Canada. https://www.cihi.ca/en/drug-use-among-seniors-in-canada
Canadian Public Health Association. (2014). Examples of health literacy in practice. https://www.cpha.ca/sites/default/files/uploads/resources/healthlit/examples_e.pdf
Beckman, A. G., Parker, M. G., & Thorslund, M. (2005). Can elderly people take their medicine? Patient Education and Counseling, 59(2), 186–191. https://doi.org/10.1016/j.pec.2004.11.005
Appropriate Use Advisory Committee. (2024). A path to improving medication appropriateness in Canada. Canadian Drug Agency Transition Office, Health Canada. https://www.canada.ca/en/health-canada/corporate/about-health-canada/activities-responsibilities/canadian-drug-agency-transition-office/path-improving-medication-appropriateness-canada.html
The Senior List. (2026, February 10). Best automatic pill dispensers of 2026. https://www.theseniorlist.com/medication/dispensers/
Bradski, G. (2000). The OpenCV library. Dr. Dobb's Journal of Software Tools, 25(11), 120–125. https://opencv.org/
JaidedAI. (2024). EasyOCR (Version 1.7) [Computer software]. GitHub. https://github.com/JaidedAI/EasyOCR
ClinCalc. (2024). The top 300 of 2022. ClinCalc DrugStats Database. Retrieved April 23, 2026, from https://clincalc.com/DrugStats/Top300Drugs.aspx
DrugBank. (2024). DrugBank Online (Version 6.0) [Database]. University of Alberta. https://go.drugbank.com/
Mahajan, A. (2023, October 8). EasyOCR: A comprehensive guide. Medium. https://medium.com/@adityamahajan.work/easyocr-a-comprehensive-guide-5ff1cb850168
Tang, J., Galbraith, N., & Truong, J. (2019). Living alone in Canada (Statistics Canada Catalogue No. 75-006-X). Insights on Canadian Society. https://www150.statcan.gc.ca/n1/pub/75-006-x/2019001/article/00003-eng.htm
Heo, J., Kang, Y., Lee, S., Jeong, D.-H., & Kim, K.-M. (2023). An accurate deep learning–based system for automatic pill identification: Model development and validation. Journal of Medical Internet Research, 25, Article e41043. https://doi.org/10.2196/41043
Images:
Pill sorting video: Polina Tankilevitch. (2021). Person organizing his medicines [Photograph]. Pexels. https://www.pexels.com/photo/person-organizing-his-medicines-8088898/
Thanks Image: OpenAI. (2026). DALL-E (Version 3) [AI image generator]. https://openai.com/dall-e-3
Images (27)
Awards (4)
- Young Scientist Award
- Special Award
- Gold Medal
- Selected for CWSF 2026
Competition history
- CWSF 2026
Related projects
ISEF · 2025
Automatic Pill Dispenser: A Reliable and Efficient Solution for Timely Medication Delivery
ISEF · 2023
Smart Pill Dispenser: Helping Patients Take Their Medication on Time
ISEF · 2020
Developing a Bluetooth Enabled Pill Dispenser
ISEF · 2022
Addressing Medicine Adherence in Older Adults Through User-Friendly Medicine Dispensers
CWSF · 2026
Intelligent Medication Reminder System to Reduce Senior Medication Nonadherence
ISEF · 2021
Rotating Weekly Pill Dispenser
ISEF · 2016
Proto-Bot
ISEF · 2020
Identifying Tablets Using Neural Networks
Closest projects by meaning, across every fair and year in the corpus.