Internet Controlled LED Using NodeMCU

74,320

24

24

Introduction: Internet Controlled LED Using NodeMCU

The Internet of Things (IoT) is a system of interrelated computing devices, mechanical and digital machines, objects, animals or people that are provided with unique identifiers and the ability to transfer data over a network without requiring human-to-human or human-to-computer interaction.

In this instructable, we'll be making a simple IoT project.Web page controlled LED using NodeMCU connected on a local network.

DESCRIPTION
NodeMCU is an open source IoT platform. It includes firmware which runs on the ESP8266 WiFi SoC from Espressif, and hardware which is based on the ESP-12 module. The term "NodeMcu" by default refers to the firmware rather than the dev kits. The firmware ESP8266 uses the Lua scripting language. It is based on the Lua project and built on the Espressif Non-OS SDK for ESP8266. It uses many open source projects, such as Lua-cjson and spiffs. LUA based interactive firmware for Expressif ESP8622 Wi-Fi SoC, as well as an open-source hardware board that contrary to the $3 ESP8266 Wi-Fi modules includes a CP2102 TTL to USB chip for programming and debugging, is breadboard-friendly, and can simply be powered via its micro USB port.

FEATURES

  • Wi-Fi Module – ESP-12E module similar to the ESP-12 module but with 6 extra GPIOs.
  • USB – micro USB port for power, programming and debugging
  • Headers – 2x 2.54mm 15-pin header with access to GPIOs, SPI, UART, ADC, and power pinsMisc – Reset and Flash buttons
  • Power – 5V via micro USB port

Step 1: Materials Required

  1. ESP8266 NodeMCU
  2. Breadboard
  3. LED
  4. Jumper Wires
  5. Arduino IDE

Step 2: Installing NodeMCU Board Package

  1. Open up Arduino IDE. Go to Files-> Preferences. Enter http://arduino.esp8266.com/stable/package_esp8266... into Additional Board Manager URLs field
  2. Now go to Tools->Boards->Board Manager, and search for ESP8266 and install the package.

Step 3: Pin Connections

  1. D7 of NodeMCU to LED's +ve.
  2. G of NodeMCU to LED's -ve.

Step 4: Source Code

In code

change ssid to your ssid name

and Password to your SSID's password

const char* ssid = "MODI";//your ssid

const char* password = "8826675619";//Your Password

Step 5: Uploading the Code

When u have successfully built your connection on the breadboard and write coding, you have to upload the coding into the NodeMCU by using a micro USB.

Now, go to Tools > Board > ESP8266 Modules and you can see many options for ESP8266. Select "NodeMCU 1.0 (ESP-12E Module). Next, select your port. If you cant recognize your port, go to the Control Panel > System > Device Manager > Port and update your USB driver.

Now upload the code to the board.

Step 6: Controlling the LED

  • Now open up your Serial Monitor, and not down the URL.
  • Now put the URL in your phone's browser.
  • A page will open having two buttons ON and OFF.
  • If everything is correct when you press ON the LED will light up and when you press OFF the LED will turn off.

Automation Contest 2017

Participated in the
Automation Contest 2017

4 People Made This Project!

Recommendations

  • Make it Glow Contest

    Make it Glow Contest
  • First Time Author Contest

    First Time Author Contest
  • PCB Challenge

    PCB Challenge

24 Discussions

0
DavidJ171
DavidJ171

6 months ago

This code is awesome!! I can't believe how easy it is to just set up a fully automated home with some simple modifications. Verified and still working 6-29-2020. Thanks Modi!!

0
sanjaysrinivas47
sanjaysrinivas47

10 months ago

I did everything as specified...even i got the buttons via URL but there is no response from the LED..can you sort this ASAP please ..awaiting for an early reply.

0
Chirag_Modi
Chirag_Modi

Reply 10 months ago

please check your pin connections

0
LinhP23
LinhP23

2 years ago

Hi Modi, I do exactly what you say in this post and i have done uploading. Then, i have this problem in the following picture. Btw, thank you for this great project. Hope to see your reply soon.

Untitled.png
0
BeliaevM
BeliaevM

Reply 1 year ago

Hello,

please first open Serial monitor and then upload the firmware. Right after upload NodeMCU will send data to monitor

do not forget to set right band 115200

0
Chirag_Modi
Chirag_Modi

Reply 2 years ago

Please change the baud rate of serial monitor to 115200

0
Ronty98
Ronty98

Reply 1 year ago

Changed the baud rate to 115200, no change. serial monitor is blank.

0
Avinash KumarP
Avinash KumarP

1 year ago

Nice Tutorial. NodeMCU get connected to Hotspot but there is no data shown on serial Monitor.
.

1
Sapankotak
Sapankotak

1 year ago

Hello, modi. 1992.
I have done all such things and connected my nodemcu with my mobile hotspot, but in serial monitor of Arduino ide is not show anything.

123.jpg
0
Rahulsh
Rahulsh

Question 2 years ago on Step 6

Hello,

I did exactly as above.

I even got the web server, with the LED ON and OFF buttons.

But, while executing the ON button, the LED does not turn ON. I even tried using a resistor, and have also checked if the LED works fine. Can you please help me with this?

I'm really excited about the whole project, and to work on a bit of modifications too if this works fine.

Thankyou.

0
SkyCrafter
SkyCrafter

Question 2 years ago

I cant get this to work :(, I installed everything exactly like you said, and I get these errors:

error: espcomm_upload_mem failed

error: espcomm_open failed

0
sharanyanair
sharanyanair

Question 2 years ago

Code is not showing any error , but when we try to open the link it show " This page isn't working" ,

and below it comes as "XXX.XXX.XX.XXX didn't send any data.ERR_EMPTY_RESPONSE

Kindly help us as soon as possible we are troubleshooting it since long.

4
apatil23
apatil23

Question 2 years ago

Hello Modi,

First of all, thank you so much for this detailed article on ESP8266.

I did built as you mentioned and it's working fine.

I have one query.

When I connect my NodeMCU and laptop to my mobile hot-spot.

I can made LED ON and OFF from laptop and another mobile browser when all these are connected to same hot-spot.

How can I connect from different mobile (having internet connection) and turn ON and OFF this ESP module LED?

Mobile hotspot: having IP http://192.xxx.xxx.xxx

Laptop is connected to this Wi-Fi hot--spot.

Another mobile when connected to this Wi-Fi hot-spot then I can control LED

Third mobile having data connection (from different service provider) when try to browse same URL http://192.xxx.xxx.xxx, can't open the webpage.

Am I missing something here?

Please can you help?

LED_ON_OFF.jpg
0
Merzomann
Merzomann

3 years ago

Hello Modi, great project. However, I have the following problem. If I do not press a button in the browser for 10 minutes, I lose the connection. I only get a connection when I upload the code again. Do you have this problem? I would be grateful for a solution.

Best regards
David

0
Jigneshk5
Jigneshk5

Reply 2 years ago

Little change in the sketch will solve your issue. I think you should make the connection to the router/hotspot in the loop() so that it can automatically reconnects if the connection is lost at some point.

0
Chirag_Modi
Chirag_Modi

Reply 3 years ago

Hi David

I am not facing such issue with my project.I'll try and figure out to solve your problem and come back with the solution

0
Merzomann
Merzomann

Reply 3 years ago

That's great! Many Thanks!

0
vivek511
vivek511

2 years ago

Very nicely drafted !