Group assignment
Individual assignments
For this week’s Interface and Application Programming assignment, I used the output board I previously designed.
implemented a simple web server using the ESP32-C3. The web interface allowed basic control of the connected output components, such as motors or LEDs. This setup demonstrated how a user can interact with hardware remotely through a browser-based application.
Interface and Application Programming focuses on creating user-friendly ways to interact with embedded systems. It involves designing interfaces—such as web pages, GUIs, or mobile apps—to control or monitor devices. This week emphasizes bridging hardware with software, enabling real-time control and feedback through programming languages, communication protocols, and visual tools.
So, I created a simple web page by integrating HTML code within the Arduino sketch. This web interface allows me to control the hardware remotely. I plan to test this setup further, and if it performs reliably, I will implement the same approach in my final project.
This technique involves embedding HTML code directly into an Arduino sketch, allowing the Arduino (e.g., ESP32) to act as a web server. When connected to Wi-Fi, it serves a web page to any browser on the same network, enabling remote control of hardware through a web interface.
What Is HTTP?
How Does It Work in Your ESP32 Project?
Protocol Stack (Technical Layer View)
Limitations of HTTP
Library Imports and Wi-Fi Setup
These lines include required libraries and set up the WiFi credentials. WiFi.h connects to your router, and WebServer.h lets us serve a web interface.
Define Motor Pins
These pins control the two motors using an H-bridge driver. Each motor has two direction pins and one PWM pin for speed control.
Web Server Initialization
This sets up a web server that listens on the default HTTP port (80).
HTML Page for Motor Control Interface
This is the web page you’ll control motors with. It has buttons for forward, backward, and stop, and a slider for speed control (with direction). The slider sends values between -50 to +50.
Handle Homepage Request
When someone opens the ESP32’s IP in a browser, this function sends the interface.
Handle Slider Input (Speed & Direction)
This function reads the slider value from the web interface and sets motor direction and speed accordingly. Negative = backward, positive = forward, 0 = stop.
Handle Forward Button
This sets both motors to move forward at full speed.
Handle Backward Button
This sets both motors to move backward at full speed.
Handle Stop Button
Stops both motors by cutting off direction and PWM.
Setup Function
This function connects to Wi-Fi, initializes pins, sets up the routes/URLs, and starts the server.
Loop Function
This keeps the server running, handling incoming HTTP requests from the browser.
In the final version of my web page, I embedded the HTML code directly within the Arduino (.ino) file. This allowed me to create a self-contained web server on the ESP32-C3. Through this interface, I was able to control hardware components like motors and LEDs via a web browser.