Getting Started with the ESP8266: Lighting Up the Onboard LED

Welcome to this introductory tutorial on using the WeMos D1 Mini microcontroller to light up its onboard LED. The ESP8266 is a low-cost Wi-Fi module that makes it easier than ever to add Wi-Fi functionality to your projects.

In this tutorial, we will cover the following steps:

  1. Hardware setup
  2. Installing required software
  3. Configuring the Arduino IDE for ESP8266
  4. Writing the code to control the onboard LED
  5. Uploading the code to ESP8266
  6. Testing the LED control

Hardware Setup

Required components:

Connecting the hardware:

The ESP8266 module can be powered using the micro USB cable. Connect one end of the cable to your computer’s USB port and the other end to the micro USB port on the ESP8266.

Note: Make sure the module is powered off whenever you are making connections.

Installing Required Software

Arduino IDE: To program the ESP8266, we will use the Arduino IDE. Download and install the latest version of the Arduino IDE from the official website: Arduino IDE Download

Configuring the Arduino IDE for ESP8266

Adding ESP8266 board support:

  1. Open the Arduino IDE.
  2. Go to File > Preferences (or Arduino > Preferences on macOS).
  3. In the Additional Board Manager URLs field, add the following URL:
  4. Click OK.




Installing the ESP8266 board package:

  1. Go to Tools > Board > Boards Manager....
  2. Type esp8266 in the search bar.
  3. Find the esp8266 by ESP8266 Community package and click Install.



Selecting the correct ESP8266 board:

  1. Go to Tools > Board.
  2. Find and select your specific board that, in my case, is the Esp8266 D1 mini.


Selecting the correct COM port:

  1. Connect the ESP8266 module to your computer using the micro USB cable.
  2. Go to Tools > Port, and select the appropriate COM port for your ESP8266 module.

Writing the Code to Control the Onboard LED

Create a new sketch in the Arduino IDE and enter the following code:

const int ledPin = LED_BUILTIN;

void setup() {
  pinMode(ledPin, OUTPUT);

void loop() {
  digitalWrite(ledPin, HIGH);
  digitalWrite(ledPin, LOW);

This code defines the onboard LED pin and sets it as an output. In the loop() function, the LED is turned on and off every second.

Uploading the Code to ESP8266

  1. Make sure your ESP8266 module is connected to your computer.
  2. Click the Upload button in the Arduino IDE (the right arrow icon).
  3. Wait for the “Done uploading” message to appear in the status bar.


Note: During the upload process, the ESP8266 may reboot a few times. This is normal.

Testing the LED Control

After successfully uploading the code, the onboard LED should start blinking. If the LED does not blink, double-check your connections and ensure that you have selected the correct board and COM port in the Arduino IDE.

Congratulations! You have successfully connected to an ESP8266 module and controlled its onboard LED using the Arduino IDE. This is just the beginning of what you can achieve with this powerful and versatile microcontroller. Explore its full potential by adding various sensors, actuators, and other components to your projects.