yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
ESP32 Core Board📖
1. ESP32 Introduction
  • 1. ESP32S3 Overview
  • 2. Environment Setup Introduction
  • 3. Dev Board Introduction
2. ESP-IDF Development Tutorial
1. Before Development
  • 1. Environment Setup (Windows)
  • 2. Environment Setup (Linux)
  • 3. Build and Flash
2. Basic Peripherals
  • 1. LED Control
  • 2. Button Detection
  • 3. Peripheral Interrupts
  • 4. ESP_TIMER
  • 5. GPTIMER
  • 6. Watchdog Timer
  • 7. DMA
  • 8. ADC
  • 9. PWM Breathing LED
  • 10. RGB LED Effects
3. Serial Communication and Storage System
  • 1. Serial UART Communication Experiment
  • 2. I2C_OLED Display Experiment
  • 3. SPI Bus Communication Experiment
  • 4. PSRAM External Memory Experiment
  • 5. Flash Read and Write Experiment
  • 6. USB Emulated Mass Storage Experiment
4. FreeRTOS operating system
  • 1.FreeRTOS Core Concepts Theory
  • 2.Task Creation and Management
  • 3.Queue
  • 4.Binary Semaphore
  • 5.Mutex
  • 6.Event Groups
  • 7.Software Timer
  • 8.Task Scheduler
  • 9.Low Power Mode
  • 10.Deadlock
  • 11.Priority Inversion
5. Network Protocols and Wireless Communication
  • 1. WIFI Network Basics
  • 2. WIFI STA Mode
  • 3. WIFI AP Mode
  • 4. UDP Client Experiment
  • 5. UDP Server Experiment
  • 6. TCP Client Experiment
  • 7. TCP Server Experiment
  • 8. Socket Programming Basics
  • 9. HTTP Client Experiment
  • 10. HTTP Server Experiment
  • 11. MQTT IoT Communication Protocol
  • 12. WIFI OTA Upgrade
  • 13. Bluetooth Fundamentals
  • 14. Bluetooth Slave Mode
  • 15. Bluetooth Master Mode
6. Audio Applications
  • 1.I2S Microphone Recording and U-Disk Playback
  • 2.I2S Audio Playback Experiment
  • 3.Repeater Experiment
7. Xiaozhi AI Voice
  • 1. Burn Xiaozhi Firmware
  • 2. Network and Configuration
  • 3. AI Agent Settings
  • 4. Program Analysis
  • 5. Free Chat
3. Arduino Development Course
1. Before Development
  • 1. Environment Setup
  • 2. Build and Flash
2. Basic Peripherals
  • 1. LED Control
  • 2. Button Detection
  • 3. Peripheral Interrupts
  • 4. ESP_TIMER
  • 5. GPTIMER
  • 6. Watchdog Timer
  • 7. ADC
  • 8. PWM Breathing LED
  • 9. RGB LED Effects
3. Serial Communication and Storage System
  • 1. Serial UART Communication
  • 2. I2C OLED Display
  • 3. SPI Bus Communication
  • 4. Flash Read and Write
  • 5. USB Emulated Mass Storage
4. Network Protocols and Wireless Communication
  • 1. WIFI Network Basics
  • 2. WIFI STA Mode
  • 3. WIFI AP Mode
  • 4. UDP Server Experiment
  • 5. UDP Client Experiment
  • 6. TCP Client Experiment
  • 7. TCP Server Experiment
  • 8. HTTP Client Experiment
  • 9. HTTP Server Experiment
  • 10. MQTT IoT Communication Protocol
  • 11. WIFI OTA Upgrade
  • 12. Bluetooth Fundamentals
  • 13. Bluetooth Slave Mode
  • 14. Bluetooth Master Mode
5. Audio Applications
  • 1.I2S Microphone Recording and U-Disk Playback
  • 2.I2S Audio Playback Experiment
  • 3.Repeater Experiment
4. MicroPython Development Course
1. Before Development
  • 1. Environment Setup
  • 2. Build and Flash
  • 3. Thonny IDE
2. Basic Peripherals
  • 1. LED Control
  • 2. Button Detection
  • 3. Peripheral Interrupts
  • 4. TIMER_IT
  • 5. Watchdog Timer
  • 6. ADC
  • 7. PWM Breathing LED
  • 8. RGB LED Effects
