How to Control LED Using ESP8266 NodemCU Lua WiFi From Website

by mybotic in Circuits > Arduino

5511 Views, 16 Favorites, 0 Comments

How to Control LED Using ESP8266 NodemCU Lua WiFi From Website

Capture.JPG

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

Pin Definition

FA36B49IT22LKOP.MEDIUM.jpg

Pin Connection

FAEEK3AISWHS1OG.MEDIUM.jpg

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.

PHP&JSON Source Code

Download this source code and upload to the Arduino.

Downloads

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.

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.

Downloads

Result

output.JPG
1.JPG
on.JPG

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)

Video

How to control LED using ESP8266 NodemCU LUA WIFI from Website

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