Main Content

WebSocket Publish

Publish data to WebSocket server in JSON format

Since R2019b

  • Raspberry Pi WebSocket Publish icon

Simulink Support Package for Raspberry Pi Hardware / Network


The WebSocket Publish block publishes the data from the Raspberry Pi® to a WebSocket server identified by an IP address and a port. The published data is in JavaScript Object Notation (JSON) format, which can be interpreted by a WebSocket client to visualize the data.

If the WebSocket server is hosted on a network IP address, any device on the network can connect to the sever and access the data.

WebSocket JSON data

This figure shows the signals in JSON format with a unique block label.

WebSocket JSON Data



expand all

The signal data to be published to the WebSocket server, specified as a row vector.

The block provides an option to add up to 10 Signal input ports that you can use to obtain signal data, with each signal being a row vector.

Example: [1.5,3]

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean


expand all

Specify a unique label for the block to identify the published JSON data (which gets created from the input signal data). The label can have a maximum of 128 characters.

IP address of the WebSocket server on which the JSON data is hosted.

Specify the port number on the WebSocket server on which the JSON data is hosted.


You can use multiple Websocket Publish blocks in a Simulink model if the Server IP address and Server Port parameters are unique.

Select the total number of input signal connections to the block, which is then converted to JSON format.

Version History

Introduced in R2019b