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
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:
- ESP8266 NodeMCU Lua WiFi
- LED
- Breadboard
- Jumper(if needed)
- Micro USB
Pin Definition
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.
PHP&JSON Source Code
Download this source code and upload to the Arduino.
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
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
This video shows the demonstration of the control LED using ESP8266 from web.