Site icon Iotguider

Build a simple Web Server using NodeMCU

Build a simple Web Server using NodeMCU

Build a simple Web Server using NodeMCU and Arduino IDE. Learn about connecting it to Wi-Fi and creating a web server using a sample text containing a web page.

Step 1: Required Components

NodeMCU Module x 1

Step 2: Code Time

This is code for Creating the NodeMCU web server. First, we initialized the server at port 80 and two constants for Wi-Fi SSID and Password. In setup, Serial started at 115200 baud to check the status of NodeMCU Connection. Wi-Fi begins to connect with SSID and Password and waited till it connects to the Wi-Fi. Print the Local IP to Serial monitor to use that address as the Web server address. Created an index page with the text “Hello! This is an index page.” using the server.on and server.send as you can see in code. And at last, Begin the Server. In loop, server.handleClient() is used for Handling incoming client requests




Step 3: Upload code to NodeMCU

Make a circuit as per the above-given diagram to upload code to NodeMCU. Make changes to SSID and Password in code and upload the code to NodeMCU using Arduino IDE. Open the Serial monitor IP in your browser after the Serial monitor shows “Server listening” It will look like as below given screenshot.

Learn programming NodeMCU with Arduino IDE.

Exit mobile version