![]() Code for ESP Async Web ServerĬopy the following code to your Arduino IDE. Based on that URL, we change the state of GPIO 2 to 0 ( LOW) and turn the LED off. When that happens, make an HTTP GET request on the /update?output= 2&state= 0 URL. ![]() In the second example, when you toggle the button to turn GPIO 2 off. Based on that URL, we change the state of GPIO 2 to 1 ( HIGH) and turn the LED on.Ģ. When that happens, it makes an HTTP GET request on the /update?output= 2&state= 1 URL. In the first scenario, you toggle the button to turn GPIO 2 on. It works similarly for the other buttons.ġ. Let’s see what happens when you toggle the buttons. We’re connecting the LEDs to GPIOs 5, 4 and 2, but you can use any other GPIOs (read ESP8266 NodeMCU GPIO Reference Guide). You can use the preceding links or go directly to /tools to find all the parts for your projects at the best price!īefore proceeding to the code, wire 3 LEDs to the ESP8266. ESP8266 (read Best ESP8266 development boards).In this tutorial we’ll control three outputs. ![]() Take a look at the library documentation on its GitHub page. “Simple template processing engine to handle templates”.“When you send the response, you are immediately ready to handle other connections while the server is taking care of sending the response in the background”.“Handle more than one connection at the same time”.Building an asynchronous web server has several advantages as mentioned in the library GitHub page, such as: ![]() To build the web server we’ll use the ESPAsyncWebServer library that provides an easy way to build an asynchronous web server. You might also like: ESP32 Async Web Server – Control Outputs with Arduino IDE (ESPAsyncWebServer library) Asynchronous Web Server ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |