# ESP32 LED Brightness Control with OTA Firmware Updates
This project implements an LED brightness control system on an ESP32 microcontroller using Pulse Width Modulation (PWM) and integrates Over-the-Air (OTA) firmware updates. The LED brightness can be adjusted through a web interface, with real-time updates via WebSocket communication.
## Features
- **PWM-based LED Brightness Control**: Adjust the brightness of the LED using PWM on the ESP32.
- **Web Interface with Slider**: Control LED brightness through a user-friendly webpage with a slider.
- **Real-Time WebSocket Communication**: Send and receive brightness updates instantly between the web interface and ESP32.
- **Over-the-Air (OTA) Updates**: Update the firmware remotely without needing a physical connection to the device.
## Components Used
- **ESP32** microcontroller
- **LED** for brightness control (connected to a PWM-capable pin)
## Getting Started
### Prerequisites
- **Arduino IDE**: Ensure that you have installed the [Arduino IDE](https://www.arduino.cc/en/software).
- **ESP32 Board Manager**: Install the ESP32 board in the Arduino IDE. You can find instructions [here](https://randomnerdtutorials.com/installing-the-esp32-board-in-arduino-ide-windows-instructions/).
- **Libraries**:
- `WiFi.h`
- `ESPAsyncWebServer.h`
- `ArduinoOTA.h`
- `AsyncTCP.h`
- `ESPAsyncWebSocket.h`
### Installation
1. Clone this repository:
```bash
git clone https://github.com/your-username/ESP32-LED-Brightness-OTA-Control.git- Open the project in the Arduino IDE.
- Install any missing libraries using the Arduino Library Manager or add them manually.
- Connect to WiFi: Replace
YOUR_SSIDandYOUR_PASSWORDin the code with your WiFi credentials. - Upload the Code:
- Connect your ESP32 to your computer and upload the code from the Arduino IDE.
- Open Serial Monitor to verify WiFi connection and see the IP address assigned to the ESP32.
- Access the Web Interface:
- Open a web browser and enter the ESP32’s IP address to access the LED control interface.
- Use the slider to adjust the brightness. Changes will be reflected in real-time through WebSocket.
- OTA Updates:
- After the first upload, subsequent updates can be done OTA via the Arduino IDE by selecting
Tools > Port > esp32with the correct IP address.
- After the first upload, subsequent updates can be done OTA via the Arduino IDE by selecting
- PWM Control: PWM is set up on the LED pin, allowing brightness control based on the slider's input value.
- Web Server and WebSocket:
- A basic web server serves the HTML interface with a slider.
- WebSocket communication enables real-time brightness adjustments between the ESP32 and the client.
- OTA Setup: Initializes OTA functionality, allowing firmware updates over WiFi without a physical connection.
ESP32-LED-Brightness-OTA-Control/
├── ESP32-LED-Brightness-OTA-Control.ino # Main code file
└── README.md # Project documentation
Feel free to fork this project and submit a pull request. Please ensure that any contributions are well-documented and tested.
This project is open-source and available under the MIT License.
- Random Nerd Tutorials for OTA and WebSocket guidance.
- Circuit Digest for tutorials on ESP32 functionality.