mahdan.xyz
← All projects

Embedded systems

Automated pill dispenser

A time-triggered pill dispenser I am building, combining an ESP32, a real-time clock, and a stepper-driven mechanism.


ControllerESP32 / real-time clock
FirmwareC / FreeRTOS
MechanismStepper motor

Projects

People forget to take their pills. The problem gets worse with age and with the number of daily doses, and the usual fix is a plastic weekday box that still depends on you remembering to open it.

DoseDrop is an overengineered version of that box. It stores the doses, keeps the time, and pushes out the right compartment when the time comes. Nobody asked for a stepper motor in a pill box. The point of the project was to put every part of a build in one place, firmware, electronics, mechanical design and enclosure, and finish it as one working device instead of four separate exercises.

ControllerESP32 / real-time clock
FirmwareC / FreeRTOS
MechanismStepper motor

The device runs on an ESP32 with a real-time clock, a stepper motor and a round display. I wrote the C firmware, interfaced the stepper and the display, designed the mechanism in Fusion 360.

From clock time to motor movement

The RTC holds the time. A FreeRTOS task wakes on the minute, compares the current time against the dose list, and starts a release when they match.

At a release the controller drives the stepper, which turns the compartment ring until the next dose falls into the collection area.

Block diagram of the DoseDrop control electronics: an ESP32 running FreeRTOS connected to an RTC, Hall sensor, encoder, temperature circuit, web interface, stepper driver and motor, display and LED, buzzer, SD card, and USB
DoseDrop control-electronics overview. Select the diagram to enlarge it.

Designing the mechanism and interface

CAD model of the pill dispenser showing day-labelled compartments, a round front display, and the recessed collection area
3D model of the dispenser, showing the compartment layout, front interface, and collection area. Select the image to enlarge it.

Compartments, motor mount and enclosure were modelled as one assembly. The round display is the local interface, used for setting the schedule rather than for triggering a dose.

Early-stage prototype

Testing the early pill dispenser prototype.

Next phases

A custom PCB will move the electronics off the breadboard and onto a dedicated board. A companion app will handle the schedule from a phone instead of the local display.