Kushan Arampath
Published © GPL3+

MedProtecc

This is a prototype alarm system with a display designed minimize the risk of prescription drug theft from elderly homes and drug overdose.

IntermediateFull instructions provided146
MedProtecc

Things used in this project

Hardware components

Argon
Particle Argon
×1
Photon
Particle Photon
×1
LED (generic)
LED (generic)
×1
RGB Backlight LCD - 16x2
Adafruit RGB Backlight LCD - 16x2
×1
Buzzer
Buzzer
×1
Rotary potentiometer (generic)
Rotary potentiometer (generic)
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
Resistor 10k ohm
Resistor 10k ohm
×2
Jumper wires (generic)
Jumper wires (generic)
×1
Breadboard (generic)
Breadboard (generic)
×2

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
IFTTT

Story

Read more

Schematics

Photon Schematic

Photon PCB

Argon Schematic

Argon PCB

Code

Argon

C#
These are the codes for the Argon. (Commented do not work.)
#include "application.h"
#include "LiquidCrystal/LiquidCrystal.h"


int buzzer = A3;
int state = 0;

LiquidCrystal lcd(5, 4, 3, 2, 1, 0);

void setup() {
    
    
    // set up the LCD's number of columns and rows: 
    lcd.begin(16,2);
    // Print a message to the LCD.
    lcd.print("MedProtecc");
    
    
    pinMode(buzzer, OUTPUT);
    analogWrite(buzzer, LOW);
    
    
    Particle.function("buzzeralarmon", buzzer_alarm_manual);
    
    
    //Particle.subscribe("Intruder", intruderalertscreen, <DEVICEID>);
    Particle.subscribe("Intruder", buzzeralarm,<deviceID>);
    
    Particle.subscribe("Nointruder", nointruder, <deviceID>);
    //Particle.variable("Drugs", message, STRING);

}

void loop() {
    
    
    if (Time.now(), "%H:%M:%S" == "00:00:00") 
    {
        lcd.clear();
    }  
  
    //columns and rows
    lcd.setCursor(0,1);
    lcd.print(Time.format(Time.now(), "%H:%M:%S"));
    
}

void nointruder(const char*event, const char*data)
{
    
    lcd.begin(16,2);
    lcd.print("MedProtecc");
    
}

void buzzeralarm(const char *event, const char*data)
{
    
    
    
    for (int i = 0; i<10; i++)
    {
        lcd.clear();
        lcd.print("Intruder");
        lcd.setCursor(0, 1);
        lcd.print("At Medbox");
        
        analogWrite(buzzer, 200);
        delay(1000);
        analogWrite(buzzer, 0);
        delay(500);
    }
    
}



int buzzer_alarm_manual(String buzz)
{
    if(buzz == "on")
    {
        
        analogWrite(buzzer, 200);
        
        return 1;
    }else if(buzz == "off")
    {
        analogWrite(buzzer, 0);
        return 0;
    }else
    {
        return -1;
    }
    
}




//void buzzertrig (const char *event, const char *data )
//{
//    buzzeralarm();
//}

//void intruderalertscreen(const char*event, const char*data)
//{
//    lcd.clear();
//    lcd.print("Intruder");
//    lcd.setCursor(0, 1);
//    lcd.print("At Medbox");
//    delay(10000);
    

//}

//char message(String Message)
//{
//    if(Message == "name")
//    {   lcd.clear();
//        lcd.begin(16,2);
//        lcd.print(;
//        return 1;
//    }else
//    {
//        return 0;
//    }
    
    
//}

Photon

C#
These are the codes for the Photon.
#include "HC_SR04.h"

double cm = 0.0;
double inches = 0.0;

int trigPin = D2;
int echoPin = D3;

int LED = D7;


HC_SR04 rangefinder = HC_SR04(trigPin, echoPin);

void setup() 
{
    Spark.variable("cm", &cm, DOUBLE);
    //Spark.variable("inches", &inches, DOUBLE);
    //Serial.printf("cm", &cm, DOUBLE, "inches", &inches, DOUBLE);
    
    pinMode(LED, OUTPUT);
    digitalWrite(LED, HIGH);
    
    //Particle.function("controllultrasonic", controlUS);
}

void loop() 
{
    
    cm = rangefinder.getDistanceCM();
    //inches = rangefinder.getDistanceInch();
    delay(100);
    
    if (cm<30)
    {
        ///delay(5000);
        Particle.publish("Intruder", "Intruder Alert");
        delay(20000);
    }else
    {
        Particle.publish("Nointruder");
        delay(15000);
    }


}



/*
Connect an HC-SR04 Range finder as follows:
Spark   HC-SR04
GND     GND
5V      VCC
D4      Trig
D5      Voltage divider output - see below

Echo --|
       >
       < 470 ohm resistor
       >
       ------ D5 on Spark
       >
       < 470 ohm resistor
       >
GND ---|

Test it using curl like this:
curl https://api.spark.io/v1/devices/<deviceid>/cm?access_token=<accesstoken>

The default usable rangefinder is 10cm to 250cm. Outside of that range -1 is returned as the distance.

You can change this range by supplying two extra parameters to the constructor of minCM and maxCM, like this:

HC_SR04 rangefinder = HC_SR04(trigPin, echoPin, 5.0, 300.0);

*/


    

The prototype website UI

HTML
<!DOCTYPE html>

<html lang="en">
<head>
    
    <title>MEDPROTECC </title>

</head>

<body>
    

    <h1>MedProtecc Controls</h1>
    <br/>

    <h2> Buzzer Alarm Control</h2>
    <form action="http://api.particle.io/v1/devices/<DEVICEID>/<EVENTNAME>?access_token=<ACCESStOKEN>" method="POST">
        <br />
        <input type="radio" name="arg" value="on" />Alarm ON
        <br />
        <input type="radio" name="arg" value="off" />Alarm OFF
        <br />
        <input type="submit" value="Submit" /> 
    </form>

    <br/>
    <h2> Intruder Alert System Control</h2>
    <form action="http://api.particle.io/v1/devices/<DEVICEID>/<EVENTNAME>?access_token=<ACCESStOKEN>" method="POST">
        <br />
        <input type="radio" name="arg" value="on" />Intruder Alert ON
        <br />
        <input type="radio" name="arg" value="off" />Intruder Alert OFF
        <br />
        <input type="submit" value="Submit" /> 
    </form>

    <h2> Drug Doses</h2>
    <form action="http://api.particle.io/v1/devices/<DEVICEID>/<EVENTNAME>?access_token=<ACCESStOKEN>" method="POST">
        <br />
        <div>
            <label>Input</label>
            <input type = "text" name = "name" maxlength = "80">
        </div>
        <br />
        <input type="submit" value="Submit" /> 
    </form>

    
</body>
</html>

Credits

Kushan Arampath

Kushan Arampath

1 project • 0 followers

Comments

Add projectSign up / Login