Click the blue text above to follow us

The previous note “ESP32-S3 Camera Captures Photos at 1600X1200 Resolution” implemented capturing a high-resolution photo using the camera. This time, we will use the camera to achieve real-time image transmission on a webpage.
1.Web Image Transmission Effect
ESP32-S3 calls the camera to transmit the captured image in real-time to a webpage built with Microdot, as shown below:
2.Microdot Introduction
Microdot is a lightweight web framework based on MicroPython that provides a simple and lightweight solution for web development.
Microdot has characteristics such as ease of use, lightweight, and scalability. It can generate a simple webpage with just a few functions, making it very suitable for building small web applications or IoT devices in resource-constrained environments.

GitHub sometimes doesn’t work well, so I put the library on Gitee, feel free to download it if needed:
https://gitee.com/py2012/hezhou-esp32-s3-camera.git
3.Test Code
The principle of web image transmission: call the network library to send the captured image from the camera to a simple webpage built with Microdot, achieving real-time video.
The ESP32-S3 connection code is as follows:
def connect(): wlan = network.WLAN(network.STA_IF) wlan.active(True) if not wlan.isconnected(): print('ESP32-S3 is connecting to the network...') wlan.connect('SSID', 'password')# Modify WiFi account and password here while not wlan.isconnected(): pass print('Network information: ', wlan.ifconfig()) ifconfig = wlan.ifconfig() print('Please open in the browser: {}:5000'.format(ifconfig[0]))
The complete code is as follows:
from microdot import Microdotimport timeimport cameraimport networkdef connect(): wlan = network.WLAN(network.STA_IF) wlan.active(True) if not wlan.isconnected(): print('ESP32-S3 is connecting to the network...') wlan.connect('20', '') while not wlan.isconnected(): pass print('Network information: ', wlan.ifconfig()) ifconfig = wlan.ifconfig() print('Please open in the browser: {}:5000'.format(ifconfig[0]))connect()app = Microdot()# Initialize camerafor i in range(5): cam = camera.init(0, d0=6, d1=47, d2=48, d3=7, d4=12, d5=10, d6=38, d7=40, format=camera.JPEG, framesize=camera.FRAME_HVGA, xclk_freq=camera.XCLK_10MHz, href=41, vsync=42, reset=45, pwdn=-1, sioc=46, siod=21, xclk=39, pclk=11) print(