Lighting Up the Onboard LED of the ESP-01 Board

Lighting Up the Onboard LED of the ESP-01 Board

The ESP-01, a compact module based on the ESP8266 chipset, is a popular choice for IoT projects due to its WiFi capability and affordability. One of its features is an onboard LED, which can be controlled programmatically. This blog post will guide you through the initial steps of lighting up this onboard LED, including driver installation and troubleshooting.

Materials Needed:

There are two types of boards the ESP-01 and the ESP-01 S. For this tutorial, i am using the “normal” ESP-01.

 

 

Source of the image and the comparison between the two boards: https://cyberblogspot.com/difference-between-esp-01-and-esp-01s/

 

 

 

 

  • Computer with Arduino IDE installed

 

 

Goodies

 

Step 1: Installing Arduino IDE

If you haven’t already, download and install the Arduino IDE from the official Arduino website. This software will allow us to write and upload code to the ESP-01.
  • Download and install the latest version of the Arduino IDE from the official website: Arduino IDE Download

 

Step 2: Setting Up the Arduino IDE for ESP8266

The Arduino IDE doesn’t support the ESP8266 platform by default, so we need to add it:

 

 

 

 

 

 

 

 

 

  • Go to Tools -> Board -> Boards Manager, search for ESP8266 and install it.

 

 

 

 

 

Selecting the correct ESP8266 board:

  • Go to Tools > Board.
  • Find and select your specific board that is the Generic Esp8266

 

 

 

  • And select the onboard LED Pin (The onboard LED is connected to Pin 1) and the Port:

 

 

 

 

Step 3: Installing the USB to TTL Converter Drivers (Optional->If problems arise)

Before we can connect the ESP-01 to the computer, we need to ensure that the correct drivers for the USB to TTL converter are installed. The process will vary depending on the specific model of your converter and your operating system.
Our Esp01 board uses the CH340 chip for the communication, so we need to have the proper drivers.

 

 

Search the device manager for the connection:

 

 

 

Download the driver and execute the file: CH340 DRIVER LINK

 

 

 

 

Check if the driver was successfully installed. If necessary unplug and plug back again the Esp-01 or switch the USB port.

 

 

Step 4: Connecting the ESP-01 to the Computer

 

To put the CH340G adapter in programming mode, follow these steps:

  • Before plugging the USB ESP-01 programming adapter into a USB port on your computer, Press and hold the push button switch that you soldered in Step 2 for a few seconds.
  • Plug the USB ESP-01 programming adapter into a USB port on your computer with the button pressed.
  • Release the button: After a few seconds, release the push button switch. The Esp-01 should be in programming mode, and you can upload code to the ESP-01 module using your preferred development environment.

 

If having trouble, go to my previous blog post. It explains with images: https://www.edgemicrotech.com/preparing-the-usb-esp-01-programming-adapter-a-step-by-step-guide/

 

Step 5: Programming the ESP-01

 

The onboard led is connected to the GPIO 1 on the Esp-01 board, that is why we choose Builtin Led: “1”. This is why, in the code, the IDE knows that the onboard led is at GPIO 1.

 

 

 

 

 

Another thing is that the activation of the LED is made on logic “0”, that is, the logic is inverted based on the LED circuit of the board. In the code, we can see that the LED will be turned ON when the logic is “LOW”.

 

 

 

Now, we’re ready to program the ESP-01 to control the onboard LED. The LED is connected to GPIO1, which is the TX pin. Here’s a simple program to blink the LED:

 

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);  // Initialize the LED_BUILTIN pin as an output - IN THIS CASE THE PIN=1 
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, LOW);  // Turn the LED on (Note that LOW is the voltage level
  // but actually the LED is on; this is because
  // it is active low on the ESP-01)
  delay(1000);                      // Wait for a second
  digitalWrite(LED_BUILTIN, HIGH);  // Turn the LED off by making the voltage HIGH
  delay(2000);                      // Wait for two seconds (to demonstrate the active low LED)
}

 

  1. Copy the above code and paste it into the Arduino IDE.
  2. Select the correct board (Generic ESP8266 Module) and port from the Tools menu.
  3. Click on the Upload button to upload the code to the ESP-01. The next image demonstrate a successful upload. If not, go to the troubleshooting section.

 

 

 

 

Step 5: Result

 

  • Remove the usb adapter and plug it back again (without pressing the button) – It will be now in running mode.
  • The onboard Esp-01 led should blink.

 

 

Troubleshooting:

 

If you encounter issues during this process, here are a few common problems and their solutions:

 

  • The ESP-01 is not recognized by the computer: Ensure that the USB to TTL converter drivers are correctly installed. Check your connections and try a different USB port if necessary.

 

  • The code doesn’t upload: Make sure you’ve selected the correct board and port in the Arduino IDE. Also, ensure that the ESP-01 is in programming mode (GPIO0 connected to GND during power up – The button has to remain pressed as the adapter is pluged on the computer).

 

 

 

  • The LED doesn’t blink: Verify that your code is correct and has been uploaded successfully. Check that the LED is connected to GPIO1 (TX pin).

 

Conclusion:

By following these steps, you should be able to light up the onboard LED of the ESP-01 module. This is a simple demonstration of how you can control the onboard LED, but the possibilities are endless. You can modify the code to make the LED blink in different patterns, or use the LED as an indicator in your IoT projects. Happy tinkering!