Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
  • Women in Engineering

Arduino Based Medicine Reminder System

By Praveen Kumar, Chennai, India

A lot of people have to take certain medicines regularly. A number of diseases like diabetes, blood pressure or heart problem are nowadays very common and the patients need to take medicines without break to keep such health issues in check. Most of the people are not punctual about taking medicines and often forget one or the other dosage. In this project, a medicine reminder system is designed in which the user can feed the schedule of their medicines and the system alerts them by sending SMS on their mobile if they miss taking a dosage. The user has to feed the type of medicine, its dosage, After or Before Food reminder, doctors name and time of the dosage in the system.
 
The user can feed multiple entries like this. When there will be time for taking a dosage, the user will have to take prescribed medicine and press a button on the projecting device confirming that the dosage has been taken. In case, the user does not take the dosage and forget to confirm on the projecting device, after 2 minutes of delay from the dosage timing, the system sends an SMS alert to the user reminding him of taking the medicine. 
 
The user can feed the type of medicine as a tablet, capsule or Syrup, dosage as half, one or two capsule/tablet/spoon, After food or before food setting, doctor name as doc-A, doc-B, doc-C and so on and dosage timing as Morning, Afternoon and Night. The morning time is assumed to be 9 AM, Afternoon time is assumed to be 12 PM and Night time is assumed to be 9 PM. 
 
The project is built on Arduino Mega and has an RTC interfaced to keep track of time without fail. The medicine information is saved in the internal EEPROM of the Arduino board. A four-switch keypad is provided to feed medicine information and an LCD display is interfaced to the system for providing the user interface. A GSM-GPRS module is interfaced to send SMS alerts and a series of LEDs is connected to the system for the testing purpose. The Arduino sketch manages to input and store medicine information, keep track of time using RTC, compare dosage time with real time, track confirmation of dosage taken and send SMS alert if dosage taken is not confirmed by the user. The Arduino code is written on Arduino IDE and burnt to the board using AVR Dude. 

Components Required – 

• Arduino Mega2560 -1pc
• 12v-1amp step down transformer
• 7805 and 7812 voltage regulator.
• IN4007 diode
• 25v 4700uF Capacitor. 
• Tiny RTC module-DC1307-1pc
• 16×2 LCD-1pc.
• RGB led- 6pcs.
• 1K ohm resistors -3pcs
• Push to ON switch-4pcs
• Toggle switch.
• Voltage regulator -7805 and 7812
• GSM/GPRS module
• A box to store medicines

Block Diagram – 

Block Diagram of Arduino based Medicine SMS Reminder System
                               Fig. 1: Block Diagram of Arduino based Medicine SMS Reminder System             

Circuit Connections – 

Prototype of Arduino based Medicine SMS Reminder System

Fig. 2: Prototype of Arduino based Medicine SMS Reminder System

The Arduino Mega controls the projecting device. Different components and modules are interfaced to the Arduino board in the following manner – 
 
Power Supply – In the circuit, Arduino board, LCD module, and RTC need a 5V regulated DC while GSM/GPRS module needs 12V regulated DC for its operation. The AC mains is used as the primary source of power. The supply from the mains is stepped down by a transformer and rectified by a full-bridge rectifier. The rectified output is regulated to 5V and 12V using 7805 and 7812 ICs. The pin 1 of both the voltage regulator ICs is connected to the anode of the battery and pin 2 of both ICs is connected to ground. The respective voltage outputs are drawn from pin 3 of the respective voltage regulator ICs. A LED along with a 10K Ω pull-up resistor is also connected between common ground and output pin to get a visual hint of supply continuity.  
 
16X2 LCD: The 16X2 LCD display is used to the user interface for feeding and displaying medicine information. It is connected to the Arduino board by connecting its data pins to pins 3 to 6 of the Arduino board. The RS and E pins of the LCD are connected to pins 13 and 12 of the Arduino UNO respectively. The RW pin of the LCD is grounded.
 
Table listing circuit connections between Arduino Uno and Character LCD
 
Fig. 3: Table listing circuit connections between Arduino Uno and Character LCD
 
The standard open-source library for interfacing LCD with Arduino Mega is used in the project. The library works as expected and needs no changes or modifications. 
RTC DS1307 – The RTC DS1307 has a built-in button cell that allows keeping track of real-time irrespective of the power supply. For interfacing with the Arduino board, SDA and SCL pins of the RTC are connected to the SDA (20) and SCA (21) pins of the Arduino Mega. The RTC module transfers the time and date information through serial communication updating the info in real-time. 
 
5-switch keypad – The keys are used for navigating and selecting medicine information and confirmation of dosage taken. There are five switches connected to A0, A1, A2, A3 and A4 pins of the Arduino board through 1K ohm pull-up resistors. The switches connected at A0, A1, A2 and A3 pins works as */Start, Next, Save and #/Exit buttons respectively. In the circuit diagram, Start, Next, Save and #/Exit buttons are designated by SW1, SW2, SW3 and SW4 labels. When the user has to start feeding information of a medicine, he has to press */Start to initiate the process, then the user can navigate through the available options of one of the five steps by pressing Next button. On pressing the Save button, selected option in the current step is saved to internal EEPROM.
The user has to pass through five step process for each medicine in which he has to feed the following information in each step – 
 
Step 1: Type of Medicine – Capsule, Tablet or Syrup
Step 2: Dosage Amount – half, one or two
Step 3: Recommendation – After Food or Before Food
Step 4: Doctor Name – Doc-A, Doc-B or Doc-C
Step 5: Timing – Morning (9 AM), Afternoon (12 PM) or Night (9 PM)
 
