Skip to content
Buy 10+ on select items — save 10% auto-applied
Free US shipping on orders $35+
Order by 3pm ET — ships same-day from the US
Skip to main content

Arduino Nano DS3231: Timed pill dispenser alerts | ShillehTek

May 27, 2026 14 views

Arduino Nano DS3231: Timed pill dispenser alerts | ShillehTek
Project

Build an Arduino Nano DS3231 pill dispenser with servo indexing, buzzer alerts, and an SSD1306 OLED so scheduled doses are easier to follow with ShillehTek.

3 hr Intermediate6 parts

Project Overview

Arduino Nano + DS3231 RTC automatic pill dispenser: The DS3231 real-time clock tracks medication times, a servo rotates a multi-compartment pill carousel, and a KY-006 buzzer alerts when it is time for the next dose while an SSD1306 OLED displays status.

This build is intended as a maker reminder system for scheduled dispensing and alerts for daily medication routines.

  • Time: ~3 hours
  • Skill level: Intermediate
  • What you will build: A 7-day medication dispenser with audible alerts, scheduled dispensing, and an OLED status display.
Arduino Nano pill dispenser build using DS3231 RTC, MG90S servo, KY-006 buzzer, and SSD1306 OLED in an enclosure
DS3231 + servo + buzzer + OLED + Arduino Nano for scheduled medication reminders.

Parts List

From ShillehTek

External

  • 3D-printed pill carousel (7-compartment turntable) - mechanical holder that indexes each dose.
  • Push-button (confirm-taken) - acknowledges the reminder (as designed for your build).
  • 5V USB supply - powers the Arduino Nano and modules.

Note: This is a maker reminder system, not medical equipment. Always check the dispensed pill against the prescription label.

Step-by-Step Guide

Step 1 - Build the Carousel

Goal: Create a 7-compartment carousel that can index from one dose to the next.

What to do: Assemble the 3D-printed turntable and mount it to the servo shaft so it can rotate reliably. The design shown uses 7 slots, so each move indexes about 51 degrees (360/7).

MG90S servo mounted to a 7-compartment 3D-printed pill carousel mechanism for an Arduino Nano dispenser
7-compartment turntable on the servo shaft; rotates about 51 degrees per slot to align the next dose.

Expected result: The carousel turns smoothly by hand and can be driven by the servo without binding.

Step 2 - Wire the DS3231, OLED, Servo, Buzzer, and Button

Goal: Connect all modules to the Arduino Nano so the RTC and display share I²C, and the servo, buzzer, and button use digital pins.

What to do: Wire the DS3231 and SSD1306 OLED to the Arduino Nano I²C lines, and connect the servo, buzzer, and confirm button to their assigned pins as shown in the diagram.

Wiring diagram showing Arduino Nano connected to DS3231 RTC and SSD1306 OLED on I2C, MG90S servo on D9, KY-006 buzzer on D8, and confirm button on D2
DS3231 + OLED on I²C, servo on D9, buzzer on D8, confirm button on D2.

Expected result: All modules power on correctly, and the I²C devices (RTC and OLED) are connected to the same bus.

Step 3 - Set the Clock and Flash the Schedule Sketch

Goal: Configure the DS3231 time and upload a sketch that dispenses on a fixed schedule with an audible alert.

What to do: Use your usual DS3231 setup method to set the current time, then upload the scheduling sketch below. The example schedule is 7am, 1pm, and 7pm, and it advances one carousel slot each time.

Code:

#include <Wire.h>
#include <RTClib.h>
#include <Servo.h>
RTC_DS3231 rtc; Servo carousel;
const int BUZZ = 8, BTN = 2;
// Schedule: 7am, 1pm, 7pm
const int HOURS[] = {7, 13, 19};
int slot = 0;
int lastDispensed = -1;

void dispense() {
  tone(BUZZ, 880, 300); delay(400); noTone(BUZZ);
  carousel.write(slot * 51);   // 51° per slot for 7 slots
  slot = (slot + 1) % 7;
}

void setup() {
  Wire.begin(); rtc.begin();
  carousel.attach(9); carousel.write(0);
  pinMode(BUZZ, OUTPUT);
  pinMode(BTN, INPUT_PULLUP);
}

void loop() {
  DateTime now = rtc.now();
  for (int h : HOURS) {
    if (now.hour() == h && now.minute() == 0 && lastDispensed != h) {
      dispense();
      lastDispensed = h;
    }
  }
  // Audible reminder every 5 min until button pressed
  delay(500);
}

Expected result: At the scheduled hour when minutes equal 00, the buzzer chirps and the servo indexes the carousel to the next slot.

Step 4 - Test the Full Assembly

Goal: Confirm the dispenser indexes correctly and the alert triggers at the right time.

What to do: Assemble everything in the enclosure, load a small test payload in the compartments, and run the system. If needed, temporarily adjust the schedule hours in code to trigger a test event sooner.

Completed Arduino Nano pill dispenser enclosure with DS3231 RTC, SSD1306 OLED, servo-driven carousel, and buzzer installed
All components mounted in one enclosure.
Arduino Nano pill dispenser running as the buzzer alerts and the servo rotates the 3D-printed pill carousel to dispense a dose
Buzzer alert and carousel rotation at the scheduled time.

Expected result: The buzzer sounds at the scheduled time and the carousel advances so the next dose aligns with the dispense slot.

Step 5 - Where to Take It Next

Goal: Identify safe, practical ways to extend the project once the base build is working.

What to do: Consider enhancements like connectivity, logging, and better schedule management.

  • Add Wi-Fi (ESP32) to alert family via Telegram if a dose is not confirmed within 30 minutes
  • Log every confirmed dose to microSD for medication adherence reports
  • Multi-medication compartment using an HX711 weight sensor to help confirm a pill dispensed
  • OLED menu for setting and adjusting schedules without re-flashing

Expected result: You have a clear roadmap for upgrades while keeping the current build stable.

Conclusion

This project uses an Arduino Nano with a DS3231 RTC, a servo-driven carousel, and a buzzer alert to create a scheduled pill dispenser with on-device status display. Once it is dialed in, it can reduce missed doses and simplify daily routines for caregivers and users.

Want the exact parts used in this build? Grab them from ShillehTek.com. If you want help customizing this project or building something for your product, check out our IoT consulting services.