3. Serial Communication and Storage System
  • 1. Serial UART Communication Experiment
  • 2. I2C_OLED Display Experiment
  • 3. SPI Bus Communication Experiment
  • 4. Flash Read and Write Experiment
  • 5. Print Storage
4. Network Protocols and Wireless Communication
  • 1. WIFI Network Basics
  • 2. WIFI STA Mode
  • 3. WIFI AP Mode
  • 4. UDP Client Experiment
  • 5. UDP Server Experiment
  • 6. TCP Client Experiment
  • 7. TCP Server Experiment
  • 8. HTTP Client Experiment
  • 9. HTTP Server Experiment
  • 10. MQTT
  • 11. Bluetooth Fundamentals
  • 12. Bluetooth Slave Mode
  • 13. Bluetooth Master Mode
5. Audio Applications
  • 1. I2S Audio Playback Experiment
  • 2. Repeater Experiment
Download
  • Code
  • Hardware_Info
  • 3D_Model_File
  • Software_Tools
  • VMware
  • VM_File
Download ZIP

Welcome to ESP32 Core Board repository

9. HTTP Server Experiment

HTTP Server Experiment


HTTP Server Experiment1. HTTP Server Overview2. Core Concepts2.1 HTTP Request Parsing2.2 HTTP Response Construction2.3 Configuration Parameters3. Hardware Dependencies4. Project Architecture and Flow5. Source Code Explained5.1 Main Program6. Operating Procedures6.1 Flashing and Running6.2 Serial Output Example6.3 Expected Results6.4 Verification Methods6.5 Postman Testing7. Common Problems


1. HTTP Server Overview

This experiment runs a simple HTTP server on the ESP32-S3; a PC browser accessing http://<ESP32_IP> shows a device information page. The server accepts one connection, returns HTML, and exits.

Typical application scenarios:

Application TypeExample
Web provisioningPhone connects to ESP32 hotspot -> enter IP in browser -> provision via web page
Device management panelBrowser views sensor data, controls relays
REST APIOther devices call the ESP32 API over HTTP

2. Core Concepts

2.1 HTTP Request Parsing

