Saad Habach / Mbed 2 deprecated Home_Monitoring_System

Dependencies:   ESP8266 mbed-rtos mbed

Fork of Home_Secuity by Waiel Haj Elnur

Files at this revision

API Documentation at this revision

Comitter:
wmerghan
Date:
Wed Mar 22 22:48:44 2017 +0000
Child:
1:5245173228f2
Commit message:
No revisions

Changed in this revision

EthernetInterface.lib Show annotated file Show diff for this revision Revisions of this file
M2XStreamClient.lib Show annotated file Show diff for this revision Revisions of this file
jsonlite.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-rtos.lib 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EthernetInterface.lib	Wed Mar 22 22:48:44 2017 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/mbed_official/code/EthernetInterface/#2fc406e2553f
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/M2XStreamClient.lib	Wed Mar 22 22:48:44 2017 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/teams/ATT-M2X-team/code/M2XStreamClient/#2610823f7f2e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jsonlite.lib	Wed Mar 22 22:48:44 2017 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/citrusbyte/code/jsonlite/#807034181e02
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Mar 22 22:48:44 2017 +0000
@@ -0,0 +1,83 @@
+#include "mbed.h"
+#include "M2XStreamClient.h"
+#include "EthernetInterface.h"
+
+AnalogIn temp(A0);
+DigitalOut test(D3, 0);
+InterruptIn motion(D2);
+Serial pc(USBTX, USBRX); // tx, rx
+
+int motion_detected = 0;
+char deviceId[] = "db9efa47cfb6502a21e51cdc97a3cdb4"; // Device you want to push to
+char streamTemp[] = "Temprature"; // Stream you want to push to
+char streamInt[] = "Intruder";
+char streamInts[] = "Intruders";
+char m2xKey[] = "d647418357fc21e8ab3672210493efe6"; // Your M2X API Key or Master API Key
+
+
+void irq_handler(void)
+{
+    motion_detected = 1;
+}
+
+
+int main(void)
+{
+    int motion_cnt = 0;
+    
+    //time_t is used to store the calender time format
+    time_t rawtime;
+    struct tm *timeinfo;
+    
+    double tempC, tempF;
+    
+    pc.printf("Started\r\n");
+    
+    motion.rise(&irq_handler);
+    
+    // Intialize Ethernet connection
+    EthernetInterface eth;
+    eth.init();
+    eth.connect();
+    printf("Success. Connected!. Device IP Address is %s\r\n", eth.getIPAddress());
+ 
+    // Initialize the M2X client
+    Client client;
+    M2XStreamClient m2xClient(&client, m2xKey);
+        
+    while(1)
+    {
+        tempC = (temp*330);
+        tempF = (9.0*tempC)/5.0 + 32.0;
+        pc.printf(" The Temperature Voltage is: %f\n\r", temp.read());
+        
+        m2xClient.updateStreamValue(deviceId, streamTemp, tempF);
+    
+        wait(1);
+        
+        if(motion_detected)
+        {
+            //get the current time
+            time(&rawtime);
+            timeinfo = localtime(&rawtime);
+            
+            motion_cnt++;
+            motion_detected = 0;
+            pc.printf("Motion %d Detected at %d:%d:%d \n\r", motion_cnt, timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
+            m2xClient.updateStreamValue(deviceId, streamInt, motion_cnt);
+            m2xClient.updateStreamValue(deviceId, streamInts, motion_cnt);
+        }
+        
+        if(tempC > 25)
+        {
+            pc.printf("Temperature is %.2f C %.2f F\n\r", tempC, tempF);
+            DigitalOut test(D3,1);
+            
+        }
+        else
+        {
+         DigitalOut test(D3,0);
+        
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Wed Mar 22 22:48:44 2017 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/mbed_official/code/mbed-rtos/#c825593ece39
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Mar 22 22:48:44 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/4336505e4b1c
\ No newline at end of file