Madison GoodParke WagnerEric Smith
Published

Meds Memo

Utilize particle photons, magnetic reed switches and LED lights to remind you to take your medications.

IntermediateFull instructions provided3.5 hours701
Meds Memo

Things used in this project

Hardware components

Reed Switch, Magnet Switch Set
Reed Switch, Magnet Switch Set
×2
Photon
Particle Photon
×3
LED (generic)
LED (generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Through Hole Resistor, 4.7 kohm
Through Hole Resistor, 4.7 kohm
×1
Breadboard (generic)
Breadboard (generic)
×3
USB-A to Mini-USB Cable
USB-A to Mini-USB Cable
×3

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
Google Sheets
Google Sheets
Maker service
IFTTT Maker service

Story

Read more

Schematics

LED Circuit Diagram Fritzing File

LED Circuit Diagram Image

Magnetic Reed Switch Circuit Fritzing File

Magnetic Reed Switch Circuit Image

Code

Bathroom Door Sensor

C/C++
When entering the bathroom, the sensors on the magnetic reed switch on the door will be separated far enough to read a "HIGH" signal, which will then publish "Bathroom Door Open" under the BathroomDoorStatus event. This device is also subscribed to each of the other particles publishable events.
int DAP = D0;
int DAR = D1;
int boardLed = D7;

void setup() {

pinMode(DAP,OUTPUT);
pinMode(DAR,INPUT);
  Particle.subscribe("cabinetdoorStatus", myHandler);
  Particle.subscribe("cabinetdoorClosed", myHandler);

}
void myHandler(const char *event, const char *data)
{
}

void loop() {

while (Particle.connected()){

if(digitalRead(DAR)==HIGH){
        Particle.publish("bathroomdoorStatus","BATHROOM DOOR OPEN",60);
        delay(2000);
    }
    else{
        Particle.publish("bathroomdoorStatus","BATHROOM DOOR CLOSED",60);
        delay(2000);
    }
}
}

Cabinet Door Sensor

C/C++
The cabinet door sensor will send a signal to the light blink sensor once two conditions are met, the bathroom door is open and the cabinet door is open. The cabinet door photon is subscribed to the bathroom door sensor. Once the "BATHROOM DOOR OPEN" status is published to the bathroom door status event and the cabinet door is opened and the photon reads a high output signal, the sensor will recognize the cabinet is open and will publish its status as an event.
int DAP = D0;
int DAR = D1;
int boardLed = D7;

void setup() {

pinMode(DAP,OUTPUT);
pinMode(DAR,INPUT);
  Particle.subscribe("bathroomdoorStatus", myHandler);
  Particle.subscribe("cabinetdoorClosed", myHandler);

}
void myHandler(const char *event, const char *data)
{
while(strcmp(data,"BATHROOM DOOR OPEN")==0){
    if(digitalRead(DAR)==HIGH){
        Particle.publish("cabinetdoorStatus","CABINET DOOR OPEN",60);
        delay(1000);
    }
    else{
        Particle.publish("cabinetdoorStatus","CABINET DOOR CLOSED",60);
        delay(1000);
    }
}
}

Light Blink Sensor

C/C++
Once the bathroom and cabinet doors are opened, the LED light inside of the cabinet, placed near the medicine, will rapidly blink. The light will then shut off once the cabinet door is closed again. Once the light goes through an on/off cycle, it will publish and event and send a reminder to check if the medicine was taken.
int led = D6;

void setup() {
     
    pinMode(led, OUTPUT);
 
  
  Particle.subscribe("cabinetdoorStatus", myHandler);
   Particle.subscribe("bathroomdoorStatus", myHandler);

}
int myHandler(const char *event, const char *data)
{
 
  

   
   if(strcmp(data,"CABINET DOOR OPEN")==0){
    digitalWrite(led, HIGH);
   

    delay(100);

    digitalWrite(led, LOW);
    
    delay(100);
    digitalWrite(led, HIGH);
   

    delay(100);

    digitalWrite(led, LOW);
    
    delay(100);
    digitalWrite(led, HIGH);
  
}
     
    
}

void loop() {

while (Particle.connected()){

if(digitalRead(D6)==HIGH){

Particle.publish("cabinetdoorClosed","MEDS TAKEN",60);
delay(2000);
digitalWrite(led, LOW);
}
else{
delay(2000);
}
}
}
     
    

Credits

Madison Good

Madison Good

1 project • 0 followers
Parke Wagner

Parke Wagner

1 project • 0 followers
Eric Smith

Eric Smith

1 project • 0 followers

Comments