WIZwiki-W7500 mbed platform & IFTTT maker channel. The aim of this project is to catch a thief when I wasn't home. If the PIR sensor catches a thief. It will send notification to your mobile device.

Dependencies:   IFTTT WIZnetInterface mbed

Files at this revision

API Documentation at this revision

Comitter:
jehoon
Date:
Thu Jul 30 05:36:01 2015 +0000
Commit message:
Stop Thief - WIZwiki-W7500 mbed platform & IFTTT maker channel.; The aim of this project is to catch a thief when I wasn't home.; If the PIR sensor catches a thief. It will send notification to your mobile device.

Changed in this revision

IFTTT.lib Show annotated file Show diff for this revision Revisions of this file
WIZnetInterface.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 801a968f1625 IFTTT.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/IFTTT.lib	Thu Jul 30 05:36:01 2015 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/mbedAustin/code/IFTTT/#15c6c9f87c32
diff -r 000000000000 -r 801a968f1625 WIZnetInterface.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WIZnetInterface.lib	Thu Jul 30 05:36:01 2015 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/teams/WIZnet/code/WIZnetInterface/#bda61525ac71
diff -r 000000000000 -r 801a968f1625 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Jul 30 05:36:01 2015 +0000
@@ -0,0 +1,72 @@
+#include "mbed.h"
+#include "EthernetInterface.h"
+#include "TCPSocketConnection.h"
+#include "ifttt.h"
+
+#define YourEventName "YOUREVENT"
+#define YourSecretKey "YOURKEY"
+
+#define DuringSafety 5  //hours
+
+EthernetInterface eth;
+Serial pc(USBTX, USBRX); // tx, rx
+DigitalOut led(LED1);
+AnalogIn sw(A0);
+DigitalIn pir(D8,PullUp);
+Timer timer;
+
+int main()
+{ 
+    int phy_link;
+    int flag = 0;
+    int onetimeflag = 0;
+    float sec = 0.0;
+    
+    pc.baud(115200);
+   printf("Wait a second...\r\n");
+    uint8_t mac_addr[6] = {0x00, 0x08, 0xDC, 0x12, 0x34, 0x56}; 
+    eth.init(mac_addr); //Use DHCP
+    eth.connect();
+    
+    do{
+         phy_link = eth.ethernet_link();
+         printf("...");
+         wait(2);
+    }while(!phy_link);
+    printf("\r\nIP Address is %s \r\n", eth.getIPAddress());
+    TCPSocketConnection sock;
+
+    // Initialize ifttt object, add up to 3 optional values, trigger event.
+    IFTTT ifttt(YourEventName,YourSecretKey, &sock); // EventName, Secret Key, socket to use
+
+
+    while(1) {
+        
+        if(!pir){
+            led = 0;
+            onetimeflag = 0;
+            printf("Safety\r\n");
+            if(!flag){
+                timer.start();
+                flag = 1;
+            }
+            wait(1);
+        }
+        else if(pir && (float)sw.read()>=0.9 && !onetimeflag){
+            led=1;
+            onetimeflag=1;
+            printf("Thief Detected\r\n");
+            ifttt.addIngredients("===WARNING===","The Thief was found","Report him to the police");
+            ifttt.trigger();   
+            timer.reset();
+            wait(1);
+        }
+        sec = timer.read();
+        if(sec > DuringSafety*3600 && (float)sw.read()>=0.9){
+            timer.reset();
+            ifttt.addIngredients("Your home in safety during",(char*)DuringSafety,"hours!");
+            ifttt.trigger();    
+        }
+    }
+
+}
\ No newline at end of file
diff -r 000000000000 -r 801a968f1625 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Jul 30 05:36:01 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/7cff1c4259d7
\ No newline at end of file