Main Content

WiFi UDP Send

R2026b

Send data to UDP host on wireless network

  • WiFi UDP Send block

Libraries:
Simulink Support Package for Arduino Hardware / WiFi

Description

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

The WiFi UDP Send block sends data to a UDP host over a wireless network. The block sends data from the port number specified in the Local IP Port parameter. Specify the IP address and the port number of the receiving host in the Remote IP address and the Remote IP Port parameters.

The block supports transmission of both fixed-length and variable-length UDP packets.

You can run a model containing the WiFi UDP Send block in connected IO mode on Arduino® boards.

For more information about the fixed ports and the allocated pins for the block, see Pin Mapping for Arduino Timer-Independent Blocks.

Note

If you are having trouble using UDP to communicate with a computer, antivirus or firewall software might be blocking UDP traffic. If so, configure the software to allow the traffic for a specific IP port number.

Supported Hardware

You can use the WiFi UDP Send block only with the following hardware:

  • ESP8266

  • WiFi Shield

  • MKR1000

  • MKR WIFI 1010

  • Nano 33 IoT

  • ESP32–S3 series (Arduino compatible)

  • ESP32–WROOM (Arduino compatible)

  • ESP32–WROVER (Arduino compatible)

Limitations

Ports

Input

expand all

The block accepts data as an N-by-1 array. The block sends this data over a wireless network to the receiving host. The data is sent in little-endian format. To convert it to a big-endian format, do any of the following:

The maximum number of bytes that can be sent by this block at each time step is shown in the table.

Target Hardware

ESP8266

WiFi Shield

Arduino On-board Wi-Fi Boards

Maximum Number of Sent Bytes

2048641400

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

Parameters

expand all

Specify the remote IP address of the host to which the data is sent. To broadcast data to all the receiving hosts, specify 255.255.255.255.

Specify the port number of the application on the host to which data is sent. Match the remote port number with the local port number on the receiving host.

Specify the port number of the application on the target from which data is sent.

Allow the block to process variable-length UDP data instead of a fixed-length payload. The block adjusts to the actual number of bytes available during the current write operation.

Enabling the option adds a two-byte length prefix at the start of the UDP payload. This prefix encodes the actual data size, allowing the receiver to reliably reconstruct the message length and correctly parse the packet contents even when the payload varies at runtime.

To use variable-length UDP transmission and reception in a model, you must enable this parameter on both the WiFi UDP Receive and WiFi UDP Send blocks.

Version History

Introduced in R2014a

expand all