Your baby opens refrigerator without closing. This gadget makes a call to you when that happens



Hardware required
  • PHPoC Blue
  • Magnetic Contact Switch


Demonstration





Wiring
  • Connect one wire of Magnetic contact switch to GND
  • Connect the other wire of Magnetic contact switch to pin 11 of PHPoC Blue
Click image for larger version

Name:	wring.jpg
Views:	61
Size:	253.3 KB
ID:	1677



IFTTT Applets
Create an IFTTT applet that use Webhooks and VoIP Calls services.


Code
PHP Code:
<?php

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

include_once "/lib/sn_http_b2.php";
include_once 
"/lib/sd_340.php";

define("IFTTT_WEBHOOKS_KEY""xxxxxxxxxxxxxxxxxxxxxx"); // change your webhooks key here

function send_notification()
{

    
$url "https://maker.ifttt.com/trigger/refrigerator_open/with/key/" IFTTT_WEBHOOKS_KEY;
    
$resp_head http_request("GET"$url"");
    
$resp_body "";

    if(
$resp_head !== "")
        
$rlen http_read_sync($resp_body);

    
http_close();

    echo 
"$resp_body\r\n";
}

uio_setup(011"in_pu");  // configuring pin 11 of the UIO 0 to input with pull-up

$previous_status 1;

while(
1)
{
    
$current_status uio_in(011);

    if(
$previous_status == && $current_status == 1) { // if door is opened...
        
echo "refrigerator is opened\r\n";
        
send_notification();
        
usleep(100000);
    } else if(
$previous_status == && $current_status == 0) { // if door is closed...
        
echo "refrigerator is closed\r\n";
    }

    
$previous_status $current_status;
}
?>