ESP32 S3 - HTTP Request
The ESP32 S3 has built-in Wi-Fi that makes it straightforward to act as an HTTP client — sending requests to web servers, REST APIs, and web services. This tutorial walks you through making HTTP GET and POST requests from the ESP32 S3, including how to attach sensor data to those requests and how to process the server's response.
What you'll build:
- An ESP32 S3 sketch that connects to Wi-Fi and sends an HTTP GET request to a remote server or API endpoint
- A sketch that includes live sensor data (temperature and humidity) in the HTTP query string of a GET request
- A sketch that sends sensor data in the body of an HTTP POST request using URL-encoded form data
- A complete working example that reads the HTTP response and prints the server reply to the Arduino IDE Serial Monitor


Hardware Preparation
Or you can buy the following kits:
| 1 | × | DIYables ESP32 S3 Starter Kit (ESP32 S3 included) | |
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables .
Basic Concepts of Web Client and Web Server
Understanding a few core HTTP concepts makes it much easier to build reliable requests from the ESP32 S3. Key ideas include the URL structure (hostname and pathname), query strings for passing data, HTTP methods (GET vs POST), and how the server's response code tells you whether the request succeeded. You can learn more about these in the HTTP tutorial.
How to Make an HTTP Request
The following steps show the building blocks needed to send an HTTP request from the ESP32 S3 using the built-in WiFi and HTTPClient libraries.
- Include libraries
- Declare WiFi SSID and password
- Declare hostname, pathname, query string
- Declare a HTTP client object
- If connected to server, send an HTTP request. For example, HTTP GET:
- Read the response data from the web server
How to Include Data in an HTTP Request
Sending sensor readings or other values to a web server requires encoding that data inside the HTTP request. The correct approach depends on whether you use GET or POST: GET requests carry data in the URL query string, while POST requests place data in the request body and can support formats beyond query strings such as JSON or XML.
The steps below show how to send data in query string format for both methods.
- Create a query string
- HTTP GET: add query string to pathname
- HTTP POST: put query string in HTTP body
- For both GET and POST, read the response data from the web server
ESP32 S3 Code
Complete ESP32 S3 Code for Making HTTP Request
The following sketch is the complete ESP32 S3 code for making an HTTP GET or POST request. It connects to your Wi-Fi network, opens an HTTP connection to the configured host and path, sends the request, reads the server response, and prints the result to the Serial Monitor. Replace the placeholder credentials and URL before uploading.
Detailed Instructions
- New to ESP32 S3? Complete our Getting Started with ESP32 S3 guide first.
- Connect the ESP32 S3 board to your PC using a USB Type-C cable.
- Open the Arduino IDE on your PC.
- In the Arduino IDE, select the correct board (ESP32S3 Dev Module or equivalent) and COM port under Tools.

- Copy the sketch above and open it in the Arduino IDE.
- Update YOUR_WIFI_SSID and YOUR_WIFI_PASSWORD with your network credentials.
- Update HOST_NAME and PATH_NAME with the server address and endpoint you want to reach.
- Click the Upload button to compile and flash the sketch to the ESP32 S3.
- Once the upload is complete, open the Serial Monitor from the Tools menu or the monitor icon.

