Home / Tutorials / ESP8266 Tutorial / WeMos D1 Mini WiFi Server
WeMos D1 Mini

WeMos D1 Mini WiFi Server

Now that you’ve set up your WeMos D1 Mini to be programmable using the Arduino IDE, it’s time to build a project. I’m a huge believer in active learning and project-making does just that. For this tutorial, I will guide you on how to build a WeMos D1 Mini WiFi server.

There are two ways for the WeMos D1 Mini to host a server: as a station and as an access point. I’ve already shown a tutorial on the former using NodeMCU so I will now use an access point server instead. Basically, an access point server doesn’t need another WiFi router – the WeMos D1 mini itself is the router. It broadcasts a WiFi connection and the user connects to it through SSID and password.

Required Libraries

You’ll need three libraries for this project, all of which are already included in the ESP8266 core for Arduino.

Define Access Point SSID and Password

Next, we define the SSID and password for the WiFi connection:

Initialize Server Object

Then we create the server object:

Create Access Point

Inside setup, we initialize the WiFi connection through:

This should start the access point, making the SSID visible to would-be clients.

Write HTML Page

Now we need to create an interface for the client. For starters, we’ll build a web page that allows the user to control the on-board LED on the WeMos D1. For this, we create a page with the following HTML:
This is a very simple HTML and could be improved with CSS and Javascript. For the purpose of this tutorial, we will stick with this one.

We place the HTML inside a string variable index
And have it shown to the client who visits the home page:

Bind to LED Control

Notice that on the HTML page, we have links to two pages: /LEDOn and /LEDOff.

When the client visits these links, that is when we are supposed to turn on or off the on board LED:
Finally, we start the server by calling the begin function.

The above code needs to be executed only once and hence will be inside setup(). The loop() function will only have one line of code and that is:

This makes the WeMos D1 Mini always listening to clients that visit the server.

WeMos D1 Mini WiFi Server Full Sketch

Here’s the full code for our WeMos D1 Mini WiFi Server:
Upload the code above to your WeMos D1 Mini. If successful, the device should be visible as a WiFi access point with the SSID and password you specified in the code above.

Check Also

Soil moisture sensor to ESP8266

Send Sensor Data to ThingSpeak via ESP8266

In the previous tutorial, we set up a soil moisture sensor and have its data …


  1. Hi,
    Thanks for the article. I just want to make sure that, there has to be an existing internet connection already, correct? This router wouldn’t work, for example on a ski slope, correct?

    • Hi Samuel,

      Yeah, a WiFi router would be necessary but it can still work without an Internet connection.

Leave a Reply

Your email address will not be published.