The user can initiate the process for another medicine by pressing the */Start switch again. Once the information of all the medicines is saved, the user needs to press # button to start getting reminders. 
 
The fifth switch connected at A4 should be pressed for confirmation of the dosage taken. 
 
GSM/GPRS MODULE: Here Arduino Mega is using TX1 and RX1 from its three USART ports. Vcc and ground are provided with the external power supply of 12V, 2 Amp and common ground. The Tx terminal of GSM module is connected to the pin 19 (RX1) of Arduino Mega and its Rx terminal is connected to the pin 18 (TX1) of Arduino mega. 

How the circuit works – 

Image of Arduino based Medicine SMS Reminder System

Fig. 4: Image of Arduino based Medicine SMS Reminder System

The Arduino board loads the required libraries as it is powered on. It waits for the user to feed the medicine information. The user can feed the information of each medicine in the five-step process. As the user presses the Save button after every 5-step wizard, the information of the respective medicine is saved to the internal EEPROM of the Arduino board. Once the user presses the #/Exit button, the Arduino board starts fetching real-time from RTC module and compare the dosage timing of the medicines with real time. At three instants of time – morning (9 AM), afternoon (12 PM) and night (9 PM), the Arduino seeks the confirmation of dosage taken by detecting the press of the confirmation button by the user. If the user does not press the button, after a delay of 2 minutes, the board sends an SMS through the GSM module to the registered mobile number of the user.
 
Check out the program code to learn how the Arduino board manages to input and store medicine information, keep track of time using RTC, compare dosage time with real time, track confirmation of dosage taken and send SMS alert if dosage taken is not confirmed by the user. 

Programming Guide – 

The Arduino sketch loads the Wire.h for I2C communication with the GSM module, EEPROM.h for storing and retrieving data from internal EEPROM, RTClib.h for handling RTC module, LiquidCrystal.h for LCD interfacing and SoftwareSerial.h for virtual serial communication with the LCD module. An object of liquid crystal type is declared and mapped to Arduino pins and an object of RTC type is declared and assigned Arduino pin. The variables and arrays are declared to keep track of the step number of the medicine input wizard, EEPROM addresses, SMS string and store medicine information along with some counter variables. 
 
Screenshot of Initialization in Arduino Code for Medicine SMS Reminder System
 
Fig. 5: Screenshot of Initialization in Arduino Code for Medicine SMS Reminder System
 
The setup() function is called in which baud rate for serial communication with LCD module and GSM module is set to 9600 bits per second and AT command to set text mode for GSM module is sent. The LED pins are set digital output and pins connecting to switches are set to digital input. The I2C interface, LCD, and RTC are initialized and initial messages are printed on the LCD. The RTC is checked if running and the date-time information is saved to the RTC.
         
Screenshot of Setup Function in Arduino Code for Medicine SMS Reminder System
 
Fig. 6: Screenshot of Setup Function in Arduino Code for Medicine SMS Reminder System
 
The loop() function is called in which the user input is checked by detecting LOW at the switches and according the wizard for entering medicine information is progressed by keeping trace of variable pos. The information is saved to internal EEPROM and compared with RTC time to frame and send SMS alert on not detecting press of the confirmation button.  
 
Screenshot of Infinite Loop in Arduino Code for Medicine SMS Reminder System
 
Fig. 7: Screenshot of Infinite Loop in Arduino Code for Medicine SMS Reminder System
 
You would find the code for Arduino Based Medicine Reminder System in the source code tab.      

Project Source Code

###

//Program to 


#include <Wire.h>

#include<EEPROM.h>

#include <RTClib.h>

#include <LiquidCrystal.h>

#include <SoftwareSerial.h>

LiquidCrystal lcd(13, 12, 6, 5, 4, 3);// Pins used for RS,E,D4,D5,D6,D7

RTC_DS1307 RTC;

int pos=50,noEntry=1,addr=1,addrA=1,af=0,bf=0,addrFT1,addrFT2,addrFT3,addrFT4;

int i=0,fondB=0,fondL=0,fondD=0,j=0,k=1,l=5,addrAM=50,addrPM=60;

int breakF=9,lunchT=2,dinnerT=9,trigSMS=0,loc=0;

int Abrkfast[10],Alunch[10],Adinner[10];

int curntSec,curntHour,curntMinute,prevTime;

int am=0,pm=0,currntTZ=0,addrs=0;

int lastMinute,count=0,num1,num2,TWHOUR=0,HOUR=0,MINUT=0,SECOND=0;//Variable to store phone number and current time 

char daysOfTheWeek[7][12] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

char* doctor[]= {"Doc-A", "Doc-B", "Doc-C", "Doc-D", "Doc-E", "Doc-E", "Doc-F", "Doc-G"};

char* mediType[]={"TAB", "CAP", "SYR"};

char* dailydos[]={".5","1","2","3"};

char* dosTime[]={"BFS","LUN","DIN"};

char* afbf[]={"A/F","B/F"};

int b1 = 22;      // LED define 1 at pin22

int b2 = 24;      // LED define 2 at pin24                             

int b3 = 26;      // LED define 3 at pin28  

int b4 = 28;      // LED define 4 at pin30

int b5 = 30;      // LED define 5 at pin32   

int b6 = 32;      // LED define 6 at pin34  


