WiFi.begin(ssid, password) //Connect to your WiFi router nd(200, "text/html", "LED is OFF") //Send ADC value only to client ajax request nd(200, "text/html", "LED is ON") //Send ADC value only to client ajax request nd(200, "text/html", s) //Send web pageĭigitalWrite(LED,LOW) //LED is connected in reverse String s = MAIN_page //Read HTML contents This routine is executed when you open its IP in browser Declare a global object variable from the ESP8266WebServer class.ĮSP8266WebServer server(80) //Server on port 80
Our HTML webpage contents in program memoryĬonst char MAIN_page PROGMEM = R"=(Ĭonst char* deviceName = "" Ĭonst char* password = "yourWiFipassword" * ESP8266 NodeMCU LED Control over WiFi Demo
#Ostoto hotspot ip address code#
This code makes a NodeMCU as webserver and controls onboard LED using web interface.Ĭhange the IP settings, SSID and Password as per your WiFi router and upload. } Complete Code of ESP8266 using Static IP address WiFi.mode(WIFI_STA) //WiFi mode station (connect to wifi router only WiFi.hostname(deviceName) // DHCP Hostname (useful for finding device for static lease) Note That: Sequence of nfig is important, first IPaddress, then subnet then gateway and last is DNS WiFi.disconnect() //Prevent connecting to wifi based on previous configuration WiFi.hostname is optional, it is used to give name to ESP to identify in WiFi router. Static ip configuration can be applied to ESP using nfig statement. IPAddress subnet(255, 255, 255, 0) //Subnet maskĬonst char* deviceName = "" Step 3: Connecting to WiFi Router with Above Configuration IPAddress gateway(192, 168, 43, 1) //IP Address of your WiFi Router (Gateway) You can get this information from your laptops wifi connection details. and NO equal to sign.ĭefine Device IP address, Gateway (i.e.
IPAddress variable is used in arduino IDE to define IP address. #include Step 2: WiFi IP configuration variables ESP Web Server Library to host a web page There is no need of any special header file for having static IP address. We make LED on off control with simple web server with static IP to our ESP.
#Ostoto hotspot ip address how to#
In this tutorial we will learn how to use static IP address for ESP8266 NodeMCU.