IOT

Dependencies:   EthernetInterface mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
rohangala
Date:
Mon Jun 15 06:16:23 2015 +0000
Commit message:
IOT lUX

Changed in this revision

EthernetInterface.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
diff -r 000000000000 -r 9d11a3afff01 EthernetInterface.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/EthernetInterface.lib	Mon Jun 15 06:16:23 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/EthernetInterface/#2fc406e2553f
diff -r 000000000000 -r 9d11a3afff01 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Jun 15 06:16:23 2015 +0000
@@ -0,0 +1,65 @@
+#include "mbed.h"
+#include "EthernetInterface.h"
+#include "stdio.h"
+
+float lux(void)
+{
+AnalogIn ain(p15);
+
+float vr=0,lr=0;
+   
+float vol[12]={0.36,0.61,0.8,0.9,1.23,1.45,1.81,2.06,2.62,2.81,3.02,3.25};
+float lux[12]={27000,20000,16000,11000,4000,1500,833,578,201,104,40,23};
+
+int i;
+float m=0;
+
+vr=ain*3.3;
+for(i=0; vr> vol[i];i++);
+m = ((lux[i]-lux[i+1])/(vol[i]-vol[i+1]));
+lr=lux[i+1]+(m*(vr-(vol[i+1])));
+
+return vr;
+}
+
+
+#include "mbed.h"
+#include "EthernetInterface.h"
+
+int main() {
+    float l=0;
+    EthernetInterface eth;
+    eth.init(); //Use DHCP
+    eth.connect();
+    printf("IP Address is %s\n", eth.getIPAddress());
+    char* public_key = "wpv0ajajxXsllRZOlbn0" ;
+    char* private_key = "wzep7E7EPDCRR0b5Rdga" ;
+    char http_cmd[256];
+    for(int i=0 ; i<5 ;i++)
+    {
+        //char c=i;
+        TCPSocketConnection sock;
+        sock.connect("data.sparkfun.com", 80);
+    l=lux();
+    printf("volt = %.2f",l);
+       sprintf(http_cmd,"GET /input/%s?private_key=%s&var1=%.2f HTTP/1.0\n\n", public_key, private_key, l);
+    //char http_cmd[] = "GET /input/wpv0ajajxXsllRZOlbn0?private_key=wzep7E7EPDCRR0b5Rdga&var1=%c HTTP/1.0\n\n",i;
+        sock.send_all(http_cmd, sizeof(http_cmd)-1);
+    
+    char buffer[300];
+    int ret;
+    while (true) {
+        ret = sock.receive(buffer, sizeof(buffer)-1);
+        if (ret <= 0)
+            break;
+        buffer[ret] = '\0';
+        printf("Received %d chars from server:\n%s\n", ret, buffer);
+    }
+    sock.close();
+     
+    
+    }
+    eth.disconnect();
+    
+    while(1) {}
+}
diff -r 000000000000 -r 9d11a3afff01 mbed-rtos.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Mon Jun 15 06:16:23 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-rtos/#ed4ff3bea947
diff -r 000000000000 -r 9d11a3afff01 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Jun 15 06:16:23 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/cbbeb26dbd92
\ No newline at end of file