SlideShare a Scribd company logo
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.

More Related Content

What's hot

silicon ic fabrican technology
silicon ic fabrican technologysilicon ic fabrican technology
silicon ic fabrican technology
govt. engineering college Bikaner
 
Ic 封裝新技術發展趨勢
Ic 封裝新技術發展趨勢Ic 封裝新技術發展趨勢
Ic 封裝新技術發展趨勢
Kent Yang
 
Wi-Fi security – WEP, WPA and WPA2
Wi-Fi security – WEP, WPA and WPA2Wi-Fi security – WEP, WPA and WPA2
Wi-Fi security – WEP, WPA and WPA2Fábio Afonso
 
Arduino lcd display
Arduino lcd displayArduino lcd display
Arduino lcd display
Makers of India
 
Super sensitive intruder alarm
Super sensitive intruder alarmSuper sensitive intruder alarm
Super sensitive intruder alarm
Quratulaintahir1
 
DoH, DoT and ESNI
DoH, DoT and ESNIDoH, DoT and ESNI
DoH, DoT and ESNI
Jisc
 
Introduction to layer 2 attacks & mitigation
Introduction to layer 2 attacks & mitigationIntroduction to layer 2 attacks & mitigation
Introduction to layer 2 attacks & mitigation
Rishabh Dangwal
 
Aircrack
AircrackAircrack
Client Side Exploits using PDF
Client Side Exploits using PDFClient Side Exploits using PDF
Client Side Exploits using PDF
n|u - The Open Security Community
 
傳輸線理論
傳輸線理論傳輸線理論
傳輸線理論
祁 周
 
KiCAD 從電路圖到電路板
KiCAD 從電路圖到電路板KiCAD 從電路圖到電路板
KiCAD 從電路圖到電路板
dahai pon
 
DLT645 protocol english version
DLT645 protocol english versionDLT645 protocol english version
DLT645 protocol english version
Ricky Yang
 
Userspace networking
Userspace networkingUserspace networking
Userspace networking
Stephen Hemminger
 
Immersion lithography
Immersion lithographyImmersion lithography
Immersion lithography
ANANDHU THAMPI
 
esquema Tv portátil AM/FM 5,5 polegadas
esquema Tv portátil AM/FM 5,5 polegadasesquema Tv portátil AM/FM 5,5 polegadas
esquema Tv portátil AM/FM 5,5 polegadas
marcelo santana
 
Original Mosfet AP09N70I 09N70I 09N701 TO-220 New
Original Mosfet AP09N70I 09N70I 09N701 TO-220 NewOriginal Mosfet AP09N70I 09N70I 09N701 TO-220 New
Original Mosfet AP09N70I 09N70I 09N701 TO-220 New
AUTHELECTRONIC
 
PCB Designing
PCB Designing PCB Designing
KEMET Webinar - KEMET ceramic reliability grades- which one should I choose?
KEMET Webinar - KEMET ceramic reliability grades- which one should I choose?KEMET Webinar - KEMET ceramic reliability grades- which one should I choose?
KEMET Webinar - KEMET ceramic reliability grades- which one should I choose?
Ivana Ivanovska
 
A Practical Guide to (Correctly) Troubleshooting with Traceroute
A Practical Guide to (Correctly) Troubleshooting with TracerouteA Practical Guide to (Correctly) Troubleshooting with Traceroute
A Practical Guide to (Correctly) Troubleshooting with Traceroute
Richard Steenbergen
 

What's hot (20)

silicon ic fabrican technology
silicon ic fabrican technologysilicon ic fabrican technology
silicon ic fabrican technology
 
Ic 封裝新技術發展趨勢
Ic 封裝新技術發展趨勢Ic 封裝新技術發展趨勢
Ic 封裝新技術發展趨勢
 
Wi-Fi security – WEP, WPA and WPA2
Wi-Fi security – WEP, WPA and WPA2Wi-Fi security – WEP, WPA and WPA2
Wi-Fi security – WEP, WPA and WPA2
 
Arduino lcd display
Arduino lcd displayArduino lcd display
Arduino lcd display
 
Super sensitive intruder alarm
Super sensitive intruder alarmSuper sensitive intruder alarm
Super sensitive intruder alarm
 
DoH, DoT and ESNI
DoH, DoT and ESNIDoH, DoT and ESNI
DoH, DoT and ESNI
 
Introduction to layer 2 attacks & mitigation
Introduction to layer 2 attacks & mitigationIntroduction to layer 2 attacks & mitigation
Introduction to layer 2 attacks & mitigation
 
Aircrack
AircrackAircrack
Aircrack
 
Client Side Exploits using PDF
Client Side Exploits using PDFClient Side Exploits using PDF
Client Side Exploits using PDF
 
傳輸線理論
傳輸線理論傳輸線理論
傳輸線理論
 
KiCAD 從電路圖到電路板
KiCAD 從電路圖到電路板KiCAD 從電路圖到電路板
KiCAD 從電路圖到電路板
 
DLT645 protocol english version
DLT645 protocol english versionDLT645 protocol english version
DLT645 protocol english version
 
