Hackster is hosting Impact Spotlights highlighting smart energy storage. Start streaming on Thursday!Stream Impact Spotlights on Thursday!
Achraf Oukheir
Published

Medication Reminder with RFID

To remind a patient to take his medication periodically, he just needs to pass his badge and verify his medication.

BeginnerShowcase (no instructions)1 hour1,955
Medication Reminder with RFID

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
RFID _RC522 READER
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

RFID READER connection

you can check the code Connection

Code

Rfid Medicament

Arduino
after veryfy u r card with code of card reading
/* 
 *  RFID Module RC522
 *  Simple Project:- Arduino will read RFID Tag and Display To the Serial Monitor!
 *  
 *  RFID RC522 and Arduino Uno Pin Configuration
 *  
 *  RFID RC522          Arduino Uno
 *  SS/SDA              D10
 *  SCK                 D13
 *  MOSI                D11
 *  MISO                D12
 *  IRQ                 Not Connected
 *  GND                 GND
 *  RST                 D9
 *  3.3V                3.3V
*/

#include <SPI.h>
#include <RFID.h>

#define SS_PIN 10
#define RST_PIN 9

#define Red_LED 6
#define Green_LED1 5
#define Green_LED2 4
#define Green_LED3 3

RFID rfid(SS_PIN, RST_PIN); 

//Unique ID of RFID Tag, which you want to give access. 
int My_RFID_Tag[5] = {0x39,0x57,0x10,0xBB,0xC5}; //after reading carte1
int My_RFID_Tag1[5] = {0x6C,0x88,0xE1,0x2B,0x2E}; //carte 2 

//variable to hold your Access_card
boolean My_Card = false;  
boolean My_Card1 = false;  


void setup()
{ 
  
  // put your setup code here, to run once:
  //set the pins as an input/output
  pinMode(Red_LED,OUTPUT);
  pinMode(Green_LED1,OUTPUT);
  pinMode(Green_LED2,OUTPUT);
  pinMode(Green_LED3,OUTPUT);

  Serial.begin(9600);
  SPI.begin(); 
  rfid.init();
 
}

void loop(){
   //First Assume detected card(Or tag) is My_Card, 
  //Then later we will check is it My_Card or not! 
  My_Card = true; 
  My_Card1 = true; 


      //Check if any RFID Tags Detected or not?
    if (rfid.isCard()) {
      
          //if RFID Tag is detected, check for the Unique ID,
      //and print it on the Serial Window
        if (rfid.readCardSerial()) {
          
        Serial.println("Card found");
            //Unique id is 5 Digit Number.
          //Printing in HEX for better Understanding
          for( int i = 0; i < 5; i++ )
          {
              Serial.print(rfid.serNum[i], HEX);
              Serial.print(" ");              
                                       
          }  
          delay(100);
                    
      //Compare this RFID Tag Unique ID with your My_RFID_Tag's Unique ID
          for(int i = 0; i < 5; i++)
          {   
              //if any one Unique ID Digit is not matching,
              //then make My_Card = false and come out from loop
              //No need to check all the digit!
              if( My_RFID_Tag[i] != rfid.serNum[i] )
              {
                My_Card = false;
                break;                
              }
                 if( My_RFID_Tag1[i] != rfid.serNum[i] )
              {
                My_Card1 = false;
                break;                
              }            
          }
           Serial.println(); 

            if(My_Card){
            Serial.println("Mme this is your medication ");
         
                             Serial.println("Breakfast - Lunch - Dinner  ");         
            
            //Turn on the Green LED as an indication of permission is given 
            //to access the room.
            digitalWrite(Green_LED1,HIGH);
                digitalWrite(Green_LED2,HIGH);
                    digitalWrite(Green_LED3,HIGH);
                    digitalWrite(Red_LED,LOW);
             delay(3000);  
                /* If we have the same ID, just write a dot. */
               Serial.print("...");
                digitalWrite(Green_LED1,LOW);
                digitalWrite(Green_LED2,LOW);
                    digitalWrite(Green_LED3,LOW);
                     digitalWrite(Red_LED,HIGH);
                                                    
             } else if(My_Card1){
            Serial.println("MR this is your medication ");
         
                  Serial.println("breakfast - Dinner  ");                
            
            //Turn on the Green LED as an indication of permission is given 
            //to access the room.
            digitalWrite(Green_LED1,HIGH);
                digitalWrite(Green_LED2,LOW);
                    digitalWrite(Green_LED3,HIGH);
                    digitalWrite(Red_LED,LOW);
             delay(3000);  
              /* If we have the same ID, just write a dot. */
               Serial.print("...");
                digitalWrite(Green_LED1,LOW);
                digitalWrite(Green_LED2,LOW);
                    digitalWrite(Green_LED3,LOW);
                     digitalWrite(Red_LED,HIGH);
                                                    
             } else {
               /* If we have the same ID, just write a dot. */
               Serial.print("...");
                digitalWrite(Green_LED1,LOW);
                digitalWrite(Green_LED2,LOW);
                    digitalWrite(Green_LED3,LOW);
                     digitalWrite(Red_LED,HIGH);
            return;
             }
          }
    } 
    rfid.halt();
}