byte Aalpha[8] ={ 0b00000,

                   0b01110,

                   0b10001,

                   0b11111,

                   0b10001,

                   0b10001,

                   0b00000,

                   0b00000

                   };

 byte Balpha[8]={ 0b00000,

                    0b11100,

                    0b10010,

                    0b11100,

                    0b10010,

                    0b11100,

                    0b00000,

                    0b00000};

  byte Calpha[8]={   0b00000,

                     0b01110,

                     0b10000,

                     0b10000,

                     0b10000,

                     0b01110,

                     0b00000,

                     0b00000};                   

 byte Dalpha[8] ={ 0b00000,

                   0b11100,

                   0b10010,

                   0b10010,

                   0b10010,

                   0b11100,

                   0b00000,

                   0b00000};

  byte Ealpha[8] ={0b00000,

                   0b11110,

                   0b10000,

                   0b11100,

                   0b10000,

                   0b11110,

                   0b00000,

                   0b00000}; 

  byte Falpha[8] ={0b00000,

                   0b11110,

                   0b10000,

                   0b11100,

                   0b10000,

                   0b10000,

                   0b00000,

                   0b00000};

    byte Galpha[8]={0b00000,

                    0b01110,

                    0b10000,

                    0b10110,

                    0b10010,

                    0b01110,

                    0b00000,

                    0b00000};

   byte Halpha[8] ={ 0b00000,

                   0b10001,

                   0b10001,

                   0b11111,

                   0b10001,

                   0b10001,

                   0b00000,

                   0b00000};  

   byte Ialpha[8]={0b00000,

                     0b01110,

                     0b00100,

                     0b00100,

                     0b00100,

                     0b01110,

                     0b00000,

                     0b00000}; 

    byte Lalpha[8]={ 0b00000,

                     0b10000,

                     0b10000,

                     0b10000,

                     0b10000,

                     0b11110,

                     0b00000,

                     0b00000}; 

   byte Malpha[8] ={ 0b00000,

                    0b10001,

                   0b11011,

                   0b10101,

                   0b10001,

                   0b10001,

                   0b00000,

                   0b00000};                                                                         

   byte Nalpha[8] ={0b00000,

                    0b10001,

                   0b11001,

                   0b10101,

                   0b10011,

                   0b10001,

                   0b00000,

                   0b00000};     

   byte Oalpha[8]={ 0b00000,

                     0b01110,

                     0b10001,

                     0b10001,

                     0b10001,

                     0b01110,

                     0b00000,

                     0b00000}; 

 byte Palpha[8]={  0b00000,

                      0b11100,

                     0b10010,

                     0b11100,

                     0b10000,

                     0b10000,

                     0b00000,

                     0b00000};      

 byte Ralpha[8]={    0b00000,

                     0b11110,

                     0b10001,

                     0b11110,

                     0b10100,

                     0b10010,

                     0b00000,

                     0b00000};                                    

 byte Salpha[8] ={ 0b00000,

                   0b01110,

                   0b10000,

                   0b01110,

                   0b00001,

                   0b01110,

                   0b00000,

                   0b00000}; 

   byte Talpha[8] ={0b00000,

                    0b11111,

                   0b00100,

                   0b00100,

                   0b00100,

                   0b00100,

                   0b00000,

                   0b00000};  

                                        

  byte Ualpha[8]={   0b00000,

                     0b10001,

                     0b10001,

                     0b10001,

                     0b10001,

                     0b01110,

                     0b00000,

                     0b00000};    

  byte Walpha[8] ={  0b00000,

                     0b10001,

                     0b10001,

                     0b10101,

                     0b11011,

                     0b10001,

                     0b00000,

                     0b00000};

   byte Yalpha[8]={  0b00000,

                     0b10001,

                     0b10001,

                     0b01010,

                     0b00100,

                     0b00100,

                     0b00000,

                     0b00000};


                     

void setup() {

  Serial1.begin(9600);   // Setting the baud rate of GSM Module  

  Serial.begin(9600);    // Setting the baud rate of Serial Monitor (Arduino)

  Serial.println( "AT+CMGF=1" ); delay(200);

  pinMode(b1, OUTPUT);

  pinMode(b2, OUTPUT);

  pinMode(b3, OUTPUT);

  pinMode(b4, OUTPUT);

  pinMode(b5, OUTPUT);

  pinMode(b6, OUTPUT);

  

  Wire.begin();

  RTC.begin();

  lcd.begin(16,2);

  lcd.setCursor(0,0);

  lcd.print("Engineers Garage");  

  lcd.setCursor(0,1);

  lcd.print(" MEDI Reminder  ");

  delay(3000);lcd.clear();delay(200);

  lcd.setCursor(0,0);

  lcd.print(" ENTER ALL INFO ");

  lcd.setCursor(0,1);

  lcd.print(" YES*       NO# ");

 if(!RTC.isrunning())

 {

 RTC.adjust(DateTime(F(__DATE__), F(__TIME__)));

 } 

}


