ESP32 Documantation
ESP32 Documantation
(ESP32)
Introduction:
As we have used ESP32 as a microcontroller for our project. The ESP32 microcontroller has become a
pivotal tool in the realm of IoT (Internet of Things), offering robust capabilities in wireless connectivity and
control. This report delves into a project aimed at controlling home appliances through a web interface
using the ESP32, MicroPython, and MicroWebSrv framework.
Code Walkthrough:
The core of the project involves setting up a web server (MicroWebSrv) on the ESP32, defining
routes for handling HTTP requests, and interacting with GPIO pins to control devices.
Route Definition: Routes are defined using tuples specifying URL paths, HTTP methods, and
corresponding handler functions.
Handler Functions: Functions are defined to handle GET and POST requests. For example,
index_handler serves the main web page, while control_handler processes control commands
from the web interface.
GPIO Interaction (main.py)
GPIO Pin Setup: GPIO pins on the ESP32 are configured for input (e.g., sensors) and output
(e.g., relays controlling appliances).
Request Processing: HTTP requests from the web interface trigger GPIO operations. For
instance, turning on a light involves setting a specific GPIO pin high.
Web Interface (index.html, style.css, script.js)
HTML Structure: index.html defines the structure of the web interface, including buttons and
input fields for user interaction.
CSS Styling: style.css provides aesthetic styling to the web interface, enhancing user
experience.
JavaScript: script.js contains client-side scripting to handle user events and send requests to the
ESP32 web server.
Request Handling (MicroWebSrv/_client.py)
HTTP Request Parsing: The _client class parses incoming HTTP requests, extracts parameters,
and identifies the requested resource.
Response Generation: Based on the request type (GET, POST), appropriate responses are
generated. Responses can include HTML content, JSON data, or file downloads.
References:
https://docs.micropython.org
https://github.com/jczic/MicroWebSrv