card reading

Arduino
/**
* Read a card using a mfrc522 reader on your SPI interface
* Pin layout should be as follows (on Arduino Uno):
* MOSI: Pin 11 / ICSP-4
* MISO: Pin 12 / ICSP-1
* SCK: Pin 13 / ISCP-3
* SS: Pin 10
* RST: Pin 9
*
* Script is based on the script of Miguel Balboa. 
* New cardnumber is printed when card has changed. Only a dot is printed
* if card is the same.
*
* @version 0.1
* @author Henri de Jong
* @since 06-01-2013
*/

#include <SPI.h>
#include <RFID.h>

#define SS_PIN 10
#define RST_PIN 9

RFID rfid(SS_PIN, RST_PIN); 

// Setup variables:
    int serNum0;
    int serNum1;
    int serNum2;
    int serNum3;
    int serNum4;

void setup()
{ 
  Serial.begin(9600);
  SPI.begin(); 
  rfid.init();
  
}

void loop()
{
    
    if (rfid.isCard()) {
        if (rfid.readCardSerial()) {
            if (rfid.serNum[0] != serNum0
                && rfid.serNum[1] != serNum1
                && rfid.serNum[2] != serNum2
                && rfid.serNum[3] != serNum3
                && rfid.serNum[4] != serNum4
            ) {
                /* With a new cardnumber, show it. */
                Serial.println(" ");
                Serial.println("Card found");
                serNum0 = rfid.serNum[0];
                serNum1 = rfid.serNum[1];
                serNum2 = rfid.serNum[2];
                serNum3 = rfid.serNum[3];
                serNum4 = rfid.serNum[4];
               
                //Serial.println(" ");
                Serial.println("Cardnumber:");
                Serial.print("Dec: ");
		Serial.print(rfid.serNum[0],DEC);
                Serial.print(", ");
		Serial.print(rfid.serNum[1],DEC);
                Serial.print(", ");
		Serial.print(rfid.serNum[2],DEC);
                Serial.print(", ");
		Serial.print(rfid.serNum[3],DEC);
                Serial.print(", ");
		Serial.print(rfid.serNum[4],DEC);
                Serial.println(" ");
                        
                Serial.print("Hex: ");
		Serial.print(rfid.serNum[0],HEX);
                Serial.print(", ");
		Serial.print(rfid.serNum[1],HEX);
                Serial.print(", ");
		Serial.print(rfid.serNum[2],HEX);
                Serial.print(", ");
		Serial.print(rfid.serNum[3],HEX);
                Serial.print(", ");
		Serial.print(rfid.serNum[4],HEX);
                Serial.println(" ");
             } else {
               /* If we have the same ID, just write a dot. */
               Serial.print(".");
             }
          }
    }
    
    rfid.halt();
}

Credits

Achraf Oukheir

Achraf Oukheir

8 projects • 14 followers

Comments