void loop() { 

if(digitalRead(A0)==LOW && pos==50){ //This is for YES jump to the start while(pos==0)

    pos=1;

    lcd.clear();

    delay(200);

    lcd.setCursor(0,0);

    lcd.print("Wait...");   

    for(i=0;i<200;i++){

      EEPROM.write(i, 255);

      delay(100);

        lcd.setCursor(6,1);

        lcd.print(i);

    }

  }

  if(digitalRead(A3)==LOW && pos==50){//This id for NO jump to the end while(pos==50)

    pos=30;

    lcd.clear();

  } 

    while(pos==1){

      lcd.setCursor(0,0);

      lcd.print("Set Medicine Typ");       

 if(digitalRead(A0)==LOW && pos==1){

    if(k<4){

      k++;

      lcd.setCursor(6,1);

      lcd.print("          ");

      delay(400);

    }}

    if(k==3){

      k=0;}

    lcd.setCursor(6,1);

    lcd.print(mediType[k]);

  if(digitalRead(A1)==LOW && pos==1){

      EEPROM.write(addrA,k);

      delay(500);

      addrA++;

      lcd.setCursor(15,1);

      lcd.print("*");

      pos=2;

      k=0;

      delay(2000);

      lcd.setCursor(0,0);

      lcd.print("                ");

      lcd.setCursor(6,1);

      lcd.print("               ");

      break;  

    }  }//End of pos=1

    

 while(pos==2){

      lcd.setCursor(0,0);

      lcd.print("   Set Dosage  "); 

 if(digitalRead(A0)==LOW && pos==2){

    if(k<4){

      k++;

      lcd.setCursor(6,1);

      lcd.print("                 ");

      delay(400);

    }}

  if(k==3){

      k=0;}

    lcd.setCursor(6,1);

    lcd.print(dailydos[k]);  

 if(digitalRead(A1)==LOW && pos==2){

      EEPROM.write(addrA,k);

      delay(500);

      addrA++;

      lcd.setCursor(15,1);

      lcd.print("*");

      pos=3;

      k=0;

      delay(2000);

      lcd.setCursor(0,0);

      lcd.print("                ");

      lcd.setCursor(6,1);

      lcd.print("                ");

      break;  

    }  }//End of pos=2

while(pos==3){

      lcd.setCursor(0,0);

      lcd.print(" Set A/F or B/F "); 

 if(digitalRead(A0)==LOW && pos==3){

    if(k<3){

      k++;

      lcd.setCursor(6,1);

      lcd.print("          ");

      delay(400);

    }}

  if(k==2){

      k=0;}

    lcd.setCursor(6,1);

    lcd.print(afbf[k]);  

 if(digitalRead(A1)==LOW && pos==3){

      EEPROM.write(addrA,k);

      delay(500);

      addrA++;

      lcd.setCursor(15,1);

      lcd.print("*");

      pos=4;

      k=0;

      delay(2000);

      lcd.setCursor(0,0);

      lcd.print("                ");

      lcd.setCursor(6,1);

      lcd.print("                ");

      break;  

    }}//End of pos=3

while(pos==4){

      lcd.setCursor(0,0);

      lcd.print("   Set Doctor   "); 

 if(digitalRead(A0)==LOW && pos==4){

    if(k<5){

       k++;

      lcd.setCursor(6,1);

      lcd.print("          ");

      delay(400);

    }}

  if(k==4){

      k=0;}

   lcd.setCursor(6,1);

   lcd.print(doctor[k]);   

 if(digitalRead(A1)==LOW && pos==4){

      EEPROM.write(addrA,k);

      delay(500);

      addrA++;

      lcd.setCursor(15,1);

      lcd.print("*");

      pos=5;

      k=0;

      delay(2000);

      lcd.setCursor(0,0);

      lcd.print("                ");

      lcd.setCursor(6,1);

      lcd.print("                ");

      break;  

    }}//End of pos=5

    

while(pos==5){

      lcd.setCursor(0,0);

      lcd.print(" Set Dose Time  "); 

 if(digitalRead(A0)==LOW && pos==5){

    if(k<4){

      k++;

      lcd.setCursor(6,1);

      lcd.print("          ");

      delay(400);

    }}

  if(k==3){

      k=0;}

    lcd.setCursor(6,1);

    lcd.print(dosTime[k]);

  if(digitalRead(A1)==LOW && pos==5){

      lcd.setCursor(15,1);

      lcd.print("*");

      EEPROM.write(addrA,k);

      delay(500);

      addrA++;

      lcd.setCursor(15,1);

      lcd.print("*");

      delay(2000);

      lcd.setCursor(0,0);

      lcd.print("                ");

      lcd.setCursor(9,1);

      lcd.print("          ");

      }

  if(digitalRead(A2)==LOW && pos==5){

    i=i;

    pos=1;

    k=0;

    noEntry++;

    delay(2000);

    lcd.setCursor(0,0);

    lcd.print("                ");

    lcd.setCursor(9,1);

    lcd.print("          ");

    EEPROM.write(100,noEntry);

    break;   

  }

  if(digitalRead(A3)==LOW && pos==5){

    lcd.clear();

    pos=30;

    delay(2000);

    break; 

    }

}//End of pos=4

while(pos==30){

    lcd.clear();

while(1){

  lcd.setCursor(0,0);

  lcd.print("Have A Nice");

  lcd.setCursor(0,1);

  lcd.print("Day:)");

 DateTime now =RTC.now();

 curntHour=now.hour();

 curntHour=((curntHour > 12) ? curntHour - 12 : ((curntHour == 0) ? 12 : curntHour));

 curntMinute=now.minute();

 curntSec=now.second();    

 currentTIME();

 matchTIM();

 Serial.println(currntTZ);

 Serial.println(curntHour);

 Serial.println(curntMinute);

 ALLDays(now.dayOfTheWeek());


} 

  }

  }

/*

char* doctor[]= {"Doc-A", "Doc-B", "Doc-C", "Doc-D", "Doc-E", "Doc-F", "Doc-G", "Doc-H", "Doc-I"};

char* mediType[]={"Tablet", "Capsule", "Syrup"};

char* dailydos[]={"Half","One","Two","Three"};

char* dosTime[]={"BRKFAST","LUNCH","DINNER"};

char* afbf[]={"A/F","B/F"};

// breakF=8,lunchT=12,dinnerT=9;*/

