This repository contains Arduino code for a simple web server running on an ESP8266/ESP32 microcontroller. The web server allows you to control the state of a digital output pin (connected to an LED or any other device) using a toggle switch on a web page.
-
Clone this repository:
git clone https://github.com/your-username/esp-web-server.git
-
Open the Arduino IDE.
-
Install the required libraries:
- ESPAsyncWebServer: In the Arduino IDE, go to Sketch > Include Library > Manage Libraries, search for "ESPAsyncWebServer" and install it.
-
Connect your ESP8266/ESP32 to your computer.
-
Open the
esp-web-server.ino
file in the Arduino IDE. -
Replace the following placeholder values in the code:
Network_name
andNewtor_password
with your WiFi network credentials.
-
Upload the code to your ESP8266/ESP32.
-
Open the Serial Monitor (Tools > Serial Monitor) to view the ESP's IP address once connected to the WiFi network.
-
Open a web browser and navigate to the provided IP address. You should see a web page with a toggle switch to control the connected device.
- The main web page allows you to toggle the state of the connected device using a switch.
- The state of the connected device is updated in real-time on the web page.
- You can also check the current state of the device by sending a GET request to
/state
.
Feel free to customize the HTML, CSS, and JavaScript in the index_html
variable to match your specific requirements.
This project is licensed under the MIT License - see the LICENSE file for details.