- Set the baud rate to 115200 in the Serial Monitor dropdown.
- Watch the Serial Monitor for the Wi-Fi connection status and the HTTP response from the server.
- Pro Tip: If the request fails with a negative error code, check that your ESP32 S3 is within Wi-Fi range and that the target server is reachable from your network — firewalls and HTTPS-only endpoints are common causes of connection failures.
Line-by-line Code Explanation
The above ESP32 S3 code contains line-by-line explanation. Please read the comments in the code!
Serial Monitor Output
When the ESP32 S3 successfully connects to Wi-Fi and completes an HTTP request, the Serial Monitor will display output similar to the following:
ESP32 S3 Code
Complete ESP32 S3 Code for Making HTTP GET Request with Data
The following sketch extends the basic HTTP example by reading sensor values and appending them as a query string to the GET request URL. This is a common pattern for logging environmental data such as temperature and humidity to a remote server or IoT platform.
Detailed Instructions
- New to ESP32 S3? Complete our Getting Started with ESP32 S3 guide first.
- Connect the ESP32 S3 board to your PC using a USB Type-C cable.
- Open the Arduino IDE on your PC.
- Copy the sketch above and open it in the Arduino IDE.
- Update the Wi-Fi credentials and target URL with your values.
- Click the Upload button to flash the sketch to the ESP32 S3.
- Open the Serial Monitor at 115200 baud to see the request URL and server response.
- Pro Tip: Use a free service such as RequestBin or Webhook.site to capture and inspect the exact query string your ESP32 S3 sends — it is an easy way to verify data is formatted correctly before connecting to your real backend.
Line-by-line Code Explanation
The above ESP32 S3 code contains line-by-line explanation. Please read the comments in the code!
Serial Monitor Output
When the GET-with-data sketch runs on the ESP32 S3, the Serial Monitor will display output similar to the following, showing the query string appended to the request and the server's reply:
ESP32 S3 Code
Complete ESP32 S3 Code for Making HTTP POST Request with Data
The following sketch sends sensor data to a server using an HTTP POST request, placing the URL-encoded key-value pairs in the request body rather than the URL. POST is preferred when sending larger payloads or when you want to keep data out of server access logs.
Detailed Instructions
- New to ESP32 S3? Complete our Getting Started with ESP32 S3 guide first.
- Connect the ESP32 S3 board to your PC using a USB Type-C cable.
- Open the Arduino IDE on your PC.
- Copy the sketch above and open it in the Arduino IDE.
- Update the Wi-Fi credentials and server URL with your values.
- Click the Upload button to flash the sketch to the ESP32 S3.
- Open the Serial Monitor at 115200 baud to confirm the POST was sent and view the server's response.
- Pro Tip: Set the Content-Type header to application/json and format the body as a JSON string if your server or API endpoint expects JSON instead of URL-encoded form data.
Line-by-line Code Explanation
The above ESP32 S3 code contains line-by-line explanation. Please read the comments in the code!
Serial Monitor Output
When the POST-with-data sketch is running on the ESP32 S3, the Serial Monitor will display output similar to the following:
Application and Project Ideas
The ESP32 S3's Wi-Fi capability and the HTTPClient library open up a wide range of real-world connectivity applications. Here are some directions worth exploring:
- IoT data logger: Periodically send temperature, humidity, or other sensor readings to a cloud database such as ThingSpeak or InfluxDB via HTTP POST.
- Home automation trigger: Send an HTTP GET request to a home automation hub (such as Home Assistant) to toggle lights, switches, or scenes from a physical button wired to the ESP32 S3.
- REST API consumer: Query a public weather, stock, or sports API over HTTP and display the parsed JSON response on an OLED or LCD screen.
- Sensor dashboard: POST live sensor data to a lightweight web server running on your local network and display readings on a browser-based dashboard.
- Alert system: Send an HTTP request to a messaging service (such as Pushover or IFTTT) when a sensor threshold is exceeded — for example, high temperature or a motion detection event.
- Firmware update notifier: Query a server endpoint to check whether a new firmware version is available and display a notice to the user before triggering an OTA update.
Video Tutorial
Watch the step-by-step video walkthrough for this ESP32 S3 project below.
Challenge Yourself
Once the basic HTTP request is working on your ESP32 S3, there are several ways to deepen your understanding and build more capable network-connected projects. Try the challenges below in order of difficulty:
- Beginner: Modify the sketch to print the full HTTP response headers to the Serial Monitor using http.collectHeaders().
- Beginner: Add a physical pushbutton to the ESP32 S3 so that pressing it triggers an HTTP GET request instead of sending on a timer.
- Intermediate: Parse a JSON response from the server using the ArduinoJson library and display a specific field value on the Serial Monitor.
- Intermediate: Implement a retry loop that resends the HTTP request up to three times if the server returns a non-200 status code or the connection times out.
- Advanced: Switch from HTTP to HTTPS by using WiFiClientSecure and a server certificate fingerprint, then confirm the ESP32 S3 can reach a TLS-secured API endpoint.
- Advanced: Build a multi-endpoint data router that reads from two different sensors and POSTs each sensor's data to a different server endpoint based on the sensor type.