void matchTIM(){

  Serial.println("Match");

  DateTime now =RTC.now();

  curntHour=now.hour();

  curntHour=((curntHour > 12) ? curntHour - 12 : ((curntHour == 0) ? 12 : curntHour));

  curntMinute=now.minute();

  curntSec=now.second();   

   /* Break Fast Setting*/

 if(curntHour==breakF && curntMinute==0 && curntSec<=2 && currntTZ==2){

   trigSMS=0;

   pos=10;

  addrFT1=EEPROM.read(100);

  lcd.clear();

  while(pos==10){

     for(i=0;i<addrFT1+1;){

         num1=EEPROM.read(l);

         if(num1==0){

          Abrkfast[i]=l;

          EEPROM.write(100+k, i);

          fondB++;

          k++;

         }

          l=l+5;

          i++;

          Serial.println(i);

          delay(500);

    if(i==addrFT1){

      pos=11;

      break;

    }

   }

  }

 if(fondB==0){

        k=1;

        l=5;

        pos=11;

        Serial.print("Not Found");

        delay(50);

             }

 if(fondB>=1 && pos==11){

           DateTime now =RTC.now();

           prevTime=now.minute();

      while(pos==11){

        Serial.println("Found");

        pos=12;   

        while(pos=12){

          DateTime now =RTC.now();

           curntHour=now.hour();

           curntMinute=now.minute();

           //curntSec=now.second();

          if(curntMinute== prevTime + 2){

            medicineAlertSMS();

            k=1;

              l=5;

             pos=30;

             delay(500);

             break; 

          }

          if(digitalRead(A0)==LOW && pos==12){

            k=1;

            l=5;

             pos=30;

             delay(500);

             break;

          } 

         for(j=1;j<fondB+1; j++){

            currentTIME();

            ALLDays(now.dayOfTheWeek());

            num2=EEPROM.read(100+j);

            Serial.print(100+j); 

            Serial.print(num2); 

            Serial.print(Abrkfast[num2]);

            Serial.println(EEPROM.read(Abrkfast[num2]-2));

            delay(100);

            if(EEPROM.read(Abrkfast[num2]-2)==0){

              digitalWrite(b1,LOW);

            }

            if(EEPROM.read(Abrkfast[num2]-2)==1){

             digitalWrite(b2,HIGH); 

            }

            lcd.setCursor(0,0);

            lcd.print(mediType[EEPROM.read(Abrkfast[num2]-4)]);

            lcd.setCursor(4,0);

            lcd.print(dailydos[EEPROM.read(Abrkfast[num2]-3)]);

            lcd.setCursor(6,0);

            lcd.print(afbf[EEPROM.read(Abrkfast[num2]-2)]);

            lcd.setCursor(10,0);

            lcd.print(dosTime[EEPROM.read(Abrkfast[num2])]);

            lcd.setCursor(0,1);

            lcd.print(doctor[EEPROM.read(Abrkfast[num2]-1)]);

            delay(1000);

            digitalWrite(b1,LOW);

            digitalWrite(b2,LOW);

            lcd.clear();

         }

         if(j==fondB+1 && pos==12){

         j=1;

         pos=13;

         delay(50);

         break;

         }

         

        }

        while(pos==13){

          if(digitalRead(A4)==LOW && trigSMS==0){

            Serial.println("Sending SMS");

            Serial1.println("AT+CMGF=1");    //Sets the GSM Module in Text Mode

            delay(100);  // Delay of 100 milli seconds delay

            Serial1.println("AT+CMGS="+918973760860"r");

            delay(100);

            Serial1.print("Alert !!! It's Time To Take Medicine");// The SMS text you want to send

            delay(100);

            Serial1.print("n");// The SMS text you want to send

            delay(100);

            for(j=1;j<fondB+1; j++){

                num2=EEPROM.read(100+j);   

                Serial1.print(mediType[EEPROM.read(Abrkfast[num2]-4)]);

                Serial1.print("- ");

                delay(100);

                Serial1.print(dailydos[EEPROM.read(Abrkfast[num2]-3)]);

                Serial1.print("  ");

                delay(100);

                Serial1.print(afbf[EEPROM.read(Abrkfast[num2]-2)]);

                Serial1.print("  ");

                delay(100);

                Serial1.print(dosTime[EEPROM.read(Abrkfast[num2])]);

                Serial1.print(" Doctor: ");

                delay(100);

                Serial1.print(doctor[EEPROM.read(Abrkfast[num2]-1)]);

                Serial1.print("n");

                delay(100);

              }

             if(j==fondB+1 && trigSMS==0){

                 Serial1.println(" ");

                 delay(100);

                 Serial1.println((char)26);// ASCII code of CTRL+Z

                 delay(100);

                 Serial.println("SMS Sent");

                 j=1;

                 pos=11;

                 trigSMS=1;

                 delay(50);

                 break;

                }

             }    

        else{

          j=1;

          pos=11;

          trigSMS=1;

          delay(50);

          break;

          } 

        } 

  }

  }

}

/*LUNCH  breakF=8,lunchT=12,dinnerT=9;*/

if(curntHour==lunchT && curntMinute==14 && curntSec<=2 && currntTZ==2){

   trigSMS=0;

   pos=10;

  addrFT1=EEPROM.read(100);

  lcd.clear();

  while(pos==10){

     for(i=0;i<addrFT1+1;){

         num1=EEPROM.read(l);

         if(num1==1){

          Abrkfast[i]=l;

          EEPROM.write(100+k, i);

          fondL++;

          k++;

         }

          l=l+5;

          i++;

          Serial.println(i);

          delay(500);

    if(i==addrFT1){

      pos=11;

      break;

    }

   }

  }

 if(fondL==0){

        k=1;

        l=5;

        pos=11;

        Serial.print("Not Found");

        delay(50);

             }

 if(fondL>=1 && pos==11){

           DateTime now =RTC.now();

           prevTime=now.minute();

      while(pos==11){

        Serial.println("Found");

        pos=12;   

        while(pos=12){

          DateTime now =RTC.now();

           curntHour=now.hour();

           curntMinute=now.minute();

           //curntSec=now.second();

          if(curntMinute== prevTime + 2){

              medicineAlertSMS();

              k=1;

              l=5;

             pos=30;

             delay(500);

             break; 

          }

          if(digitalRead(A0)==LOW && pos==12){

              l=5;

              k=1;

             pos=30;

             delay(500);

             break;

          } 

         for(j=1;j<fondL+1; j++){

            currentTIME();

            ALLDays(now.dayOfTheWeek());

            num2=EEPROM.read(100+j);

            Serial.print(100+j); 

            Serial.print(num2); 

            Serial.print(Abrkfast[num2]);

            Serial.println(EEPROM.read(Abrkfast[num2]-2));

            delay(100);

            if(EEPROM.read(Abrkfast[num2]-2)==0){

              digitalWrite(b3,HIGH);

            }

            if(EEPROM.read(Abrkfast[num2]-2)==1){

             digitalWrite(b4,HIGH); 

            }

            lcd.setCursor(0,0);

            lcd.print(mediType[EEPROM.read(Abrkfast[num2]-4)]);

            lcd.setCursor(4,0);

            lcd.print(dailydos[EEPROM.read(Abrkfast[num2]-3)]);

            lcd.setCursor(6,0);

            lcd.print(afbf[EEPROM.read(Abrkfast[num2]-2)]);

            lcd.setCursor(10,0);

            lcd.print(dosTime[EEPROM.read(Abrkfast[num2])]);

            lcd.setCursor(0,1);

            lcd.print(doctor[EEPROM.read(Abrkfast[num2]-1)]);

            delay(1000);

            digitalWrite(b3,LOW);

            digitalWrite(b4,LOW);

            lcd.clear();

         }

         if(j==fondL+1 && pos==12){

         j=1;

         pos=13;

         delay(50);

         break;

         }

         

        }

        while(pos==13){

          if(digitalRead(A4)==LOW && trigSMS==0){

            Serial.println("Sending SMS");

            Serial1.println("AT+CMGF=1");    //Sets the GSM Module in Text Mode

            delay(100);  // Delay of 100 milli seconds delay

            Serial1.println("AT+CMGS="+918973760860"r");//9001931333my 7357187588

            delay(100);

            Serial1.print("Alert !!! It's Time To Take Medicine");// The SMS text you want to send

            delay(100);

            Serial1.print("n");// The SMS text you want to send

            delay(100);

            for(j=1;j<fondL+1; j++){

                num2=EEPROM.read(100+j);   

                Serial1.print(mediType[EEPROM.read(Abrkfast[num2]-4)]);

                Serial1.print("- ");

                delay(100);

                Serial1.print(dailydos[EEPROM.read(Abrkfast[num2]-3)]);

                Serial1.print("  ");

                delay(100);

                Serial1.print(afbf[EEPROM.read(Abrkfast[num2]-2)]);

                Serial1.print("  ");

                delay(100);

                Serial1.print(dosTime[EEPROM.read(Abrkfast[num2])]);

                Serial1.print(" Doctor: ");

                delay(100);

                Serial1.print(doctor[EEPROM.read(Abrkfast[num2]-1)]);

                Serial1.print("n");

                delay(100);

              }

             if(j==fondL+1 && trigSMS==0){

                 Serial1.println(" ");

                 delay(100);

                 Serial1.println((char)26);// ASCII code of CTRL+Z

                 delay(100);

                 Serial.println("SMS Sent");

                 j=1;

                 pos=11;

                 trigSMS=1;

                 delay(50);

                 break;

                }

             }    

        else{

          j=1;

          pos=11;

          trigSMS=1;

          delay(50);

          break;

          } 

        } 

  }

  }

}

/*DINNER breakF=8,lunchT=12,dinnerT=9;*/

if(curntHour==dinnerT && curntMinute==0 && curntSec<=2 && currntTZ==2){

  trigSMS=0;

  pos=10;

  addrFT1=EEPROM.read(100);

  lcd.clear();

  while(pos==10){

     for(i=0;i<addrFT1+1;){

         num1=EEPROM.read(l);

         if(num1==2){

          Abrkfast[i]=l;

          EEPROM.write(100+k, i);

          fondD++;

          k++;

         }

          l=l+5;

          i++;

          Serial.println(i);

          delay(500);

    if(i==addrFT1){

      pos=11;

      break;

    }

   }

  }

 if(fondD==0){

        k=1;

        l=5;

        pos=11;

        Serial.print("Not Found");

        delay(50);

             }

 if(fondD>=1 && pos==11){

           DateTime now =RTC.now();

           prevTime=now.minute();

      while(pos==11){

        Serial.println("Found");

        pos=12;   

        while(pos=12){

          DateTime now =RTC.now();

           curntHour=now.hour();

           curntMinute=now.minute();

           //curntSec=now.second();

          if(curntMinute== prevTime + 2){

            medicineAlertSMS();

            l=5;

            k=1;

             pos=30;

             delay(500);

             break; 

          }

          if(digitalRead(A0)==LOW && pos==12){

            l=5;

            k=1;

             pos=30;

             delay(500);

             break;

          } 

         for(j=1;j<fondD+1; j++){

            currentTIME();

            ALLDays(now.dayOfTheWeek());

            num2=EEPROM.read(100+j);

            Serial.print(100+j); 

            Serial.print(num2); 

            Serial.print(Abrkfast[num2]);

            Serial.println(EEPROM.read(Abrkfast[num2]-2));

            delay(100);

             if(EEPROM.read(Abrkfast[num2]-2)==0){

              digitalWrite(b5,HIGH);

            }

            if(EEPROM.read(Abrkfast[num2]-2)==1){

             digitalWrite(b6,HIGH); 

            }

            lcd.setCursor(0,0);

            lcd.print(mediType[EEPROM.read(Abrkfast[num2]-4)]);

            lcd.setCursor(4,0);

            lcd.print(dailydos[EEPROM.read(Abrkfast[num2]-3)]);

            lcd.setCursor(6,0);

            lcd.print(afbf[EEPROM.read(Abrkfast[num2]-2)]);

            lcd.setCursor(10,0);

            lcd.print(dosTime[EEPROM.read(Abrkfast[num2])]);

            lcd.setCursor(0,1);

            lcd.print(doctor[EEPROM.read(Abrkfast[num2]-1)]);

            delay(1000);

            digitalWrite(b5,LOW);

            digitalWrite(b6,LOW);

            lcd.clear();

         }

         if(j==fondD+1 && pos==12){

         j=1;

         pos=13;

         delay(50);

         break;

         }

         }

        while(pos==13){

          if(digitalRead(A4)==LOW && trigSMS==0){

            Serial.println("Sending SMS");

            Serial1.println("AT+CMGF=1");    //Sets the GSM Module in Text Mode

            delay(100);  // Delay of 100 milli seconds delay

            Serial1.println("AT+CMGS="+918973760860"r");

            delay(100);

            Serial1.print("Alert !!! It's Time To Take Medicine");// The SMS text you want to send

            delay(100);

            Serial1.print("n");// The SMS text you want to send

            delay(100);

            for(j=1;j<fondD+1; j++){

                num2=EEPROM.read(100+j);   

                Serial1.print(mediType[EEPROM.read(Abrkfast[num2]-4)]);

                Serial1.print("- ");

                delay(100);

                Serial1.print(dailydos[EEPROM.read(Abrkfast[num2]-3)]);

                Serial1.print("  ");

                delay(100);

                Serial1.print(afbf[EEPROM.read(Abrkfast[num2]-2)]);

                Serial1.print("  ");

                delay(100);

                Serial1.print(dosTime[EEPROM.read(Abrkfast[num2])]);

                Serial1.print(" Doctor: ");

                delay(100);

                Serial1.print(doctor[EEPROM.read(Abrkfast[num2]-1)]);

                Serial1.print("n");

                delay(100);

              }

             if(j==fondD+1 && trigSMS==0){

                 Serial1.println(" ");

                 delay(100);

                 Serial1.println((char)26);// ASCII code of CTRL+Z

                 delay(100);

                 Serial.println("SMS Sent");

                 j=1;

                 pos=11;

                 trigSMS=1;

                 delay(50);

                 break;

                }

             }    

        else{

          j=1;

          pos=11;

          trigSMS=1;

          delay(50);

          break;

          } 

        } 

  }

  }

}

}