Userspace networking
Userspace networkingUserspace networking
Userspace networking
 
Immersion lithography
Immersion lithographyImmersion lithography
Immersion lithography
 
esquema Tv portátil AM/FM 5,5 polegadas
esquema Tv portátil AM/FM 5,5 polegadasesquema Tv portátil AM/FM 5,5 polegadas
esquema Tv portátil AM/FM 5,5 polegadas
 
Vumetro estereo
Vumetro estereoVumetro estereo
Vumetro estereo
 
Original Mosfet AP09N70I 09N70I 09N701 TO-220 New
Original Mosfet AP09N70I 09N70I 09N701 TO-220 NewOriginal Mosfet AP09N70I 09N70I 09N701 TO-220 New
Original Mosfet AP09N70I 09N70I 09N701 TO-220 New
 
PCB Designing
PCB Designing PCB Designing
PCB Designing
 
KEMET Webinar - KEMET ceramic reliability grades- which one should I choose?
KEMET Webinar - KEMET ceramic reliability grades- which one should I choose?KEMET Webinar - KEMET ceramic reliability grades- which one should I choose?
KEMET Webinar - KEMET ceramic reliability grades- which one should I choose?
 
A Practical Guide to (Correctly) Troubleshooting with Traceroute
A Practical Guide to (Correctly) Troubleshooting with TracerouteA Practical Guide to (Correctly) Troubleshooting with Traceroute
A Practical Guide to (Correctly) Troubleshooting with Traceroute
 

Similar to NodeMCU 0.9 Manual using Arduino IDE

Introduction to Node MCU
Introduction to Node MCUIntroduction to Node MCU
Introduction to Node MCU
Amarjeetsingh Thakur
 
Introduction to Things board (An Open Source IoT Cloud Platform)
Introduction to Things board (An Open Source IoT Cloud Platform)Introduction to Things board (An Open Source IoT Cloud Platform)
Introduction to Things board (An Open Source IoT Cloud Platform)
Amarjeetsingh Thakur
 
Esp8266 v12
Esp8266 v12Esp8266 v12
Esp8266 v12
handson28
 
WIFI ESP01 interfacing with Arduino UNO with Sensor DHT11
WIFI ESP01 interfacing with Arduino UNO with Sensor DHT11WIFI ESP01 interfacing with Arduino UNO with Sensor DHT11
WIFI ESP01 interfacing with Arduino UNO with Sensor DHT11
hussain0075468
 
Webshield internet of things
Webshield internet of thingsWebshield internet of things
Webshield internet of things
Raghav Shetty
 
IoT Hands-On-Lab, KINGS, 2019
IoT Hands-On-Lab, KINGS, 2019IoT Hands-On-Lab, KINGS, 2019
IoT Hands-On-Lab, KINGS, 2019
Jong-Hyun Kim
 
Arduino final ppt
Arduino final pptArduino final ppt
Arduino final ppt
Indu Mathi
 
ESP8266 Wifi Nodemcu
ESP8266 Wifi Nodemcu ESP8266 Wifi Nodemcu
ESP8266 Wifi Nodemcu
creatjet3d labs
 
Open Source Home Automation with LinkSprite.IO
Open Source Home Automation with LinkSprite.IOOpen Source Home Automation with LinkSprite.IO
Open Source Home Automation with LinkSprite.IO
Jingfeng Liu
 
Home Automation with LinkSprite IO
Home Automation with LinkSprite IOHome Automation with LinkSprite IO
Home Automation with LinkSprite IO
Jingfeng Liu
 
Wi-Fi Esp8266 nodemcu
Wi-Fi Esp8266 nodemcu Wi-Fi Esp8266 nodemcu
Wi-Fi Esp8266 nodemcu
creatjet3d labs
 
Arduino by bishal bhattarai IOE, Pashchimanchal Campus Pokhara, Nepal
Arduino by bishal bhattarai  IOE, Pashchimanchal Campus Pokhara, NepalArduino by bishal bhattarai  IOE, Pashchimanchal Campus Pokhara, Nepal
Arduino by bishal bhattarai IOE, Pashchimanchal Campus Pokhara, Nepal
bishal bhattarai
 
Cassiopeia Ltd - ESP8266+Arduino workshop
Cassiopeia Ltd - ESP8266+Arduino workshopCassiopeia Ltd - ESP8266+Arduino workshop
Cassiopeia Ltd - ESP8266+Arduino workshop
tomtobback
 
Intel galileo gen 2
Intel galileo gen 2Intel galileo gen 2
Intel galileo gen 2
srknec
 
programmer avec Arduino
programmer avec Arduinoprogrammer avec Arduino
programmer avec Arduino
mohamednacim
 
Concurrent networking - made easy
Concurrent networking - made easyConcurrent networking - made easy
Concurrent networking - made easy
Amazing Applications AB
 
Microsoft's view of the Internet of Things (IoT) by Imran Shafqat
Microsoft's view of the Internet of Things (IoT) by Imran ShafqatMicrosoft's view of the Internet of Things (IoT) by Imran Shafqat
Microsoft's view of the Internet of Things (IoT) by Imran Shafqat
Allied Consultants
 
