How to Control LED Using ESP8266 NodemCU Lua WiFi From Website




This tutorial is going to teach you some basics on using ESP8266 NodemCU Lua WiFi to controls the LED from web.

Before you are getting started, make sure you have all the materials needed:

  1. ESP8266 NodeMCU Lua WiFi
  2. LED
  3. Breadboard
  4. Jumper(if needed)
  5. Micro USB

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Pin Definition

Step 2: Pin Connection

This is one of the most simple connection and suitable for a beginner.In this tutorial, we need connect LED's anode to ESP8266's GND pin and LED's cathode to ESP8266 D7.

Step 3: PHP&JSON Source Code

Download this source code and upload to the Arduino.

Step 4: Build a Website

1. First, go to here.

2. Free sign up the account and make a website name. (Just write the name only no need www and .com)

3. If sign up the account done, open email for verification.

4. After done, go to manage the website and upload the PHP and JSON files.

Step 5: Arduino Source Code

Download the source code and open it with Arduino IDE. Make sure you has successfully install ESP8266 into your Arduino IDE so you can connect your ESP8266 into your Arduino IDE and select the correct board and port into Arduino IDE.

Click here on how to install ESP8266 into your Arduino IDE.

*Note :

1. Change the ssid and password to your own WiFi Name and password.

2. Change the host and path.

const char* host = ""; //your domain

String path = "/light.json"; //beginning with slash

3. Change the pin number.

Step 6: Result

After power up the controller, open "Serial Monitor" and it will show:

...WIFI Connected

connecting to (Your website name)

...............LED OFF

closing connection.Connecting to (Your website name)

When you open your website and click "Turn On" button, the "Serial Monitor" will show:

...............LED ON

closing connection.Connecting to (Your website name)

OR click "Turn Off" button, the "Serial Monitor" will show:

...............LED OFF
closing connection.Connecting to (Your website name)

Step 7: Video

This video shows the demonstration of the control LED using ESP8266 from web.

Be the First to Share


    • Made with Math Contest

      Made with Math Contest
    • Multi-Discipline Contest

      Multi-Discipline Contest
    • Robotics Contest

      Robotics Contest

    4 Discussions


    1 year ago

    Thanks for this great tutorial. It is really simple and useful. It helped me a lot :)


    Reply 1 year ago

    Yes but if you turn on or off the button on website, the file will show out {light:off} or {light:on}


    Reply 1 year ago

    Hi, thanks for the reply. But, i get a issue on the serial monitor. I did follow exactly the schematic but it did not connect my host.