//this void function is really useful; it adds a "0" to the beginning of the number,

so that 5 minutes is displayed as "00:05:00", rather than "00:5 :00"

void printDigits2(int digits){

  if(digits < 10) 

  {

    lcd.print("0");

    lcd.print(digits);

  }

  else

  {

    lcd.print(digits);

  }

}


void ALLDays(int dey){

  switch(dey)

  {

    case 0://sun

          lcd.createChar(5,Salpha);

          lcd.createChar(6,Ualpha);

          lcd.createChar(7,Nalpha);

          lcd.setCursor(13,0);

          lcd.write(5);

          lcd.setCursor(14,0);

          lcd.write(6);

          lcd.setCursor(15,0);

          lcd.write(7);break;   

       case 1://mon

          lcd.createChar(5,Malpha);

          lcd.createChar(6,Oalpha);

          lcd.createChar(7,Nalpha);

          lcd.setCursor(13,0);

          lcd.write(5);

          lcd.setCursor(14,0);

          lcd.write(6);

          lcd.setCursor(15,0);

          lcd.write(7);break;

      case 2://tue

          lcd.createChar(5,Talpha);

          lcd.createChar(6,Ualpha);

          lcd.createChar(7,Ealpha);

          lcd.setCursor(13,0);

          lcd.write(5);

          lcd.setCursor(14,0);

          lcd.write(6);

          lcd.setCursor(15,0);

          lcd.write(7);break;

    

    case 3://wed

          lcd.createChar(5,Walpha);

          lcd.createChar(6,Ealpha);

          lcd.createChar(7,Dalpha);

          lcd.setCursor(13,0);

          lcd.write(5);

          lcd.setCursor(14,0);

          lcd.write(6);

          lcd.setCursor(15,0);

          lcd.write(7);break;

    case 4://thu

          lcd.createChar(5,Talpha);

          lcd.createChar(6,Halpha);

          lcd.createChar(7,Ualpha);

          lcd.setCursor(13,0);

          lcd.write(5);

          lcd.setCursor(14,0);

          lcd.write(6);

          lcd.setCursor(15,0);

          lcd.write(7);break;

     case 5://fri

          lcd.createChar(5,Falpha);

          lcd.createChar(6,Ralpha);

          lcd.createChar(7,Ialpha);

          lcd.setCursor(13,0);

          lcd.write(5);

          lcd.setCursor(14,0);

          lcd.write(6);

          lcd.setCursor(15,0);

          lcd.write(7);break;

      case 6://sat

          lcd.createChar(5,Salpha);

          lcd.createChar(6,Aalpha);

          lcd.createChar(7,Talpha);

          lcd.setCursor(13,0);

          lcd.write(5);

          lcd.setCursor(14,0);

          lcd.write(6);

          lcd.setCursor(15,0);

          lcd.write(7);break; 

      case 7://sun

          lcd.createChar(5,Salpha);

          lcd.createChar(6,Ualpha);

          lcd.createChar(7,Nalpha);

          lcd.setCursor(13,0);

          lcd.write(5);

          lcd.setCursor(14,0);

          lcd.write(6);

          lcd.setCursor(15,0);

          lcd.write(7);break; 

     default:break;

  } 


}


