Modifed version from Samuel Mokrani Changed URL to push data to sensor page Added visualisation page URL as a comment

Dependencies:   EthernetInterface MMA7660 WebSocketClient mbed-rtos mbed LM75B

Fork of Websocket_Ethernet_acc by Samuel Mokrani

Files at this revision

API Documentation at this revision

Comitter:
samux
Date:
Fri Feb 08 12:46:02 2013 +0000
Parent:
1:1ca9c7ae7e0b
Commit message:
demo using acc and tmp sensors

Changed in this revision

LM75B.lib Show annotated file Show diff for this revision Revisions of this file
WebSocketClient.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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/LM75B.lib	Fri Feb 08 12:46:02 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/chris/code/LM75B/#6a70c9303bbe
--- a/WebSocketClient.lib	Fri Oct 26 09:27:16 2012 +0000
+++ b/WebSocketClient.lib	Fri Feb 08 12:46:02 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/samux/code/WebSocketClient/#86e89a0369b9
+http://mbed.org/users/samux/code/WebSocketClient/#4567996414a5
--- a/main.cpp	Fri Oct 26 09:27:16 2012 +0000
+++ b/main.cpp	Fri Feb 08 12:46:02 2013 +0000
@@ -1,30 +1,39 @@
-#include "mbed.h"
-#include "EthernetInterface.h"
-#include "Websocket.h"
-#include "MMA7660.h"
-
-MMA7660 MMA(p28, p27);
-
-DigitalOut l1(LED1);
- 
-int main() {
-    char json_str[100];
-    
-    if (MMA.testConnection())
-        l1 = 1;
- 
-    EthernetInterface eth;
-    eth.init(); //Use DHCP
-    eth.connect();
-    printf("IP Address is %s\n\r", eth.getIPAddress());
-    
-    Websocket ws("ws://sockets.mbed.org/ws/sensors/wo");
-    // visit http://tools.mbed.org/iot/ to see the realtime graph
-    ws.connect();
- 
-    while (1) {
-        sprintf(json_str, "{\"id\":\"mbed-app-board\",\"ax\":\"%d\",\"ay\":\"%d\",\"az\":\"%d\"}", (int)(MMA.x()*200), (int)(MMA.y()*200), (int)(MMA.z()*200));
-        ws.send(json_str);
-        wait(0.2);
-    }
+#include "mbed.h"
+#include "EthernetInterface.h"
+#include "Websocket.h"
+#include "MMA7660.h"
+#include "LM75B.h"
+
+// accelerometer
+MMA7660 acc(p28, p27);
+
+// temperature sensor
+LM75B tmp(p28,p27);
+
+DigitalOut l1(LED1);
+ 
+int main() {
+    char json_str[100];
+    
+    if (acc.testConnection())
+        l1 = 1;
+ 
+    EthernetInterface eth;
+    eth.init(); //Use DHCP
+    eth.connect();
+    printf("IP Address is %s\n\r", eth.getIPAddress());
+    
+    // See the output on http://sockets.mbed.org/app-board/viewer
+    Websocket ws("ws://sockets.mbed.org:443/ws/app-board/wo");
+    ws.connect();
+ 
+    while (1) {
+        // create json string with acc/tmp data
+        sprintf(json_str, "{\"id\":\"app_board_eth_EW2013\",\"ax\":%d,\"ay\":%d,\"az\":%d, \"tmp\":%d}", (int)(acc.x()*360), (int)(acc.y()*360), (int)(acc.z()*360), (int)tmp.read());
+        
+        // send str
+        ws.send(json_str);
+        
+        wait(0.1);
+    }
 }
\ No newline at end of file