Industrial Internet Application Development
上QQ阅读APP看书,第一时间看更新

Application-level protocols – WebSocket

In this section, we will try to build a simple IoT app for sending data from an XD-80 light sensor module to a receiver device, using a Raspberry Pi hub and the WebSocket protocol:

Data flow from an XD-80 sensor to a receiver device

WebSocket is most widely used in the case that one needs to enable fast transfer of real-time data. The protocol allows for two-way interaction between a client and a server, and for streaming multiple messages using the same TCP connection, which lowers the communications overhead.

In the following table, you can find a more detailed description of the protocol to understand whether it is suitable for your needs:

   
            
Key        Value
Open source        Yes
The OSI layer        Application
Data types        String
Limitations        Not suitable for large amounts of binary data
Possible operations        Send/receive data
Latency        Very low
Usage        Real-time communication
Security        Yes
Compression        Yes

 

Table 3: WebSocket protocol specifications

For building the application, we will need the following.

Required software:

Required hardware:

  • Raspberry Pi 3 (model B)
  • A power adapter (2A/5V)
  • A microSD card (8 GB+) and an SD adapter
  • A XD-80 light sensor module
  • A breadboard and a set of dupont cables
  • An Ethernet cable for a wired network connection