void currentTIME(){

 DateTime now = RTC.now();

 lcd.setCursor(6,1);

 HOUR=now.hour();

 printDigits2((HOUR > 12) ? HOUR - 12 : ((HOUR == 0) ? 12 : HOUR)); 

 lcd.print(":");

 printDigits2(MINUT=now.minute());

 lcd.print(":");

 printDigits2(SECOND=now.second());

 lcd.setCursor(14,1);

 if(HOUR < 12){                  // Adding the AM/PM sufffix

    //lcd.setCursor(14,0);

    lcd.write("AM");

    currntTZ=1;   

    }

   else{

   // lcd.setCursor(14,0);

    lcd.write("PM");

    currntTZ=2;

   }

 delay(800);

 currentDAY();

 delay(800);

}


void currentDAY(){

 DateTime now = RTC.now();

 lcd.setCursor(6,1);

 lcd.print(now.day(),DEC);

 lcd.print("/");

 lcd.print(now.month(),DEC);

 lcd.print("/");

 lcd.print(now.year(),DEC);

 lcd.setCursor(6,1);

 printDigits2(now.day());

 lcd.print("/");

 printDigits2(now.month());

 lcd.print("/");

 lcd.print(now.year(),DEC);

}

void medicineAlertSMS(){

            Serial.println("Sending SMS");

            Serial1.println("AT+CMGF=1");    //Sets the GSM Module in Text Mode

            delay(100);  // Delay of 100 milli seconds delay

            Serial1.println("AT+CMGS="+918973760860"r");

            delay(100);

            Serial1.print("Alert !!! You forgot to take medicine");// The SMS text you want to send

            delay(100);

            Serial1.print("n");// The SMS text you want to send

            delay(100);

            Serial1.print("Please Take Medicine On Time");// The SMS text you want to send

            delay(100);

            delay(100);

            Serial1.println((char)26);// ASCII code of CTRL+Z

            delay(1000);
    

}

