0% found this document useful (0 votes)
35 views2 pages

ESP32 Documantation

11111111111111111111111111111111111111111111

Uploaded by

Adam Khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views2 pages

ESP32 Documantation

11111111111111111111111111111111111111111111

Uploaded by

Adam Khan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

MICROCONTROLLER

(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.

ESP (Project Overview):


The project aims to create a web server hosted on the ESP32, allowing users to control
connected home appliances through a web interface. This is achieved using MicroPython, a
lean implementation of Python 3 for microcontrollers, and MicroWebSrv, a lightweight web
server specifically designed for microcontrollers like the ESP32.

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.

MicroWebSrv Setup (MicroWebSrv.py)


The MicroWebSrv.py script initializes the web server with specified configurations:
Port and IP Binding: Defines the port (default: 80) and IP address (default: '0.0.0.0') for the
web server.
Web Path: Specifies the path (/flash/www) where web files are stored on the ESP32 filesystem.
Routing and Request Handling

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:

 Espressif Systems. (n.d.). ESP32 Overview. Retrieved from


https://www.espressif.com/en/products/socs/esp32/overview

 MicroPython Documentation. (n.d.). Retrieved from:

https://docs.micropython.org

 MicroWebSrv GitHub Repository. (n.d.). Retrieved from:

https://github.com/jczic/MicroWebSrv

You might also like