PHPoC - Detect Someone Taking Your Stuff

PHPoC - Detect Someone Taking Your Stuff

Postby IoT_lover » Wed Aug 02, 2017 11:58 am

Introduction
In this project, I am going to show you how to detect someone stealing your valuable stuff. If detected, PHPoC sends a notification via Gmail and makes an alert sound and light.

Demonstration
phpBB [video]


Hardware Components

- PHPoC Blue × 1
- SparkFun Force Sensor × 1
- Resistor 3.3k ohm × 1
- PHPoC 4-Port Relay Expansion Board (T-type) × 1
- Warning Lights & Electric Horns × 1

Schematics

- Stack PHPoC Relay Board on PHPoC Blue
- Connect Force sensor to PHPoC Blue as below image.
- Connect Warning Lights & Electric Horns to port 0 of Relay Board

PHPoC Wiring.JPG
PHPoC Wiring.JPG (58.4 KiB) Viewed 265 times


Real PHPoC Wiring.JPG
Real PHPoC Wiring.JPG (43.9 KiB) Viewed 265 times


Detecting Something is Taken Away

To detect treasure present or not, I put the treasure on the force sensor. This sensor let us know how heavy the treasure is. If output value of sensor is below a threshold, it means the treasure is not present and someone took it away.

Force sensor (electronic part is hidden below table).jpg
Force sensor (electronic part is hidden below table).jpg (13.92 KiB) Viewed 265 times


Laptop overlays force sensor..jpg
Laptop overlays force sensor..jpg (44.27 KiB) Viewed 265 times


Electronic part should be hidden under table.

Handling Event
If event is detected, PHPoC will make an alert sound and light, and send a Gmail notification to owner.

Source Code
<task0.php>
Code: Select all
<?php

if(_SERVER("REQUEST_METHOD"))
    exit; // avoid php execution via http request

include_once "/lib/sd_340.php";
include_once "/lib/sn_dns.php";
include_once "/lib/sn_esmtp.php";
include_once "/lib/sd_spc.php";

define("THRESHOLD", 50); // in ADC value

function send_gmail()
{
    esmtp_account("ypur_account@gmail.com", "PHPoC");
    esmtp_auth("your_account", "your_password");
    esmtp_msa("smtp.gmail.com", 465);
    
    $time 
= date("Y-M-d H:i:s", time());

    $subject = "Alert: Your treasure is being taken away";
    $message  = "Location: Planet Earth\r\n";
    $message .= "Time: $time\r\n";
    $message .= "Your treasure is being taken away\r\n";

    $msg = esmtp_send("receiver_account@gmail.com", "Boss", $subject, $message);

    if($msg == "221")
        return true;
    else
        return false
;
}

spc_reset();
spc_sync_baud(115200);
adc_setup(0, 0); // adc0, channel 0

$obj_present = false;

while(
1)
{
    $adc_in = adc_in(0, 30);
    
    if
($adc_in < THRESHOLD)
    {
        
        if
($obj_present)
        {
            //Alert
            spc_request(14, 4, "set 0 output high");
            // send notification
            while(!send_gmail())
                ;
            
            $obj_present 
= false;
        }
    }
    else
    
{
        $obj_present = true;
        spc_request(14, 4, "set 0 output low");
    }
}

?>
IoT_lover
 
Posts: 7
Joined: Mon Jun 26, 2017 1:01 pm

Return to Project

Who is online

Users browsing this forum: No registered users and 1 guest

cron