###

 


Circuit Diagrams

Circuit-Diagram-Arduino-Based-Medicine-SMS-Reminder-System

Project Video


Filed Under: Electronic Projects

 

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


Featured Tutorials

  • Designing Gate Driver Circuit and Switching Mechanism for Modified Sine Wave Inverter – (Part 9/17)
  • Completing Modified Sine Wave Inverter Design with Full Bridge Circuit and Step Up Transformer – (Part 10/17)
  • Designing an Offline UPS – Part (12 /17)
  • How to reduce Switching Time of a Relay – (Part 15/17)
  • Testing MOSFET – (Part 16/17)
  • Driving High Side MOSFET using Bootstrap Circuitry – (Part 17/17)

Stay Up To Date

Newsletter Signup

Sign up and receive our weekly newsletter for latest Tech articles, Electronics Projects, Tutorial series and other insightful tech content.

EE Training Center Classrooms

EE Classrooms

Recent Articles

  • MicroPython – I2C protocol in ESP8266 and ESP3
  • New automotive radar sensor enables reliable in-cabin monitoring system
  • TI breaks ground on 300-mm semiconductor wafer-fabrication plants in Texas
  • New wireless AR Smart Viewer reference design
  • Infineon launches scalable and wireless charging platform with configurable controllers

Most Popular

5G 555 timer circuit 8051 ai Arduino atmega16 automotive avr dc motor display Electronic Part Electronic Parts Fujitsu ic infineontechnologies integratedcircuit Intel IoT ir lcd ldr led maximintegratedproducts microchip microchiptechnology Microchip Technology microcontroller microcontrollers mosfet motor powermanagement Raspberry Pi remote renesaselectronics renesaselectronicscorporation Research samsung semiconductor sensor software STMicroelectronics switch Technology vishayintertechnology wireless

RSS EDABOARD.com Discussions

  • What's the deal with all these "MPPT" IC's with no current sense?
  • Photovoltaic MOSFET Drivers - Voltage Rating
  • Impedance requirement for SDRAM signals
  • A circuit that can adjust a resistance and probing a voltage node
  • A analogue circuit that spit out the resistance desired

RSS Electro-Tech-Online.com Discussions

  • IRS2453 the H circuit
  • Ampro 16mm Stylist projector woes.
  • How to quickly estimate lead acid battery capacity ?
  • Finally switched to Linux.
  • Multistage BJT amplifier
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • About Us
  • Contact Us
  • Advertise

Copyright © 2022 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Projects and Tutorials
    • Electronic Projects
      • 8051
      • Arduino
      • ARM
      • AVR
      • PIC
      • Raspberry pi
      • STM32
    • Tutorials
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Products News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • EE Resources
    • DesignFast
    • LEAP Awards
    • Oscilloscope Product Finder
    • White Papers
    • Webinars
  • EE Learning Center
  • Women in Engineering