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

Committer:
chris
Date:
Fri Oct 26 09:27:16 2012 +0000
Revision:
1:1ca9c7ae7e0b
Parent:
0:11bb5faeb547
Child:
2:1fae595547d5
Changed the URL to feed data to a graph

Who changed what in which revision?

UserRevisionLine numberNew contents of line
samux 0:11bb5faeb547 1 #include "mbed.h"
samux 0:11bb5faeb547 2 #include "EthernetInterface.h"
samux 0:11bb5faeb547 3 #include "Websocket.h"
samux 0:11bb5faeb547 4 #include "MMA7660.h"
samux 0:11bb5faeb547 5
samux 0:11bb5faeb547 6 MMA7660 MMA(p28, p27);
samux 0:11bb5faeb547 7
samux 0:11bb5faeb547 8 DigitalOut l1(LED1);
samux 0:11bb5faeb547 9
samux 0:11bb5faeb547 10 int main() {
samux 0:11bb5faeb547 11 char json_str[100];
samux 0:11bb5faeb547 12
samux 0:11bb5faeb547 13 if (MMA.testConnection())
samux 0:11bb5faeb547 14 l1 = 1;
samux 0:11bb5faeb547 15
samux 0:11bb5faeb547 16 EthernetInterface eth;
samux 0:11bb5faeb547 17 eth.init(); //Use DHCP
samux 0:11bb5faeb547 18 eth.connect();
samux 0:11bb5faeb547 19 printf("IP Address is %s\n\r", eth.getIPAddress());
chris 1:1ca9c7ae7e0b 20
chris 1:1ca9c7ae7e0b 21 Websocket ws("ws://sockets.mbed.org/ws/sensors/wo");
chris 1:1ca9c7ae7e0b 22 // visit http://tools.mbed.org/iot/ to see the realtime graph
samux 0:11bb5faeb547 23 ws.connect();
samux 0:11bb5faeb547 24
samux 0:11bb5faeb547 25 while (1) {
chris 1:1ca9c7ae7e0b 26 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));
samux 0:11bb5faeb547 27 ws.send(json_str);
samux 0:11bb5faeb547 28 wait(0.2);
samux 0:11bb5faeb547 29 }
samux 0:11bb5faeb547 30 }