GET / HTTP/1.1\r\n
Host: 192.168.1.105\r\n
Accept: */*\r\n
\r\n

The server parses three parts: request line (method + path) -> headers -> blank line.

2.2 HTTP Response Construction

xxxxxxxxxx
resp = f"HTTP/1.1 200 OK\r\n" \
       f"Content-Type: text/html; charset=utf-8\r\n" \
       f"Content-Length: {len(body)}\r\n" \
       f"Connection: close\r\n\r\n{body}"

Status line + Content-Type + Content-Length + blank line separator + response body.

2.3 Configuration Parameters

ParameterDescriptionValue Used in This Experiment
LISTEN_PORTESP32 listen port80

3. Hardware Dependencies

The ESP32-S3 has built-in WiFi. The client only needs a browser on the same LAN as the ESP32-S3.


4. Project Architecture and Flow

xxxxxxxxxx
Script execution (single-file .py)
  |
  |- wifi_connect(): connect to WiFi (STA mode)
  |- create Server socket -> bind(80) -> listen(3)
  |
  |- while True:
       |- accept(): block waiting for browser connection
       |- recv(): read the request
       |- print the request line
       |- construct HTML (with real-time memory/runtime)
       |- sendall(): return the response
       |- close() -> continue waiting for the next one

5. Source Code Explained

Full source code: Source Code -> MicroPython -> 4.Network Protocols -> HTTP_Server -> HTTP_Server.py

5.1 Main Program

bind(80) -> listen(3) -> while True loop -> accept() blocks waiting for a browser connection -> read the request -> print the request line -> construct HTML with real-time memory data -> sendall returns -> close -> continue waiting for the next one.

​x
def main():
    wlan = wifi_connect(WIFI_SSID, WIFI_PASS)     # connect to WiFi
​
    server = socket.socket(socket.AF_INET, socket.SOCK_STREAM)  # TCP socket
    server.bind(("0.0.0.0", LISTEN_PORT))         # bind port 80
    server.listen(3)                               # start listening
    ip = wlan.ifconfig()[0]
    print(f"[HTTP] Server: http://{ip}:{LISTEN_PORT}/")
    print("Press Ctrl+C to stop")
​
    while True:
        conn, addr = server.accept()               # block until accept
        print(f"[TCP] New connection: {addr[0]}:{addr[1]}")
​
        raw = conn.recv(4096).decode("utf-8")      # read request
        if raw:
            print(f"[HTTP] {raw.split(chr(13))[0]}")  # print request line
​
        free = gc.mem_free()                       # free heap
        total = gc.mem_alloc() + free              # total heap
        body = f"""\
<html>
<head><meta charset="utf-8"><title>ESP32-S3</title></head>
<body>
<h1>ESP32-S3 HTTP Server</h1>
<p>Free Memory: {free / 1024:.0f} KB</p>
<p>Total Memory: {total / 1024:.0f} KB</p>
<p>Uptime: {time.ticks_ms() / 1000:.0f}s</p>
</body>
</html>"""
        resp = f"HTTP/1.1 200 OK\r\nContent-Type: text/html; charset=utf-8\r\nContent-Length: {len(body)}\r\nConnection: close\r\n\r\n{body}"
        conn.sendall(resp.encode("utf-8"))         # send response
        print(f"[HTTP] 200 {len(body)} bytes")
​
        conn.close()
        gc.collect()                               # collect garbage

6. Operating Procedures

6.1 Flashing and Running

Thonny IDE steps: See MicroPython -> 1. Before Development -> 3.Thonny IDE.

  1. Modify WIFI_SSID / WIFI_PASS

    修改WiFi和PORT

  2. Run HTTP_Server.py and note the address printed on the serial port

    打印地址

  3. Open http://<ESP32_IP>/ in a browser

    网页查询

6.2 Serial Output Example

xxxxxxxxxx
===== ESP32-S3 HTTP Server =====
[WiFi] Already connected. IP: 192.168.11.229
[HTTP] Server: http://192.168.11.229:80/
Press Ctrl+C to stop
[TCP] New connection: 192.168.11.183:64574
[HTTP] GET / HTTP/1.1
[HTTP] 200 194 bytes
[TCP] New connection: 192.168.11.183:64586
[HTTP] GET /get?msg=hello HTTP/1.1
[HTTP] 200 194 bytes

串口打印

6.3 Expected Results

After opening the browser, the ESP32-S3 device information and real-time memory data are displayed. Refreshing the page multiple times always shows updated memory data.

6.4 Verification Methods

Browser accesses http://<IP>/Displays an HTML page with memory/runtime
Refresh the browser multiple timesReturns the latest real-time data each time
Ctrl+C to stopThe server shuts down

6.5 Postman Testing

Start Postman Server工具Postman create a GET request, and enter the ESP32's IP and port in the URL:

GET http://<ESP32_IP>/ -> returns

xxxxxxxxxx
<html>
<head>
    <meta charset="utf-8">
    <title>ESP32-S3</title>
</head>
<body>
    <h1>ESP32-S3 HTTP Server</h1>
    <p>Free Memory: 169 KB</p>
    <p>Total Memory: 175 KB</p>
    <p>Uptime: 2094s</p>
</body>
</html>

Postman新建需求

 

Postman访问

 


7. Common Problems

SymptomCauseSolution
Browser cannot open the pagePort 80 occupied or firewall blockingEnsure the ESP32 and PC are on the same LAN
Garbled pagecharset=utf-8 not setThe response Content-Type already includes charset=utf-8
HTTP Client Experiment
MQTT

COMPANY

  • About us
  • Team Style
  • Blog

LEARNING & EXPLORATION

  • Tutorials
  • Edge AI hardware
  • Educational robots
  • Embedded intelligent hardware

WHERE TO BUY

  • Yahboom Online Store
  • Amazon
  • Alibaba
  • AliExpress
  • Mercado

TECHNOLOGY SUPPORT

  • Email: support@yahboom.com

BE A DISTRIBUTOR

  • Email: sales@yahboom.com
QR Code
QR Code

Copyright © 2017-2026 Yahboom. All Rights Reserved.

EN/中文