Internet of Things (IoT) reference architecture using Azure -MIC - Lahore
Internet of Things (IoT) reference architecture using Azure -MIC - LahoreInternet of Things (IoT) reference architecture using Azure -MIC - Lahore
Internet of Things (IoT) reference architecture using Azure -MIC - Lahore
Information Technology University
 
Introduction to Arduino Microcontroller
Introduction to Arduino MicrocontrollerIntroduction to Arduino Microcontroller
Introduction to Arduino Microcontroller
Mujahid Hussain
 
DeviceHub - First steps using Intel Edison
DeviceHub - First steps using Intel EdisonDeviceHub - First steps using Intel Edison
DeviceHub - First steps using Intel Edison
Gabriel Arnautu
 

Similar to NodeMCU 0.9 Manual using Arduino IDE (20)

Introduction to Node MCU
Introduction to Node MCUIntroduction to Node MCU
Introduction to Node MCU
 
Introduction to Things board (An Open Source IoT Cloud Platform)
Introduction to Things board (An Open Source IoT Cloud Platform)Introduction to Things board (An Open Source IoT Cloud Platform)
Introduction to Things board (An Open Source IoT Cloud Platform)
 
Esp8266 v12
Esp8266 v12Esp8266 v12
Esp8266 v12
 
WIFI ESP01 interfacing with Arduino UNO with Sensor DHT11
WIFI ESP01 interfacing with Arduino UNO with Sensor DHT11WIFI ESP01 interfacing with Arduino UNO with Sensor DHT11
WIFI ESP01 interfacing with Arduino UNO with Sensor DHT11
 
Webshield internet of things
Webshield internet of thingsWebshield internet of things
Webshield internet of things
 
IoT Hands-On-Lab, KINGS, 2019
IoT Hands-On-Lab, KINGS, 2019IoT Hands-On-Lab, KINGS, 2019
IoT Hands-On-Lab, KINGS, 2019
 
Arduino final ppt
Arduino final pptArduino final ppt
Arduino final ppt
 
ESP8266 Wifi Nodemcu
ESP8266 Wifi Nodemcu ESP8266 Wifi Nodemcu
ESP8266 Wifi Nodemcu
 
Open Source Home Automation with LinkSprite.IO
Open Source Home Automation with LinkSprite.IOOpen Source Home Automation with LinkSprite.IO
Open Source Home Automation with LinkSprite.IO
 
Home Automation with LinkSprite IO
Home Automation with LinkSprite IOHome Automation with LinkSprite IO
Home Automation with LinkSprite IO
 
Wi-Fi Esp8266 nodemcu
Wi-Fi Esp8266 nodemcu Wi-Fi Esp8266 nodemcu
Wi-Fi Esp8266 nodemcu
 
Arduino by bishal bhattarai IOE, Pashchimanchal Campus Pokhara, Nepal
Arduino by bishal bhattarai  IOE, Pashchimanchal Campus Pokhara, NepalArduino by bishal bhattarai  IOE, Pashchimanchal Campus Pokhara, Nepal
Arduino by bishal bhattarai IOE, Pashchimanchal Campus Pokhara, Nepal
 
Cassiopeia Ltd - ESP8266+Arduino workshop
Cassiopeia Ltd - ESP8266+Arduino workshopCassiopeia Ltd - ESP8266+Arduino workshop
Cassiopeia Ltd - ESP8266+Arduino workshop
 
Intel galileo gen 2
Intel galileo gen 2Intel galileo gen 2
Intel galileo gen 2
 
programmer avec Arduino
programmer avec Arduinoprogrammer avec Arduino
programmer avec Arduino
 
Concurrent networking - made easy
Concurrent networking - made easyConcurrent networking - made easy
Concurrent networking - made easy
 
Microsoft's view of the Internet of Things (IoT) by Imran Shafqat
Microsoft's view of the Internet of Things (IoT) by Imran ShafqatMicrosoft's view of the Internet of Things (IoT) by Imran Shafqat
Microsoft's view of the Internet of Things (IoT) by Imran Shafqat
 
Internet of Things (IoT) reference architecture using Azure -MIC - Lahore
Internet of Things (IoT) reference architecture using Azure -MIC - LahoreInternet of Things (IoT) reference architecture using Azure -MIC - Lahore
Internet of Things (IoT) reference architecture using Azure -MIC - Lahore
 
Introduction to Arduino Microcontroller
Introduction to Arduino MicrocontrollerIntroduction to Arduino Microcontroller
Introduction to Arduino Microcontroller
 
DeviceHub - First steps using Intel Edison
DeviceHub - First steps using Intel EdisonDeviceHub - First steps using Intel Edison
DeviceHub - First steps using Intel Edison
 

Recently uploaded

Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
SOFTTECHHUB
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Nexer Digital
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 

Recently uploaded (20)

Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
 
Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?Elizabeth Buie - Older adults: Are we really designing for our future selves?
Elizabeth Buie - Older adults: Are we really designing for our future selves?
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 

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>");