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: WebSocketClient WiflyInterface mbed messages
Code to Change
In order for the mbed to connect to your network, you will have to tell it ahead of time your network name, and password, etc. Here are the bare minimum lines you have to modify, separated by filename:
main.cpp¶
Change Line 56 for each unique IoT device that you would like to connect to your server. The value of IoT_ID should be an integer. You can leave it a 1 for your first device.
55 // Set the IoT ID: 56 IoT_ID = 1; 57
After completing all of the changes, compile and download the program to the mbed. The mbed will start connecting to the wifi network, and once successful, try to connect to your server. You can open up Tera Term to see the serial output of the microcontroller.
globals.h¶
Change Line 49 so that the SERVER_IP macro points to your computer where the WebSocket server is running.
48 #define WS_PORT 4444 49 #define SERVER_IP "192.168.1.99" 50
globals.cpp¶
Change Lines 43 and 44 to your Wifi's SSID and password, respectively.
43 char* wifissid = “HomeNetwork”; 44 char* wifipassword = “Pass”; 55
After completing all of the changes, compile and download the program to the mbed. The mbed will start connecting to the wifi network, and once successful, try to connect to your server. You can open up Tera Term to see the serial output of the microcontroller.
Next: Tour of the Code...