Projects / Talking pill reminder

Talking pill reminder

Beginner2 hGuided buildReviewed

Build it step by step

0 of 8 done
  1. NANODFPLAYSANDIS

    Prepare the sound files

    Record clips and name them 0001.mp3, 0002.mp3 on the card.

  2. NANO

    Wire the player

    Connect the speaker and the serial lines with the resistor.

  3. NANO

    Test one track

    Play track 1 from a simple sketch.

  4. NANODS323110:48

    Set the RTC

    Use a library example once.

  5. NANO

    Set the dose times

    Edit the DOSES list.

  6. NANO

    Upload

    At the dose time the clip plays.

  7. NANO

    Confirm

    Press the button to stop the repeats.

  8. NANO

    Check a missed dose

    Leave it and see it repeat every five minutes.

In short

How do you build a talking pill reminder?

A reminder speaks the name of the pill at dose time for people with low vision. You need Arduino Nano, DFPlayer Mini MP3 module, Speaker 8 Ω 0.5 W, SanDisk microSD card 32 GB (A1, Class 10), DS3231 RTC module, Tactile push button 6 mm and Resistor 1 kΩ. It takes 8 steps and about 120 minutes.

Level
Beginner
Time
About 120 min
Parts
7

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
DFPlayer VCCNano 5VPower
DFPlayer GNDNano GNDGround
DFPlayer RX1 kΩ resistor then Nano D11Commands to the player
DFPlayer TXNano D10Status from the player
DFPlayer SPK1 and SPK2SpeakerAudio output
DS3231 VCC and GNDNano 5V and GNDPower
DS3231 SDA and SCLNano A4 and A5I2C
ButtonNano D2 and GNDConfirm the dose

Code

This is a reminder aid and not a medical device. It does not know whether a pill was taken and it must not replace advice from a doctor or a pharmacist, so check with a caregiver for important medicines. Record short voice clips (for example "Morning tablet, one white tablet") with a phone, save them as 0001.mp3, 0002.mp3 and so on on a FAT32 card, and set the times in the DOSES list; set the RTC once using a library example. The 1 kΩ resistor on the DFPlayer RX line cuts the noise from the 5 V serial signal. If the volume is too low, raise player.volume up to 30. Keep the pill box and the speaker where the person can find them by touch. Arduino IDE, board "Arduino Nano" (processor ATmega328P, or ATmega328P (Old Bootloader) for clones).

Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

// Libraries: DFRobotDFPlayerMini, RTClib (Adafruit). SD card files: 0001.mp3, 0002.mp3 ...
#include <SoftwareSerial.h>
#include <DFRobotDFPlayerMini.h>
#include <Wire.h>
#include <RTClib.h>

SoftwareSerial pSerial(10, 11);     // RX, TX
DFRobotDFPlayerMini player;
RTC_DS3231 rtc;

struct Dose { byte hour; byte minute; byte track; };
const Dose DOSES[] = { {8, 0, 1}, {14, 0, 2}, {21, 0, 3} };   // track 1 = "Morning tablet", and so on
const byte N = sizeof(DOSES) / sizeof(DOSES[0]);
const byte BTN = 2;

bool pending[N];
byte lastDay = 255;
unsigned long lastPlay[N];
byte repeats[N];

void setup() {
  Serial.begin(9600);
  pSerial.begin(9600);
  pinMode(BTN, INPUT_PULLUP);
  rtc.begin();
  if (!player.begin(pSerial)) { Serial.println("DFPlayer not found, check the card and wiring"); while (1) {} }
  player.volume(20);
}

void loop() {
  DateTime now = rtc.now();
  if (now.day() != lastDay) { lastDay = now.day(); for (byte i = 0; i < N; i++) { pending[i] = false; repeats[i] = 0; } }

  for (byte i = 0; i < N; i++) {
    if (now.hour() == DOSES[i].hour && now.minute() == DOSES[i].minute && !pending[i] && repeats[i] == 0) {
      pending[i] = true; repeats[i] = 1; lastPlay[i] = millis();
      player.play(DOSES[i].track);
    }
    if (pending[i] && repeats[i] < 4 && millis() - lastPlay[i] > 5UL * 60000UL) {    // repeat every 5 minutes, up to 3 more times
      repeats[i]++; lastPlay[i] = millis(); player.play(DOSES[i].track);
    }
  }
  if (digitalRead(BTN) == LOW) {                    // pressing the button confirms every pending dose
    for (byte i = 0; i < N; i++) pending[i] = false;
    player.stop();
    delay(300);
  }
}

What the serial monitor should show

Open the serial monitor at the baud rate in the code. This is what our simulator prints for a virtual Arduino Nano with its sensors at their default values. Your numbers will follow your real readings, but the format should match.

DFPlayer not found, check the card and wiring

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
At a dose timeThe clip plays
Button pressedClip stops and no repeats
IgnoredRepeats every five minutes up to three more times
Next dayDoses are reset

If it does not work

DFPlayer not found

Check the card format, files and the TX and RX wiring.

No sound

Check the speaker wiring and the volume.

Clicks and noise

Add the 1 kΩ resistor and keep the speaker wires away from the signal.

Wrong time

Set the RTC again.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the talking pill reminder?

Arduino Nano, DFPlayer Mini MP3 module, Speaker 8 Ω 0.5 W, SanDisk microSD card 32 GB (A1, Class 10), DS3231 RTC module, Tactile push button 6 mm and Resistor 1 kΩ.

How long does the talking pill reminder take to build?

About 120 minutes for a beginner maker, in 8 steps.

How do I know the talking pill reminder works?

At a dose time: The clip plays. Button pressed: Clip stops and no repeats. Ignored: Repeats every five minutes up to three more times.

DFPlayer not found: what should I check?

Check the card format, files and the TX and RX wiring.

No sound: what should I check?

Check the speaker wiring and the volume.

Clicks and noise: what should I check?

Add the 1 kΩ resistor and keep the speaker wires away from the signal.

Wrong time: what should I check?

Set the RTC again.