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: mbed LM75B NTPClient WiflyInterface MMA7660 WebSocketClient
main.cpp
- Committer:
- samux
- Date:
- 2013-02-08
- Revision:
- 4:79f9caf3d109
- Parent:
- 3:d1d4b7d317d1
- Child:
- 5:ab84dbbe7366
File content as of revision 4:79f9caf3d109:
#include "mbed.h"
#include "WiflyInterface.h"
#include "Websocket.h"
#include "LM75B.h"
#include "MMA7660.h"
/* wifly interface:
* - p9 and p10 are for the serial communication
* - p30 is for the reset pin
* - p29 is for the connection status
* - "mbed" is the ssid of the network
* - "password" is the password
* - WPA is the security
*/
WiflyInterface wifly(p9, p10, p30, p29, "mbed", "password", WPA);
// accelerometer
MMA7660 acc(p28, p27);
// temperature sensor
LM75B tmp(p28,p27);
int main()
{
char json_str[100];
wifly.init(); //Use DHCP
while (!wifly.connect());
printf("IP Address is %s\n\r", wifly.getIPAddress());
// See the output on http://sockets.mbed.org/app-board/viewer
Websocket ws("ws://sockets.mbed.org:443/ws/sensors/wo");
// connect WS server
while (!ws.connect());
while (1) {
// create json string with acc/tmp data
sprintf(json_str, "{\"id\":\"app_board_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);
}
}