Gayathri Krishnan
Published © GPL3+

Voice Based Drug Alert System Using RTC and DF mini player

A voice-based smart drug reminder that helps users take their medications accurately and on schedule.

BeginnerWork in progress3 hours86
Voice Based Drug Alert System Using RTC and DF mini player

Things used in this project

Story

Read more

Schematics

df_miniplayer_G8p8V0mtuW.pdf

Code

VOICE BASED DRUG ALERT SYSTEM USING RTC AND DFMINI PLAYER

C/C++
while using DF mini player 1) use standard microSD card(2GB-32GB)
,2) card must be formatted as FAT16 or FAT32
3)only MP3 or WAV files are supported , keep the file names simple
in this project audio file 4 is " take thyronorm on empty stomach" ,audio file 2 is same instruction recorded in malayalam (local language spoken in Kerala) ( Thyronorm is a medication given for hypothyroidism)
#include<RTClib.h>       install RTC library     
#include<Wire.h>          for I2C communication with RTC
RTC_DS3231 rtc;
# include <SoftwareSerial.h>   install SoftwareSerial for additional Serial ports
# include <DFRobotDFPlayerMini.h>  install DFPlayerMini library
SoftwareSerial mySerial(10,11);  create a software Serial port using pin10 and 11
DFRobotDFPlayerMini myDFPlayer;
bool alarmStopped=false;
bool alarmTriggered=false;
bool lastButtonState=HIGH;
bool currentButtonState=HIGH;
bool alternateFlag= false;
int buttonpin=6;
int busypin=12;

void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
pinMode(buttonpin,INPUT_PULLUP);
mySerial.begin(9600);
if(!myDFPlayer.begin(mySerial)){
  Serial.print("error detected");
  while(true);
}
myDFPlayer.volume(30);    setting the volume of DFPlayer

if(!rtc.begin()){
  Serial.print("no rtc found");
  while(1);
}
if(rtc.lostPower()){
  Serial.print("rtc lost power");
  rtc.adjust(DateTime(F(__DATE__),F(__TIME__)));
}
}
void loop() {
  // put your main code here, to run repeatedly:
DateTime now=rtc.now();



if (now.hour() == 6 && now.minute() ==0 ) {
    alarmTriggered = true;             setting the alarm time
  }

 currentButtonState = digitalRead(buttonpin);

if (currentButtonState == LOW && lastButtonState == HIGH) { 
 myDFPlayer.stop();
 alarmStopped = true;
alarmTriggered = false;
Serial.println("Alarm permanently stopped");  when button pressed-DFPlayer stops
}
lastButtonState = currentButtonState;

if (alarmTriggered && !alarmStopped) {
    if (digitalRead(busypin) == HIGH) {
    if (alternateFlag) myDFPlayer.play(2);
    else myDFPlayer.play(4);
    alternateFlag = !alternateFlag;                alternating 2 and 4
    }
}
}

Credits

Gayathri Krishnan
4 projects • 0 followers
I’m an MBBS doctor who has always been interested in physics, which led me into Arduino projects. I’ve been building for about three months

Comments