Click here to Skip to main content
15,881,413 members
Articles / Internet of Things
Article

Creating an application that communicates with your board using Web Sockets

Rate me:
Please Sign up or sign in to vote.
3.67/5 (2 votes)
17 May 2016CPOL2 min read 8.1K  
This simple Node.js project uses the socket.io Node.js module to enable real-time communication between a client and an Intel® Galileo board or Intel® Edison board.

This article is for our sponsors at CodeProject. These articles are intended to provide you with information on products and services that we consider useful and of value to developers

Get access to the new Intel® IoT Developer Kit, a complete hardware and software solution that allows developers to create exciting new solutions with the Intel® Galileo and Intel® Edison boards. Visit the Intel® Developer Zone for IoT.

This simple Node.js* project uses the socket.io Node.js module to enable real-time communication between a client and an Intel® Galileo board or Intel® Edison board. You can use the client-side application provided with this project to view the number of users connected to the board, send text messages between connected users, and turn an LED on the board on ad off.

For sample code and design considerations, including in-depth technical information about this application, see https://github.com/gomobile/iotapp-template-websockets.

Requirements

Creating a project

  1. Run the Intel XDK IoT Edition.
  2. In the top left, click the Projects tab.
  3. Click Start a New Project.

    Image 1
  4. Under Internet of Things Embedded Application, click Templates.

    Image 2
  5. From the right, click Web Sockets. Click Continue.
  6. Type a name for the project in the Project Name field, then click Create. Your new project opens.

    Image 3

Building and running your project

  1. To install the required Node.js modules for this project, click the Build/Install icon Image 4. If you are prompted to choose whether to upload or build your project, click Build.

    Image 5
  2. Once your project finishes building, a build complete message is displayed. Click the Upload icon Image 6 to upload the project to your board.
  3. Click the Run icon Image 7 to run your project.

Testing the Web Sockets Client Console

  1. In a web browser, type the IP address of your board, followed by a colon (:) and the port number to use to connect to your board, which in this example is 3000. For example, if the IP address of your board is 192.168.1.0, enter http://192.168.1.0:3000. The Web Sockets Client Console application opens, with a list of users currently connected to the board displayed under Connected Users.

    Note: If you don't know your board's IP address, open a serial or SSH connection with your board and enter the command: ifconfig. The IP address is displayed, as shown below.

    Image 8

  2. You can turn an onboard LED on your board on and off by clicking Toggle LED in your browser. Your actions are recorded under the Log heading. To send a message to other users, type a message in the field and click Send.

    Image 9

<

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United States United States
You may know us for our processors. But we do so much more. Intel invents at the boundaries of technology to make amazing experiences possible for business and society, and for every person on Earth.

Harnessing the capability of the cloud, the ubiquity of the Internet of Things, the latest advances in memory and programmable solutions, and the promise of always-on 5G connectivity, Intel is disrupting industries and solving global challenges. Leading on policy, diversity, inclusion, education and sustainability, we create value for our stockholders, customers and society.
This is a Organisation

42 members

Comments and Discussions

 
-- There are no messages in this forum --