![]() Starting the Server: The server is started with the server.begin() command, enabling it to listen for incoming requests.Routing Requests to Functions: The server.on("/", handleRoot) line establishes a routing mechanism, associating incoming requests to the root URL (“/”) with the handleRoot() function defined earlier.The board’s IP address is determined using WiFi.softAPIP() and displayed for reference. WiFi Configuration: The Wemos D1 board is configured to act as an Access Point ( WiFi.softAP(ssid, password)), with the specified SSID and password.Serial communication is initiated for debugging purposes. The delay(1000) provides a brief pause for stability. Setup Function: The setup() function is where the initial configuration of the WiFi Access Point and Server occurs.This function will be called whenever a client accesses the root URL of the server. It responds with a simple HTML message indicating that the user is connected. Handling Root Requests: The handleRoot() function is defined to manage incoming requests to the root URL (“/”).Creating the Server Object: The ESP8266WebServer object is instantiated as server(80), indicating that the server will operate on port 80, which is the default port for HTTP communication.By setting these constants ( APSSID and APPSK), users can customize their access point’s credentials. Defining SSID and Password: A section of the code handles the definition of the WiFi network’s SSID (name) and password.The ESP8266WiFi.h library enables communication with the WiFi module, WiFiClient.h facilitates interaction with WiFi clients, and ESP8266WebServer.h empowers the creation of a web server on the module. Library Inclusions: The code starts by including necessary libraries.*/ĭownload Code Understanding the Code Logic: * You can remove the password parameter if you want the AP to be open. Serial.print("Configuring access point.") nd(200, "text/html", "You are connected") Go to in a web browserĬonnected to this access point to see it. * Set these to your desired credentials. #include //Import ESP 8266 WiFi Webserver To execute our project, gather the following components:Īrduino Sketch #include //Import ESP 8266 WiFi library For detailed insights, delve into the realm of ESP8266. Others may display just “D1,” hinting at the AI Thinker’s ESP12 chip. Some boards sport the “WEMOS D1” label, indicating the presence of the ESP12 chip, a product of WEMOS. While R1 and R2 boards bear a striking resemblance to the Arduino UNO board, the version information isn’t explicitly printed on them. Variants like R1, R2, and MINI are available in the market. Our focal point in this tutorial is configuring the Wemos D1 Board to function as a WiFi Access Point (AP) and Server, opening the door to myriad possibilities.Įxploring Different Variants of Wemos D1 Boards Before we plunge into the setup process, it’s essential to grasp the diversity among Wemos D1 boards. Much like the renowned Arduino Uno Board, the Wemos D1 comes equipped with the ESP8266 chip on board, introducing an intriguing dimension to our creative projects. In this installment, we’re about to embark on an exciting journey of crafting basic projects with this versatile WiFi module. In our previous tutorial, we delved into the foundational aspects of the Wemos D1 WiFi module, featuring the powerful ESP8266 chip.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |