Main Content

WebSocket Publish

Publish data to WebSocket server in JSON format

Since R2020b

Add-On Required: This feature requires the Simulink Support Package for Arduino Hardware add-on.

  • Arduino WebSocket Publish icon

Simulink Support Package for Arduino Hardware / WiFi


The WebSocket Publish block publishes data from the Arduino® hardware 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 Arduino hardware, any device on the network can connect to the server and access the data.

Supported Arduino Boards

  • Arduino MKR1000

  • Arduino MKR WIFI 1010

  • Arduino Nano 33 IoT

  • Arduino compatible ESP32 – WROOM board

  • Arduino compatible ESP32 – WROVER board

WebSocket JSON Data

This figure shows the signals in JSON format.

JSON format for Arduino WebSocket Publish

If the JSON string size is more than 1024 bytes, the published data is replaced with the error messages.

Error Format for WebSocket Publish



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 the port number on the WebSocket server on which the JSON data is hosted.

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

Version History

Introduced in R2020b