SlideShare a Scribd company logo
2
Most read
7
Most read
8
Most read
NodeMCU 0.9 Manual
Using Arduino IDE
Introduction
NodeMCU is an open source IoT platform. It includes firmware which runs on
ESP8266 Wi-Fi SoC.
This manual explains each step to set up Arduino IDE for NodeMCU and make a
DEVKIT Version 0.9 of NodeMCU work with it. At the end of this manual, we shall
be able to program NodeMCU DEVKIT using Arduino IDE and control it from a
local area network (via WiFi).
NodeMCU Pin Mapping
Notes:
* The ESP8266 chip requires 3.3V power supply voltage. It should not be
powered with 5 volts like other Arduino boards.
* NodeMCU ESP-12E development board can be connected to 5V
using micro USB connector or Vin pin available on board.
* The I/O pins of ESP8266 communicate or input/output max 3.3V only.
The pins are NOT 5V tolerant inputs.
Getting Arduino IDE
Step 1: Go to https://www.arduino.cc/en/Main/Software
Step 2: Download the required package (according to your Operating System and
system requirements).
Note: Arduino IDE for Linux needs to be run either by “root” or any user with
privileged permission to allow USB access.
Setting up NodeMCU 0.9 board
Step 1: Open Arduino IDE
Step 2: Go to Files and open Preferences
Step 3: Paste the following URL in Additional Boards Manager URLs box. If there
are multiple URLs, separate them by comma.
http://arduino.esp8266.com/stable/package_esp8266com_index.json
Step 4: Click OK and close the preference dialog.
Step 5: Go to Tools and then under Board menu, click Board Manager
Step 6: Scroll down and navigate to “esp8266 by esp8266 community”. Click on
install and let the installation process complete.
Step 7: Once installed we’re ready to program our NodeMCU.
Glowing a LED
Step 1: Connect a LED to the NodeMCU DEVKIT as shown in the figure. The 13th
pin in Arduino IDE is mapped onto the D7 slot of NodeMCU.
Step 2: The following is the basic blink program for making the LED blink from
NodeMCU.
void setup() {
pinMode(13, OUTPUT);
}
void loop() {
// Let the LED glow for 2 seconds
digitalWrite(13, HIGH);
delay(2000);
// LED would be turned off for 3 seconds
digitalWrite(13, LOW);
delay(3000);
}
Step 3: Upload the program to the board (NodeMCU 0.9) through appropriate
port.
Controlling LED from a web browser
Step 1: Make a local WiFi hotspot using smartphone or wireless router.
Step 2: The following code glows LED from devices connected to that WiFi
#include <ESP8266WiFi.h>
const char* ssid = "Cygnus-a";
const char* password = "cygnus8019@star";
int ledPin = 13; // GPIO13
WiFiServer server(80);
void setup() {
Serial.begin(115200);
delay(10);
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);
// Connect to WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
// Start the server
server.begin();
Serial.println("Server started");
// Print the IP address
Serial.print("Use this URL to connect: ");
Serial.print("http://");
Serial.print(WiFi.localIP());
Serial.println("/");
}
void loop() {
// Check if a client has connected
WiFiClient client = server.available();
if (!client) {
return;
}
// Wait until the client sends some data
Serial.println("new client");
while(!client.available()){
delay(1);
}
// Read the first line of the request
String request = client.readStringUntil('r');
Serial.println(request);
client.flush();
// Match the request
int value = LOW;
if (request.indexOf("/LED=ON") != -1) {
digitalWrite(ledPin, HIGH);
value = HIGH;
}
if (request.indexOf("/LED=OFF") != -1) {
digitalWrite(ledPin, LOW);
value = LOW;
}
// Set ledPin according to the request
//digitalWrite(ledPin, value);
// Return the response
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println(""); // do not forget this one
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.print("Led pin is now: ");
if(value == HIGH) {
client.print("On");
} else {
client.print("Off");
}
client.println("<br><br>");
client.println("<a href="/LED=ON""><button>Turn On
</button></a>");
client.println("<a href="/LED=OFF""><button>Turn Off
</button></a><br />");
client.println("</html>");
delay(1);
Serial.println("Client disonnected");
Serial.println("");
}
Step 3: Open serial monitor and note down the URL assigned to NodeMCU by
DHCP server.
Step 4: Connect a computer or smartphone to the WiFi and open
http://192.168.0.101/LED=ON to turn LED on or http://192.168.0.101/LED=OFF to
turn LED off. The URL would be the URL shown by Node on serial monitor.
Controlling electrical devices from a web browser
Step 1: Make sure all devices that would be controlling electrical appliances are
connected to the same WiFi network.
Step 2: The following circuit connection has two relay switch modules attached
that can be controlled through the microcontroller.
Step 3: Upload the following code to the NodeMCU board.
#include <ESP8266WiFi.h>
const char* ssid = "Cygnus-a";
const char* password = "cygnus8019@star";
WiFiServer server(80);
void setup() {
Serial.begin(115200);
delay(10);
pinMode(5, OUTPUT);
pinMode(4, OUTPUT);
pinMode(0, OUTPUT);
pinMode(13, OUTPUT);
digitalWrite(5, LOW);
digitalWrite(4, LOW);
digitalWrite(0, LOW);
digitalWrite(13, LOW);
// Connect to WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
// Start the server
server.begin();
Serial.println("Server started");
// Print the IP address
Serial.print("Use this URL to connect: ");
Serial.print("http://");
Serial.print(WiFi.localIP());
Serial.println("/");
}
void loop() {
// Check if a client has connected
WiFiClient client = server.available();
if (!client) {
return;
}
// Wait until the client sends some data
Serial.println("new client");
while(!client.available()){
delay(1);
}
// Read the first line of the request
String request = client.readStringUntil('r');
Serial.println(request);
client.flush();
// Match the request
if (request.indexOf("/light1on") > 0) {
digitalWrite(5, HIGH);
}
if (request.indexOf("/light1off") >0) {
digitalWrite(5, LOW);
}
if (request.indexOf("/light2on") > 0) {
digitalWrite(4, HIGH);
}
if (request.indexOf("/light2off") >0) {
digitalWrite(4, LOW);
}
if (request.indexOf("/light3on") >0) {
digitalWrite(0, HIGH);
}
if (request.indexOf("/light3off") > 0) {
digitalWrite(0, LOW);
}
if (request.indexOf("/light4on") > 0) {
digitalWrite(13, HIGH);
}
if (request.indexOf("/light4off") > 0) {
digitalWrite(13, LOW);
}
// Set ledPin according to the request
//digitalWrite(ledPin, value);
// Return the response
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println(""); // do not forget this one
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.println("<head>");
client.println("<meta name='apple-mobile-web-app-capable'
content='yes' />");
client.println("<meta name='apple-mobile-web-app-status-
bar-style' content='black-translucent' />");
client.println("</head>");
client.println("<body bgcolor = "#f7e6ec">");
client.println("<hr/><hr>");
client.println("<h4><center> Esp8266 Electrical Device
Control </center></h4>");
client.println("<hr/><hr>");
client.println("<br><br>");
client.println("<br><br>");
client.println("<center>");
client.println("Device 1");
client.println("<a href="/light1on""><button>Turn On
</button></a>");
client.println("<a href="/light1off""><button>Turn Off
</button></a><br />");
client.println("</center>");
client.println("<br><br>");
client.println("<center>");
client.println("Device 2");
client.println("<a href="/light2on""><button>Turn On
</button></a>");
client.println("<a href="/light2off""><button>Turn Off
</button></a><br />");
client.println("</center>");
client.println("<br><br>");
client.println("<center>");
client.println("Device 3");
client.println("<a href="/light3on""><button>Turn On
</button></a>");
client.println("<a href="/light3off""><button>Turn Off
</button></a><br />");
client.println("</center>");
client.println("<br><br>");
client.println("<center>");
client.println("Device 4");
client.println("<a href="/light4on""><button>Turn On
</button></a>");
client.println("<a href="/light4off""><button>Turn Off
</button></a><br />");
client.println("</center>");
client.println("<br><br>");
client.println("<center>");
client.println("<table border="5">");
client.println("<tr>");
if (digitalRead(5))
{
client.print("<td>Light 1 is ON</td>");
}
else
{
client.print("<td>Light 1 is OFF</td>");
}
client.println("<br />");
if (digitalRead(4))
{
client.print("<td>Light 2 is ON</td>");
}
else
{
client.print("<td>Light 2 is OFF</td>");
}
client.println("</tr>");
client.println("<tr>");
if (digitalRead(0))
{
client.print("<td>Light 3 is ON</td>");
}
else
{
client.print("<td>Light 3 is OFF</td>");
}
if (digitalRead(13))
{
client.print("<td>Light 4 is ON</td>");
}
else
{
client.print("<td>Light 4 is OFF</td>");
}
client.println("</tr>");
client.println("</table>");
client.println("</center>");
client.println("</html>");
delay(1);
Serial.println("Client disonnected");
Serial.println("");
}
Copy the above code and complete the process.
Ad

Recommended

Arduino & NodeMcu
Arduino & NodeMcu
Guhan Ganesan
 
Architecture Of The Linux Kernel
Architecture Of The Linux Kernel
guest547d74
 
The Linux Kernel Scheduler (For Beginners) - SFO17-421
The Linux Kernel Scheduler (For Beginners) - SFO17-421
Linaro
 
Solid State Drives (Third Generation) 2013
Solid State Drives (Third Generation) 2013
Hemanth HR
 
Cisco Wireless LAN Controller Palo Alto Networks Config Guide
Cisco Wireless LAN Controller Palo Alto Networks Config Guide
Alberto Rivai
 
Aula 07 8 periféricos de um
Aula 07 8 periféricos de um
Marcos Basilio
 
Bare-Metal Hypervisor as a Platform for Innovation
Bare-Metal Hypervisor as a Platform for Innovation
The Linux Foundation
 
Communication Protocols (UART, SPI,I2C)
Communication Protocols (UART, SPI,I2C)
Emertxe Information Technologies Pvt Ltd
 
U-Boot presentation 2013
U-Boot presentation 2013
Wave Digitech
 
Raspberry pi project smart motion detection system using raspberry pi 3
Raspberry pi project smart motion detection system using raspberry pi 3
Bhaskar Nemala
 
Building Embedded Linux Full Tutorial for ARM
Building Embedded Linux Full Tutorial for ARM
Sherif Mousa
 
Successfully Deploying IPv6
Successfully Deploying IPv6
Zivaro Inc
 
Moving NEON to 64 bits
Moving NEON to 64 bits
Chiou-Nan Chen
 
1149.6extest
1149.6extest
Chiranjeevi Chiru
 
Linux Environment- Linux vs Unix
Linux Environment- Linux vs Unix
Trinity Dwarka
 
Using FPGA in Embedded Devices
Using FPGA in Embedded Devices
GlobalLogic Ukraine
 
Android is NOT just 'Java on Linux'
Android is NOT just 'Java on Linux'
Tetsuyuki Kobayashi
 
ARM Processor Tutorial
ARM Processor Tutorial
Embeddedcraft Craft
 
Basic Linux Internals
Basic Linux Internals
mukul bhardwaj
 
Bootloaders
Bootloaders
Anil Kumar Pugalia
 
Reliability, Availability and Serviceability on Linux
Reliability, Availability and Serviceability on Linux
Samsung Open Source Group
 
Modelon FMI Tutorial NAMUG 2016
Modelon FMI Tutorial NAMUG 2016
Modelon
 
Hands-on ethernet driver
Hands-on ethernet driver
SUSE Labs Taipei
 
ARM Processor
ARM Processor
Aniket Thakur
 
Linux device drivers
Linux device drivers
Emertxe Information Technologies Pvt Ltd
 
RAM Source code and Test Bench
RAM Source code and Test Bench
Raj Mohan
 
Embedded_Linux_Booting
Embedded_Linux_Booting
Rashila Rr
 
Introduction to FreeRTOS
Introduction to FreeRTOS
ICS
 
Introduction to Node MCU
Introduction to Node MCU
Amarjeetsingh Thakur
 
Esp8266 v12
Esp8266 v12
handson28
 

More Related Content

What's hot (20)

U-Boot presentation 2013
U-Boot presentation 2013
Wave Digitech
 
Raspberry pi project smart motion detection system using raspberry pi 3
Raspberry pi project smart motion detection system using raspberry pi 3
Bhaskar Nemala
 
Building Embedded Linux Full Tutorial for ARM
Building Embedded Linux Full Tutorial for ARM
Sherif Mousa
 
Successfully Deploying IPv6
Successfully Deploying IPv6
Zivaro Inc
 
Moving NEON to 64 bits
Moving NEON to 64 bits
Chiou-Nan Chen
 
1149.6extest
1149.6extest
Chiranjeevi Chiru
 
Linux Environment- Linux vs Unix
Linux Environment- Linux vs Unix
Trinity Dwarka
 
Using FPGA in Embedded Devices
Using FPGA in Embedded Devices
GlobalLogic Ukraine
 
Android is NOT just 'Java on Linux'
Android is NOT just 'Java on Linux'
Tetsuyuki Kobayashi
 
ARM Processor Tutorial
ARM Processor Tutorial
Embeddedcraft Craft
 
Basic Linux Internals
Basic Linux Internals
mukul bhardwaj
 
Bootloaders
Bootloaders
Anil Kumar Pugalia
 
Reliability, Availability and Serviceability on Linux
Reliability, Availability and Serviceability on Linux
Samsung Open Source Group
 
Modelon FMI Tutorial NAMUG 2016
Modelon FMI Tutorial NAMUG 2016
Modelon
 
Hands-on ethernet driver
Hands-on ethernet driver
SUSE Labs Taipei
 
ARM Processor
ARM Processor
Aniket Thakur
 
Linux device drivers
Linux device drivers
Emertxe Information Technologies Pvt Ltd
 
RAM Source code and Test Bench
RAM Source code and Test Bench
Raj Mohan
 
Embedded_Linux_Booting
Embedded_Linux_Booting
Rashila Rr
 
Introduction to FreeRTOS
Introduction to FreeRTOS
ICS
 
U-Boot presentation 2013
U-Boot presentation 2013
Wave Digitech
 
Raspberry pi project smart motion detection system using raspberry pi 3
Raspberry pi project smart motion detection system using raspberry pi 3
Bhaskar Nemala
 
Building Embedded Linux Full Tutorial for ARM
Building Embedded Linux Full Tutorial for ARM
Sherif Mousa
 
Successfully Deploying IPv6
Successfully Deploying IPv6
Zivaro Inc
 
Moving NEON to 64 bits
Moving NEON to 64 bits
Chiou-Nan Chen
 
Linux Environment- Linux vs Unix
Linux Environment- Linux vs Unix
Trinity Dwarka
 
Android is NOT just 'Java on Linux'
Android is NOT just 'Java on Linux'
Tetsuyuki Kobayashi
 
Reliability, Availability and Serviceability on Linux
Reliability, Availability and Serviceability on Linux
Samsung Open Source Group
 
Modelon FMI Tutorial NAMUG 2016
Modelon FMI Tutorial NAMUG 2016
Modelon
 
RAM Source code and Test Bench
RAM Source code and Test Bench
Raj Mohan
 
Embedded_Linux_Booting
Embedded_Linux_Booting
Rashila Rr
 
Introduction to FreeRTOS
Introduction to FreeRTOS
ICS
 

Similar to NodeMCU 0.9 Manual using Arduino IDE (20)

Introduction to Node MCU
Introduction to Node MCU
Amarjeetsingh Thakur
 
Esp8266 v12
Esp8266 v12
handson28
 
IoT Hands-On-Lab, KINGS, 2019
IoT Hands-On-Lab, KINGS, 2019
Jong-Hyun Kim
 
IoT with Arduino
IoT with Arduino
Arvind Singh
 
NodeMCU ESP8266 workshop 1
NodeMCU ESP8266 workshop 1
Andy Gelme
 
Build WiFi gadgets using esp8266
Build WiFi gadgets using esp8266
Baoshi Zhu
 
NodeMCU with Blynk and Firebase
NodeMCU with Blynk and Firebase
Eueung Mulyana
 
Node MCU Fun
Node MCU Fun
David Bosschaert
 
IoT Platform
IoT Platform
Saurabh Singh
 
IoT Platform
IoT Platform
Saurabh Singh
 
IOT Talking to Webserver - how to
IOT Talking to Webserver - how to
Indraneel Ganguli
 
p12a-esp8266 aaaaaaaaaaaaaaaaaaahttp.pdf
p12a-esp8266 aaaaaaaaaaaaaaaaaaahttp.pdf
DwiPratiwi50
 
Arduino: interruptor de encendido controlado por Internet
Arduino: interruptor de encendido controlado por Internet
SANTIAGO PABLO ALBERTO
 
Getting Started with the NodeMCU- NodeMCU Programming (By Akshet Patel)
Getting Started with the NodeMCU- NodeMCU Programming (By Akshet Patel)
AkshetPatel
 
IoT Application Development
IoT Application Development
Vignesh Govindraj
 
IOT WORKSHEET 1.4.pdf
IOT WORKSHEET 1.4.pdf
MayuRana1
 
IoT simple with the ESP8266 - presented at the July 2015 Austin IoT Hardware ...
IoT simple with the ESP8266 - presented at the July 2015 Austin IoT Hardware ...
David Fowler
 
programmer avec Arduino
programmer avec Arduino
mohamednacim
 
Scottish Ruby Conference 2010 Arduino, Ruby RAD
Scottish Ruby Conference 2010 Arduino, Ruby RAD
lostcaggy
 
Esp8266 wi fi_module_quick_start_guide_v_1.0.4
Esp8266 wi fi_module_quick_start_guide_v_1.0.4
Melvin Gutiérrez Rivero
 
IoT Hands-On-Lab, KINGS, 2019
IoT Hands-On-Lab, KINGS, 2019
Jong-Hyun Kim
 
NodeMCU ESP8266 workshop 1
NodeMCU ESP8266 workshop 1
Andy Gelme
 
Build WiFi gadgets using esp8266
Build WiFi gadgets using esp8266
Baoshi Zhu
 
NodeMCU with Blynk and Firebase
NodeMCU with Blynk and Firebase
Eueung Mulyana
 
IOT Talking to Webserver - how to
IOT Talking to Webserver - how to
Indraneel Ganguli
 
p12a-esp8266 aaaaaaaaaaaaaaaaaaahttp.pdf
p12a-esp8266 aaaaaaaaaaaaaaaaaaahttp.pdf
DwiPratiwi50
 
Arduino: interruptor de encendido controlado por Internet
Arduino: interruptor de encendido controlado por Internet
SANTIAGO PABLO ALBERTO
 
Getting Started with the NodeMCU- NodeMCU Programming (By Akshet Patel)
Getting Started with the NodeMCU- NodeMCU Programming (By Akshet Patel)
AkshetPatel
 
IOT WORKSHEET 1.4.pdf
IOT WORKSHEET 1.4.pdf
MayuRana1
 
IoT simple with the ESP8266 - presented at the July 2015 Austin IoT Hardware ...
IoT simple with the ESP8266 - presented at the July 2015 Austin IoT Hardware ...
David Fowler
 
programmer avec Arduino
programmer avec Arduino
mohamednacim
 
Scottish Ruby Conference 2010 Arduino, Ruby RAD
Scottish Ruby Conference 2010 Arduino, Ruby RAD
lostcaggy
 
Esp8266 wi fi_module_quick_start_guide_v_1.0.4
Esp8266 wi fi_module_quick_start_guide_v_1.0.4
Melvin Gutiérrez Rivero
 
Ad

Recently uploaded (20)

Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Priyanka Aash
 
Creating Inclusive Digital Learning with AI: A Smarter, Fairer Future
Creating Inclusive Digital Learning with AI: A Smarter, Fairer Future
Impelsys Inc.
 
Python Conference Singapore - 19 Jun 2025
Python Conference Singapore - 19 Jun 2025
ninefyi
 
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Safe Software
 
Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
ICT Frame Magazine Pvt. Ltd.
 
10 Key Challenges for AI within the EU Data Protection Framework.pdf
10 Key Challenges for AI within the EU Data Protection Framework.pdf
Priyanka Aash
 
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
 
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
Edge AI and Vision Alliance
 
You are not excused! How to avoid security blind spots on the way to production
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
OpenPOWER Foundation & Open-Source Core Innovations
OpenPOWER Foundation & Open-Source Core Innovations
IBM
 
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
Securing AI - There Is No Try, Only Do!.pdf
Securing AI - There Is No Try, Only Do!.pdf
Priyanka Aash
 
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
revolcs10
 
Techniques for Automatic Device Identification and Network Assignment.pdf
Techniques for Automatic Device Identification and Network Assignment.pdf
Priyanka Aash
 
Lessons Learned from Developing Secure AI Workflows.pdf
Lessons Learned from Developing Secure AI Workflows.pdf
Priyanka Aash
 
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance
 
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Josef Weingand
 
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Oh, the Possibilities - Balancing Innovation and Risk with Generative AI.pdf
Priyanka Aash
 
Creating Inclusive Digital Learning with AI: A Smarter, Fairer Future
Creating Inclusive Digital Learning with AI: A Smarter, Fairer Future
Impelsys Inc.
 
Python Conference Singapore - 19 Jun 2025
Python Conference Singapore - 19 Jun 2025
ninefyi
 
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Improving Data Integrity: Synchronization between EAM and ArcGIS Utility Netw...
Safe Software
 
Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
Information Security Response Team Nepal_npCERT_Vice_President_Sudan_Jha.pdf
ICT Frame Magazine Pvt. Ltd.
 
10 Key Challenges for AI within the EU Data Protection Framework.pdf
10 Key Challenges for AI within the EU Data Protection Framework.pdf
Priyanka Aash
 
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
 
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
“Key Requirements to Successfully Implement Generative AI in Edge Devices—Opt...
Edge AI and Vision Alliance
 
You are not excused! How to avoid security blind spots on the way to production
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
 
MuleSoft for AgentForce : Topic Center and API Catalog
MuleSoft for AgentForce : Topic Center and API Catalog
shyamraj55
 
OpenPOWER Foundation & Open-Source Core Innovations
OpenPOWER Foundation & Open-Source Core Innovations
IBM
 
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
Securing AI - There Is No Try, Only Do!.pdf
Securing AI - There Is No Try, Only Do!.pdf
Priyanka Aash
 
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
ReSTIR [DI]: Spatiotemporal reservoir resampling for real-time ray tracing ...
revolcs10
 
Techniques for Automatic Device Identification and Network Assignment.pdf
Techniques for Automatic Device Identification and Network Assignment.pdf
Priyanka Aash
 
Lessons Learned from Developing Secure AI Workflows.pdf
Lessons Learned from Developing Secure AI Workflows.pdf
Priyanka Aash
 
9-1-1 Addressing: End-to-End Automation Using FME
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance
 
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Josef Weingand
 
Ad

NodeMCU 0.9 Manual using Arduino IDE

  • 2. Introduction NodeMCU is an open source IoT platform. It includes firmware which runs on ESP8266 Wi-Fi SoC. This manual explains each step to set up Arduino IDE for NodeMCU and make a DEVKIT Version 0.9 of NodeMCU work with it. At the end of this manual, we shall be able to program NodeMCU DEVKIT using Arduino IDE and control it from a local area network (via WiFi). NodeMCU Pin Mapping
  • 3. Notes: * The ESP8266 chip requires 3.3V power supply voltage. It should not be powered with 5 volts like other Arduino boards. * NodeMCU ESP-12E development board can be connected to 5V using micro USB connector or Vin pin available on board. * The I/O pins of ESP8266 communicate or input/output max 3.3V only. The pins are NOT 5V tolerant inputs.
  • 4. Getting Arduino IDE Step 1: Go to https://www.arduino.cc/en/Main/Software Step 2: Download the required package (according to your Operating System and system requirements). Note: Arduino IDE for Linux needs to be run either by “root” or any user with privileged permission to allow USB access. Setting up NodeMCU 0.9 board Step 1: Open Arduino IDE Step 2: Go to Files and open Preferences
  • 5. Step 3: Paste the following URL in Additional Boards Manager URLs box. If there are multiple URLs, separate them by comma. http://arduino.esp8266.com/stable/package_esp8266com_index.json Step 4: Click OK and close the preference dialog. Step 5: Go to Tools and then under Board menu, click Board Manager
  • 6. Step 6: Scroll down and navigate to “esp8266 by esp8266 community”. Click on install and let the installation process complete.
  • 7. Step 7: Once installed we’re ready to program our NodeMCU. Glowing a LED Step 1: Connect a LED to the NodeMCU DEVKIT as shown in the figure. The 13th pin in Arduino IDE is mapped onto the D7 slot of NodeMCU.
  • 8. Step 2: The following is the basic blink program for making the LED blink from NodeMCU. void setup() { pinMode(13, OUTPUT); } void loop() { // Let the LED glow for 2 seconds digitalWrite(13, HIGH); delay(2000); // LED would be turned off for 3 seconds digitalWrite(13, LOW); delay(3000); } Step 3: Upload the program to the board (NodeMCU 0.9) through appropriate port. Controlling LED from a web browser Step 1: Make a local WiFi hotspot using smartphone or wireless router. Step 2: The following code glows LED from devices connected to that WiFi
  • 9. #include <ESP8266WiFi.h> const char* ssid = "Cygnus-a"; const char* password = "cygnus8019@star"; int ledPin = 13; // GPIO13 WiFiServer server(80); void setup() { Serial.begin(115200); delay(10); pinMode(ledPin, OUTPUT); digitalWrite(ledPin, LOW); // Connect to WiFi network Serial.println(); Serial.println(); Serial.print("Connecting to "); Serial.println(ssid); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500);
  • 10. Serial.print("."); } Serial.println(""); Serial.println("WiFi connected"); // Start the server server.begin(); Serial.println("Server started"); // Print the IP address Serial.print("Use this URL to connect: "); Serial.print("http://"); Serial.print(WiFi.localIP()); Serial.println("/"); } void loop() { // Check if a client has connected WiFiClient client = server.available(); if (!client) { return; } // Wait until the client sends some data
  • 11. Serial.println("new client"); while(!client.available()){ delay(1); } // Read the first line of the request String request = client.readStringUntil('r'); Serial.println(request); client.flush(); // Match the request int value = LOW; if (request.indexOf("/LED=ON") != -1) { digitalWrite(ledPin, HIGH); value = HIGH; } if (request.indexOf("/LED=OFF") != -1) { digitalWrite(ledPin, LOW); value = LOW; } // Set ledPin according to the request //digitalWrite(ledPin, value);
  • 12. // Return the response client.println("HTTP/1.1 200 OK"); client.println("Content-Type: text/html"); client.println(""); // do not forget this one client.println("<!DOCTYPE HTML>"); client.println("<html>"); client.print("Led pin is now: "); if(value == HIGH) { client.print("On"); } else { client.print("Off"); } client.println("<br><br>"); client.println("<a href="/LED=ON""><button>Turn On </button></a>"); client.println("<a href="/LED=OFF""><button>Turn Off </button></a><br />"); client.println("</html>"); delay(1); Serial.println("Client disonnected"); Serial.println(""); }
  • 13. Step 3: Open serial monitor and note down the URL assigned to NodeMCU by DHCP server. Step 4: Connect a computer or smartphone to the WiFi and open http://192.168.0.101/LED=ON to turn LED on or http://192.168.0.101/LED=OFF to turn LED off. The URL would be the URL shown by Node on serial monitor. Controlling electrical devices from a web browser Step 1: Make sure all devices that would be controlling electrical appliances are connected to the same WiFi network. Step 2: The following circuit connection has two relay switch modules attached that can be controlled through the microcontroller.
  • 14. Step 3: Upload the following code to the NodeMCU board. #include <ESP8266WiFi.h> const char* ssid = "Cygnus-a"; const char* password = "cygnus8019@star"; WiFiServer server(80); void setup() { Serial.begin(115200); delay(10); pinMode(5, OUTPUT); pinMode(4, OUTPUT); pinMode(0, OUTPUT); pinMode(13, OUTPUT); digitalWrite(5, LOW); digitalWrite(4, LOW); digitalWrite(0, LOW); digitalWrite(13, LOW); // Connect to WiFi network Serial.println();
  • 15. Serial.println(); Serial.print("Connecting to "); Serial.println(ssid); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.print("."); } Serial.println(""); Serial.println("WiFi connected"); // Start the server server.begin(); Serial.println("Server started"); // Print the IP address Serial.print("Use this URL to connect: "); Serial.print("http://"); Serial.print(WiFi.localIP()); Serial.println("/"); } void loop() { // Check if a client has connected WiFiClient client = server.available(); if (!client) { return; } // Wait until the client sends some data Serial.println("new client"); while(!client.available()){ delay(1); } // Read the first line of the request
  • 16. String request = client.readStringUntil('r'); Serial.println(request); client.flush(); // Match the request if (request.indexOf("/light1on") > 0) { digitalWrite(5, HIGH); } if (request.indexOf("/light1off") >0) { digitalWrite(5, LOW); } if (request.indexOf("/light2on") > 0) { digitalWrite(4, HIGH); } if (request.indexOf("/light2off") >0) { digitalWrite(4, LOW); } if (request.indexOf("/light3on") >0) { digitalWrite(0, HIGH); } if (request.indexOf("/light3off") > 0) { digitalWrite(0, LOW); } if (request.indexOf("/light4on") > 0) { digitalWrite(13, HIGH); } if (request.indexOf("/light4off") > 0) { digitalWrite(13, LOW);
  • 17. } // Set ledPin according to the request //digitalWrite(ledPin, value); // Return the response client.println("HTTP/1.1 200 OK"); client.println("Content-Type: text/html"); client.println(""); // do not forget this one client.println("<!DOCTYPE HTML>"); client.println("<html>"); client.println("<head>"); client.println("<meta name='apple-mobile-web-app-capable' content='yes' />"); client.println("<meta name='apple-mobile-web-app-status- bar-style' content='black-translucent' />"); client.println("</head>"); client.println("<body bgcolor = "#f7e6ec">"); client.println("<hr/><hr>"); client.println("<h4><center> Esp8266 Electrical Device Control </center></h4>"); client.println("<hr/><hr>"); client.println("<br><br>"); client.println("<br><br>"); client.println("<center>"); client.println("Device 1"); client.println("<a href="/light1on""><button>Turn On </button></a>"); client.println("<a href="/light1off""><button>Turn Off </button></a><br />"); client.println("</center>"); client.println("<br><br>"); client.println("<center>"); client.println("Device 2"); client.println("<a href="/light2on""><button>Turn On </button></a>"); client.println("<a href="/light2off""><button>Turn Off </button></a><br />"); client.println("</center>"); client.println("<br><br>");
  • 18. client.println("<center>"); client.println("Device 3"); client.println("<a href="/light3on""><button>Turn On </button></a>"); client.println("<a href="/light3off""><button>Turn Off </button></a><br />"); client.println("</center>"); client.println("<br><br>"); client.println("<center>"); client.println("Device 4"); client.println("<a href="/light4on""><button>Turn On </button></a>"); client.println("<a href="/light4off""><button>Turn Off </button></a><br />"); client.println("</center>"); client.println("<br><br>"); client.println("<center>"); client.println("<table border="5">"); client.println("<tr>"); if (digitalRead(5)) { client.print("<td>Light 1 is ON</td>"); } else { client.print("<td>Light 1 is OFF</td>"); } client.println("<br />"); if (digitalRead(4)) { client.print("<td>Light 2 is ON</td>"); } else {
  • 19. client.print("<td>Light 2 is OFF</td>"); } client.println("</tr>"); client.println("<tr>"); if (digitalRead(0)) { client.print("<td>Light 3 is ON</td>"); } else { client.print("<td>Light 3 is OFF</td>"); } if (digitalRead(13)) { client.print("<td>Light 4 is ON</td>"); } else { client.print("<td>Light 4 is OFF</td>");