Introduction: How to Control LED Using ESP8266 NodemCU Lua WiFi From Website

Picture of 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

Step 1: Pin Definition

Picture of Pin Definition

Step 2: Pin Connection

Picture of 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 the source code and upload to the web.

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 = "controlled.000webhostapp.com"; //your domain

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

3. Change the pin number.

Step 6: Result

Picture of 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.

Comments

KokY2 (author)2017-10-28

Is it really empty on the light.json file?

mybotic (author)KokY22017-10-29

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

KokY2 (author)mybotic2017-10-30

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.

About This Instructable

512views

14favorites

License:

More by mybotic:How to use ESP32 to Control LED With Blynk Via WiFiTutorial for ESP8266 ESPDuino NodeMcu SPI Module Using Arduino UnoTutorial for L298 2Amp Motor Driver Shield for Arduino
Add instructable to: