3D Printing a Smart Pillbox with Neural Network Image Recognition

ST Dentistry

Share this Article

Hospital pharmacists have their hands full, as they have to handle a wide variety of medications. They need to keep the medicine safe, and no matter how hard we may try, people aren’t perfect, so processes like these are always subject to human error. One way to solve this is by using a pill dispensing system, which can be fabricated with 3D printing. Five researchers from Taiwan published a paper, titled “Development of Smart Pillbox Using 3D Printing Technology and Convolutional Neural Network Image Recognition,” about the automated system they developed that makes it more accurate and simple to dispense medication.

“Safety in taking medicine is important in health care. In this study, we propose a complete concept of an active smart pillbox, which comprises a main control unit, a pill dispenser unit, and an application software (app) for the automatic dispensing of medicine. The smart pillbox employs convolutional neural network image recognition and 3D printing technology,” the abstract states.

They designed the system as a 3D-printed mechanism, which uses an Arduino-based platform to control its movement, and a mobile app to set the parameters via smartphone. The app sets the type of medication, and what time it should be taken, and the smartphone will then transmit the selected settings through Bluetooth to the main platform.

“The Arduino (master) sends the action commands through a MAX485 to the Arduino (slave). The Arduino (slave) receives the command and starts the action. In the Arduino (slave) action process, the main Arduino (master) continues transmitting the message to each Arduino (slave) and completes the actions for each Arduino (slave). After completely dispensing the pills, the main Arduino (master) returns the message to the smartphone to inform the user taking the medicine,” the researchers explained.

The pillbox system was designed in Solidworks, and it was 3D printed, along with the rotating gear.

At first, a button setting isused to operate the smart pillbox, but eventually, the mobile app will define which of the pills should be dispensed, and then set the medication commands for when they should be dropped.

“To increase the number of types of pills that can be stored, the Arduino (master) gives instructions to the slave through MAX485, sets the number of each type of pill, and operates the system,” they wrote. “The times when the pills should be dropped are set, according to the arranged kit number. Multiple times can be set, and the user is reminded to take the medicine at these different times.”

Once the amount of pills to be dispensed is set, the Arduino controller gives a command to start both the motor and the sensor. The motor gears drive the gears that connect to the rotating teeth, which then rotate the pill dispensary. Then, once the pill arrives at the chute, it’s dropped through, and a sensor counts the number of pills dispensed. For every pill dropped, a value on the display is reduced by one.

The other parts to this system are pill image recognition and the training model. Three processes are used to recognize a picture—identification, looking, and scaling down—and, in this case, a camera based on the popular convolutional neural network (CNN) is used to perform these and acquire images of the pills. These images are then transferred to the smartphone app for CNN recognition.

This CNN uses Googlenet architecture for model training, which has trouble achieving data diversity. But, as the object’s background in this system is limited, and features no miscellaneous identification, the researchers used a Siamese network, which is “often used for face recognition and model architecture training.”

“The principle is to capture the features of the neural network for image recognition. The final fully connected layer for classification is not entered, but the feature is entered as one (128, 1). The vector, also known as an embedding, then discards the photo of the identified item and the photo in the database is selected for the model to obtain a vector of (128, 1), and then the two vectors are compared,” the researchers wrote. “For training this model, first, we must define a loss function to measure the distance between embeddings. Here, we use the triplet-loss function; there will be three photos: the anchor and the positive and negative images of the anchor.”

As the data set is a picture of just one pill, in order to detect the individual pills, multiple images are processed so edge detection can be used to cut out and separate each one. The model finds the edge’s pixel-exposed part by following these steps:

  • Eliminate noise and smooth image with a mask
  • Calculate the horizontal and vertical gradients to find the boundary
  • Find the contour

“Finding the contour: use the findtour function of cv2; with the CV_RETR_EXTERNAL parameter, only the outline of the outermost layer is taken. Input of square image: the cv2.boundingRect parameter is used and saved as an image file,” they stated.

There are still some issues to work out, such as excessive friction being generated if too many medicines are in the box, and the fact that the training model’s recognition rate with unseen data is low due to “lack of diversity of resources.”

“If we can accumulate more datasets in the future, the accuracy of the model can be increased, and the model can be compared with other models,” they stated.

But, because users can set their pill type and medication time with the app, it’s easy to use the pillbox system from the comfort of home – it actually provides a reminder once the parameters have been set, and will then dispense the right pills at the right time.

“The purpose of this study is to develop an intelligent automatic pillbox system on the basis of the concept of a pharmaceutical packaging system used in smart hospitals, a system that is tailored for personalized use. The development of the smartphone app provides a more convenient and safe medication system for patients’ homecare. It is not necessary to put the tablets one by one into a designated area according to the medication time of the user, which can reduce the unnecessary waste of time and exposure of tablets,” the researchers concluded.

Discuss this and other 3D printing topics at or share your thoughts below.

Share this Article

Recent News

3DPOD Episode 153: 3D Printing Success with 3Doodler Inventor Max Bogue

AddUp Joins $1.5M USAF Contract to Boost Aerospace 3D Printing


3D Design

3D Printed Art

3D Printed Food

3D Printed Guns

You May Also Like

3D Printing News Briefs, May 27, 2023: Contract, Acquisition, Movie Prop, & More

We’re discussing Sintratec’s All-Material Platform first in today’s 3D Printing News Briefs, and then moving on to an NSF Career Award for a University of Pittsburgh research and a Phase...

Zeda Opens 3D Printing Facility in Cincinnati to Serve Regulated Industries

Today, California-based Zeda, Inc. announced that it has officially opened the doors to its new 75,000-square-foot advanced manufacturing facility in Cincinnati, Ohio. The company, which rebranded to Zeda from PrinterPrezz...

3D Printing News Briefs, May 13, 2023: RAPID Roundup Part 2

For the second time this week, 3D Printing News Briefs is focused on news stories about RAPID + TCT! From new hires and 3D printer integrations to new 3D printers,...

Dyndrite RAPID Roundup: Partnering with Impossible Objects, BCN3D, AMFG, & UPM

Like so many other 3D printing companies, Dyndrite attended the recent RAPID + TCT, North America’s premier annual additive manufacturing trade show. The Seattle-based AM software company, which developed its...