The ESP8266 microprocessor contains a Wi-Fi sender and receiver as well as software to drive them. This can be used to make web pages in our program as well as TCP/IP communication. We will not go further than a simple web page for this introduction. The library comes with examples to demonstrate some possible use cases. We have provided an example below that ilustrates how the onboard LED can be controlled form a web page using the router in the NDL.

The SSSID and password of the Wi-Fi router in the NDL can be found underneath the router.

#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
 
#define LISTEN_PORT 80
 
const char* ssid = "YOUR_SSID_HERE"; //name of local WiFi network in the NDL
const char* password = "YOUR_PASSWORD_HERE"; 
 
MDNSResponder mdns;
ESP8266WebServer server(LISTEN_PORT);
const char index_html[] PROGMEM = R"rawliteral(
<!DOCTYPE HTML><html>
<body>
	<h1>Wi-Fi LED control</h1>
	<p> Press me <a href="button"><button style="background-color:blue; color: white;"> LED </button></a></p>
</body>
</html>)rawliteral";
 
 
bool ledOn = false;
 
void setup() {
	Serial.begin(115200);
	pinMode(LED_BUILTIN, OUTPUT);
	digitalWrite(LED_BUILTIN, ledOn);	
	
	WiFi.begin(ssid, password);	// Start Wi-Fi connection to specified access point
	Serial.println("Start connecting.");
	while (WiFi.status() != WL_CONNECTED) {	// Wait until we are connected
		delay(500);
		Serial.print(".");
	}
 
	Serial.print("Connected to ");
	Serial.print(ssid);
	Serial.print(", IP address: ");
	Serial.println(WiFi.localIP());	// Print local IP to Serial Monitor
 
	if(mdns.begin("esp8266", WiFi.localIP())) {
		Serial.println("MDNS responder started");
	}
 
	server.on("/", [](){	// When we receive traffic from the main page
		server.send(200, "text/html", index_html);	// Send an OK HTML response of type text containing the web page
	});
 
	server.on("/button", [](){	// When we receive traffic from the "button" slug
		server.send(200, "text/html", index_html);	// Reload the page by sending it again
		ledOn = !ledOn;
		Serial.print("led ");
		Serial.println(ledOn);
		digitalWrite(LED_BUILTIN, !ledOn);	// Change LED status
		delay(1000);
	 });
	 
	 server.begin();
	 Serial.println("HTTP server started");
}
 
void loop() {
	server.handleClient(); //Handle all website logic, this should be run every loop!
	mdns.update();
}
 

Ensure that your computer or phone is connected to the router used in this program. Copy the IP address shown in the serial monitor to the address bar of the browser of your choice. This should show you the specified page. Pressing the blue button switches the built in LED on the D1 Mini on and off.

Troubleshooting