Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EthernetInterface MMA7660 WebSocketClient mbed-rtos mbed LM75B
Fork of Websocket_Ethernet_acc by
main.cpp
00001 #include "mbed.h" 00002 #include "EthernetInterface.h" 00003 #include "Websocket.h" 00004 #include "MMA7660.h" 00005 #include "LM75B.h" 00006 00007 // accelerometer 00008 MMA7660 acc(p28, p27); 00009 00010 // temperature sensor 00011 LM75B tmp(p28,p27); 00012 00013 DigitalOut l1(LED1); 00014 00015 int main() { 00016 char json_str[100]; 00017 00018 if (acc.testConnection()) 00019 l1 = 1; 00020 00021 EthernetInterface eth; 00022 eth.init(); //Use DHCP 00023 eth.connect(); 00024 printf("IP Address is %s\n\r", eth.getIPAddress()); 00025 00026 // See the output on http://sockets.mbed.org/app-board/viewer 00027 Websocket ws("ws://sockets.mbed.org:443/ws/app-board/wo"); 00028 ws.connect(); 00029 00030 while (1) { 00031 // create json string with acc/tmp data 00032 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()); 00033 00034 // send str 00035 ws.send(json_str); 00036 00037 wait(0.1); 00038 } 00039 }
Generated on Wed Jul 13 2022 21:38:24 by
1.7.2
