Main Content

WiFi HTTP Client

Send and receive data from HTTP server over URL connection

Since R2023a

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

  • Arduino WiFi HTTP Client Block Icon

Libraries:
Simulink Support Package for Arduino Hardware / WiFi

Description

Use the WiFi HTTP Client block to send and receive data such as text from the remote server using the HTTP protocol. The Arduino® hardware acts as a client and can send HTTP requests to the remote server over an uniform resource locator (URL) connection. The block supports HTTP GET, POST, and PUT methods.

Supported Arduino Boards

  • Arduino MKR1000

  • Arduino MKR WIFI 1010

  • Arduino Nano 33 IoT

  • Arduino compatible ESP32 – WROOM board

  • Arduino compatible ESP32 – WROVER board

Ports

Input

expand all

The block inputs the URL of the server.

Tip

If you are using the String library blocks to create a URL, use a String to ASCII block to convert the string to uint8 vector. The WiFi HTTP Client block needs the URL as a uint8 vector input.

Data Types: uint8

The block inputs the data that the Arduino hardware sends as a payload of the request to the remote server.

Dependencies

  • To enable this port, select Request has payload input.

Data Types: uint8

Output

expand all

The port outputs the status of the HTTP request whether the request to the remote server.

  • 0 — Indicates any failure associated with the request sent to the server.

  • 1 — Indicates a successful request sent to the server.

  • 2 — Indicates an invalid response as the block waits to make the next HTTP request to the server.

Data Types: uint8

If the Status port outputs 0, then the Message port outputs the error message.

Dependencies

  • To enable this port, clear Request has response output.

Data Types: uint8

For every successful HTTP request sent to the server, the port outputs the response message. If the Status port outputs 0, then the Response port outputs the error message. If the Status port outputs 1, then the Response port outputs the response message.

Dependencies

  • To enable this port, select Request has response output.

Data Types: uint8

The port outputs the size of the response message data received from the server.

Dependencies

  • To enable this port, select Request has response output.

Data Types: int32

Parameters

expand all

Main

Select the HTTP request method to send a request message to the server from your Arduino hardware.

  • GET — This method requests data from a specified resource.

  • POST — This method sends data to a server to create or update a resource.

  • PUT — This method sends data to a server to create or update a resource.

Specify the number of seconds to wait between subsequent HTTP requests.

Select this option if the HTTP request contains payload data in any one of these formats: JSON or text.

Select the content type of the payload input of the HTTP request. In HTTP requests such as POST or PUT, the client informs the remote server on the type of data actually sent.

Dependencies

  • To enable this parameter, select Request has payload input.

Select this option if the HTTP response from the server contains payload data.

Enter the maximum length of the expected payload data response received from the server.

Dependencies

  • To enable this parameter, select Request has response output.

Select the format of the output payload data of the HTTP response which the client can understand.

Dependencies

  • To enable this parameter, select Request has response output.

Select this option to print diagnostic messages for each HTTP request on the Arduino serial port.

Advanced

Select the number of custom HTTP request headers. You can customize a header that contains one or more key-value pairs to provide more information about the request. The value 0 indicates that the HTTP request has no custom header.

Specify the HTTP request header key attribute. When you specify a value other than 0 in the Number of custom headers parameter, the block generates equal number of header keys. For example, if you set Number of custom headers to 2, the block generates two Key parameters.

Dependencies

  • To enable this parameter, set Number of custom headers to 1, 2, or 3.

Specify the value for the custom HTTP request header key. When you specify a value other than 0 in the Number of custom headers parameter, the block generates equal number of header values. For example, if you set Number of custom headers to 3, the block generates three Value parameters.

Dependencies

  • To enable this parameter, set Number of custom headers to 1, 2, or 3.

Version History

Introduced in R2023a