Movatterモバイル変換


[0]ホーム

URL:


PPTX, PDF5,101 views

Introduction to Node MCU

The document provides an overview of NodeMCU, an open-source development environment based on the ESP8266 microcontroller, enabling low-cost, Wi-Fi capable projects. It includes programming instructions using C or Lua, along with practical activities for interfacing with LEDs and serial communication. Additionally, it emphasizes the importance of platform-based development and outlines learning outcomes for participants.

Embed presentation

Downloaded 69 times
NODEMCU1
3
4
We will now have connectivity for anything. Fromany time, any place connectivity for anyone!!!5
Various Names, One ConceptFor over a decade after the introduction of the termInternet-of-Things,different organizations andworking groups have been providing variousdefinitions.• M2M (Machine to Machine)• “Internet of Everything” (Cisco Systems)• “World Size Web” (Bruce Schneier)• “Skynet” (Terminator movie)• Cloud of Things• Web of Things6
7
What is NodeMCU? The NodeMCU (Node MicroController Unit) is an opensource software and hardware development environmentthat is built around a very inexpensive System-on-a-Chip(SoC) called the ESP8266. An Arduino-like device Main component: ESP8266 Withprogrammable pins And built-inwifi Power via USB Low cost8
What you can do with it? Program it via C or LUA Access it via wifi (ex. HTTP) Connect pins to any device(in or out)9
Main Component10
Pin Description11
ESP8266 Block DiagramFigure : ESP8266EX Block Diagram12
Types of ESP826613
Download and install the Arduino Software14
Programming an Arduino• The Arduino softwareconsists of a developmentenvironment (IDE) and thecore libraries.• The IDE is written in Javaand based onthe processing environment.• The core libraries arewritten in C and C++ andcompiled using avr-gcccompiler.15
Arduino environment16
Program StructureSetup( ){// A function that runs once at the start of a program and is used toset //pinMode or initialize serial communication}loop( ){// This function includes the code to be executed continuously – readinginputs, //triggering outputs, etc.// This function is the core of all Arduino programs and does the bulk ofthe //work.}17
BREAD BOARD18
Nodemcu assembling on Breadboard19
LED (Light emitting diode)20
Activity 1.1Type : Team of 2 Duration : 20 MinutesSingle LED blink program using web.Anode of LED Cathode ofLED21
#include <ESP8266WiFi.h>#include <WiFiClient.h>const char* ssid = "XXXX"; //Mention SSIDconst char* password = "XXXX"; //Mention passwordint ledPin = 5; //pin D1 of nodemcuWiFiServer server(80);void setup() {Serial.begin(115200);delay(10);22
pinMode(ledPin, OUTPUT);digitalWrite(ledPin, LOW);// Connect to WiFi networkSerial.println();Serial.println();WiFi.mode(WIFI_AP);/* You can remove the password parameter if youwant the AP to be open. */Serial.print("Connecting to ");Serial.println(ssid);23
WiFi.begin(ssid, password);while (WiFi.status() != WL_CONNECTED) {delay(500);Serial.print(".");}Serial.println("");Serial.println("WiFi connected");// Start the serverserver.begin();Serial.println("Server started");24
// Print the IP addressSerial.print("Use this URL to connect: ");Serial.print("http://");Serial.print(WiFi.localIP());Serial.println("/");}25
void loop(){// Check if a client has connectedWiFiClient client = server.available();if (!client){return;}// Wait until the client sends some dataSerial.println("new client");while (!client.available()){delay(1);}26
// Read the first line of the requestString request = client.readStringUntil('r');Serial.println(request);client.flush();// Match the requestint value = LOW;if (request.indexOf("/LED=ON") != -1) {digitalWrite(ledPin, HIGH);value = HIGH;}if (request.indexOf("/LED=OFF") != -1) {digitalWrite(ledPin, LOW);value = LOW;}27
// Return the responseclient.println("HTTP/1.1 200 OK");client.println("Content-Type: text/html");client.println(""); // do not forget this oneclient.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>");28
delay(1);Serial.println("Client disonnected");Serial.println("");}29
Interfacing with NodeMCU30
Activity 1.2Type : Team of 2 Duration : 20 MinutesTwo LEDs blink program using web31
#include <ESP8266WiFi.h>#include <WiFiClient.h>const char* ssid = "xxxx"; //Mention SSIDconst char* password = "xxxx"; //Mention passwordint ledPin = 5; //pin D2 of nodemcuint ledPin1 = 4; //pin D1 of nodemcuWiFiServer server(80);void setup() {Serial.begin(115200);delay(10);pinMode(ledPin1, OUTPUT);pinMode(ledPin, OUTPUT);digitalWrite(ledPin, LOW);32
// Connect to WiFi networkSerial.println();Serial.println();WiFi.mode(WIFI_AP);/* You can remove the password parameter if you want the AP to be open. */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 serverserver.begin();Serial.println("Server started");33
// Print the IP addressSerial.print("Use this URL to connect: ");Serial.print("http://");Serial.print(WiFi.localIP());Serial.println("/");}void loop(){// Check if a client has connectedWiFiClient client = server.available();34
if (!client){return;}// Wait until the client sends some dataSerial.println("new client");while (!client.available()){delay(1);}// Read the first line of the requestString request = client.readStringUntil('r');Serial.println(request);client.flush();35
// Match the requestint value = LOW;if (request.indexOf("/LED=ON") != -1) {digitalWrite(ledPin, HIGH);value = HIGH;}if (request.indexOf("/LED=OFF") != -1) {digitalWrite(ledPin, LOW);value = LOW;}if (request.indexOf("/LED1=ON") != -1) {digitalWrite(ledPin1, HIGH);value = HIGH;}if (request.indexOf("/LED1=OFF") != -1) {digitalWrite(ledPin1, LOW);value = LOW;}36
// Return the responseclient.println("HTTP/1.1 200 OK");client.println("Content-Type: text/html");client.println(""); // do not forget this oneclient.println("<!DOCTYPE HTML>");client.println("<html>");client.print("Led pin is now: ");if (value == HIGH) {client.print("On");} else {client.print("Off");}37
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("<br><br>");client.println("<a href="/LED1=ON""><button>Turn On1</button></a>");client.println("<a href="/LED1=OFF""><button>Turn Off1</button></a><br />");client.println("</html>");delay(1);Serial.println("Client disonnected");Serial.println("");}38
Serial communicationWhat is serial communication ?39
The word serial means "one after the other." What is Baud rate ?Number of symbols transferred per sec40
Serial Display Functions Serial.begin(baud_rate)//baud rate(characters per sec) between computer andboard is typically 9600 although you can work withother speeds by changing settings of COM Port Serial.print(value),//value could be any data and even string Serial.println(value)//print in new line41
Eg. Print INDIA on serial monitorvoid setup( ){Serial.begin(9600);// 9600 is default baud rate of serial comport of a computer}void loop( ){Serial.println(“INDIA”); // Send the value “INDIA”}42
Serial Monitor43
Activity 1.3Type : Team of 2 Duration : 20 MinutesWi-Fi Network Scanning by NodeMCU44
#include <ESP8266WiFi.h>void setup(){Serial.begin(115200); // Set WiFi to station modeWiFi.mode(WIFI_STA);WiFi.disconnect();delay(100);Serial.println("Setup done");}void loop(){Serial.println("scan start");int n = WiFi.scanNetworks(); // WiFi.scanNetworks willreturn the number of networksfoundSerial.println("scan done");45
if (n == 0)Serial.println("no networks found");else{Serial.print(n);Serial.println(" networks found");for (int i = 0; i < n; ++i){// Print SSID and RSSI for each network foundSerial.print(i + 1);Serial.print(": ");Serial.print(WiFi.SSID(i));Serial.print(" (");Serial.print(WiFi.RSSI(i));Serial.print(")");Serial.println((WiFi.encryptionType(i) == ENC_TYPE_NONE) ? " " :"*");delay(10);}46
}Serial.println("");delay(5000);}47
Learning OutcomesAt the end of the workshop the student should be able to1. Explain the importance of platform based development2. Understand The importance of NodeMCU and demonstrateits interfacing with various devices and sensors.48
For more information contact:amarjeetsinght@gmail.comlinkedin.com/in/amarjeetsingh-thakur-5491595549
50

Recommended

PPTX
Wi-Fi Esp8266 nodemcu
PPTX
Introduction to Arduino Microcontroller
PDF
Esp8266 basics
PPT
IoT with Arduino
PPTX
Nodemcu - introduction
PPT
Intro to Arduino
PPTX
Internet of Things Using Arduino
PDF
Arduino Lecture 1 - Introducing the Arduino
PDF
Arduino Workshop Day 1 - Basic Arduino
 
PPTX
IoT Based Home Automation System Presantation
PPTX
Arduino for beginners- Introduction to Arduino (presentation) - codewithgauri
PDF
Project report on home automation using Arduino
PPS
What is Arduino ?
PDF
IoT Programming on the Raspberry Pi
PPTX
Presentation on IoT Based Home Automation using android & NodeMCU
PDF
Report on arduino
DOCX
HOME AUTOMATION USING ARDUINO
PPTX
Iot based home automation
PPTX
Introduction to arduino
PPTX
PPT on Bluetooth Based Wireless Sensor Networks
PPTX
M2M - Machine to Machine Technology
PPTX
Temperature based fan speed control & monitoring using
PPT
Voice Control Home Automation
PPT
Raspberry pi
PPTX
Switches and LEDs interface to the 8051 microcontroller
PPTX
Serial Communication in 8051
PPTX
Power dissipation cmos
PPTX
Ultrasonic sensor
PPTX
Introduction to Things board (An Open Source IoT Cloud Platform)
PPTX
ESP8266 Wifi Nodemcu

More Related Content

PPTX
Wi-Fi Esp8266 nodemcu
PPTX
Introduction to Arduino Microcontroller
PDF
Esp8266 basics
PPT
IoT with Arduino
PPTX
Nodemcu - introduction
PPT
Intro to Arduino
PPTX
Internet of Things Using Arduino
PDF
Arduino Lecture 1 - Introducing the Arduino
Wi-Fi Esp8266 nodemcu
Introduction to Arduino Microcontroller
Esp8266 basics
IoT with Arduino
Nodemcu - introduction
Intro to Arduino
Internet of Things Using Arduino
Arduino Lecture 1 - Introducing the Arduino

What's hot

PDF
Arduino Workshop Day 1 - Basic Arduino
 
PPTX
IoT Based Home Automation System Presantation
PPTX
Arduino for beginners- Introduction to Arduino (presentation) - codewithgauri
PDF
Project report on home automation using Arduino
PPS
What is Arduino ?
PDF
IoT Programming on the Raspberry Pi
PPTX
Presentation on IoT Based Home Automation using android & NodeMCU
PDF
Report on arduino
DOCX
HOME AUTOMATION USING ARDUINO
PPTX
Iot based home automation
PPTX
Introduction to arduino
PPTX
PPT on Bluetooth Based Wireless Sensor Networks
PPTX
M2M - Machine to Machine Technology
PPTX
Temperature based fan speed control & monitoring using
PPT
Voice Control Home Automation
PPT
Raspberry pi
PPTX
Switches and LEDs interface to the 8051 microcontroller
PPTX
Serial Communication in 8051
PPTX
Power dissipation cmos
PPTX
Ultrasonic sensor
Arduino Workshop Day 1 - Basic Arduino
 
IoT Based Home Automation System Presantation
Arduino for beginners- Introduction to Arduino (presentation) - codewithgauri
Project report on home automation using Arduino
What is Arduino ?
IoT Programming on the Raspberry Pi
Presentation on IoT Based Home Automation using android & NodeMCU
Report on arduino
HOME AUTOMATION USING ARDUINO
Iot based home automation
Introduction to arduino
PPT on Bluetooth Based Wireless Sensor Networks
M2M - Machine to Machine Technology
Temperature based fan speed control & monitoring using
Voice Control Home Automation
Raspberry pi
Switches and LEDs interface to the 8051 microcontroller
Serial Communication in 8051
Power dissipation cmos
Ultrasonic sensor

Similar to Introduction to Node MCU

PPTX
Introduction to Things board (An Open Source IoT Cloud Platform)
PPTX
ESP8266 Wifi Nodemcu
PPTX
Using arduino and raspberry pi for internet of things
PDF
NodeMCU 0.9 Manual using Arduino IDE
PPTX
IoT Hands-On-Lab, KINGS, 2019
PDF
Esp8266 v12
PDF
NodeMCU with Blynk and Firebase
PPTX
IoT Application Development
PPTX
Nodemcu and IOT.pptx
PDF
Node MCU Fun
PDF
Gaztea Tech Robotica 2016
PDF
p12a-esp8266 aaaaaaaaaaaaaaaaaaahttp.pdf
PDF
Arduino delphi 2014_7_bonn
PDF
Arduino: interruptor de encendido controlado por Internet
PPTX
Esp8266 Workshop
PDF
programmer avec Arduino
PDF
Arduino Teaching Program
PDF
Design of home automation base on internet
PPTX
Capstonetech1 v.0.03
PPTX
Final Presentation - Edan&Itzik
Introduction to Things board (An Open Source IoT Cloud Platform)
ESP8266 Wifi Nodemcu
Using arduino and raspberry pi for internet of things
NodeMCU 0.9 Manual using Arduino IDE
IoT Hands-On-Lab, KINGS, 2019
Esp8266 v12
NodeMCU with Blynk and Firebase
IoT Application Development
Nodemcu and IOT.pptx
Node MCU Fun
Gaztea Tech Robotica 2016
p12a-esp8266 aaaaaaaaaaaaaaaaaaahttp.pdf
Arduino delphi 2014_7_bonn
Arduino: interruptor de encendido controlado por Internet
Esp8266 Workshop
programmer avec Arduino
Arduino Teaching Program
Design of home automation base on internet
Capstonetech1 v.0.03
Final Presentation - Edan&Itzik

More from Amarjeetsingh Thakur

PPTX
Arduino Interfacing with different sensors and motor
PPTX
Introduction to Internet of Things (IoT)
PPTX
Introduction to Arduino
PDF
Arduino programming part1
PPTX
Introduction to Arduino
PPTX
Adafruit_IoT_Platform
PPTX
Image Processing Using MATLAB
PPTX
Introduction to MQ Telemetry Transport (MQTT)
PDF
Python code for Buzzer Control using Raspberry Pi
PPTX
Image processing in MATLAB
PDF
Arduino programming part 2
PDF
Python OpenCV Real Time projects
PDF
Python openCV codes
PDF
Core python programming tutorial
PDF
Python code for servo control using Raspberry Pi
PDF
Python openpyxl
PDF
Python Numpy Source Codes
PPTX
“Introduction to MATLAB & SIMULINK”
PDF
Python code for Push button using Raspberry Pi
PDF
Steemit html blog
Arduino Interfacing with different sensors and motor
Introduction to Internet of Things (IoT)
Introduction to Arduino
Arduino programming part1
Introduction to Arduino
Adafruit_IoT_Platform
Image Processing Using MATLAB
Introduction to MQ Telemetry Transport (MQTT)
Python code for Buzzer Control using Raspberry Pi
Image processing in MATLAB
Arduino programming part 2
Python OpenCV Real Time projects
Python openCV codes
Core python programming tutorial
Python code for servo control using Raspberry Pi
Python openpyxl
Python Numpy Source Codes
“Introduction to MATLAB & SIMULINK”
Python code for Push button using Raspberry Pi
Steemit html blog

Recently uploaded

PPTX
Presentation on Purdue model for control hierarchy
PDF
IPEC Presentation - Partial discharge Pro .pdf
PPTX
Cloud vs On-Premises CMMS — Which Maintenance Platform Is Better for Your Plant?
PPTX
MECCA Empire – Hotel Shuttle System for the 2026 FIFA World Cup
 
PPTX
UnrealGameplayAbilitySystemPresentation.pptx
PPTX
Assessment 4 SRS Presentation - Final (2).pptx
PDF
Hybrid Anomaly Detection Mechanism for IOT Networks
PPTX
Industrial Plant Safety – Comprehensive Guide for Workplace Safety & Risk Pre...
PPTX
Plant Performance Strategies: Enhanced Reliability & Operational Efficiency w...
PDF
Basic Control system for oin and gas PART1.pdf
PPTX
Optimizing Operations: Key Elements of a Successful Plant Maintenance Plan — ...
PPTX
TPM Metrics & Measurement: Drive Performance Excellence with TPM | MaintWiz
PDF
Hazim Gaber - A Lean Six Sigma Black Belt
PPTX
How to Implement Kaizen in Your Organization for Continuous Improvement Success
PPTX
Natural Gas fundamentals and GRU for associated gas trap.pptx
PPTX
Vertical turbine pump explains installed in power plants
PPTX
علي نفط.pptx هندسة النفط هندسة النفط والغاز
PDF
Best Architecture in Kovilpatti - Amar Dexign Scape.pdf
PPTX
Data Science with R Final yrUnit II.pptx
PPTX
Role of In Vitro and In Vivo Testing biomedical engineering
Presentation on Purdue model for control hierarchy
IPEC Presentation - Partial discharge Pro .pdf
Cloud vs On-Premises CMMS — Which Maintenance Platform Is Better for Your Plant?
MECCA Empire – Hotel Shuttle System for the 2026 FIFA World Cup
 
UnrealGameplayAbilitySystemPresentation.pptx
Assessment 4 SRS Presentation - Final (2).pptx
Hybrid Anomaly Detection Mechanism for IOT Networks
Industrial Plant Safety – Comprehensive Guide for Workplace Safety & Risk Pre...
Plant Performance Strategies: Enhanced Reliability & Operational Efficiency w...
Basic Control system for oin and gas PART1.pdf
Optimizing Operations: Key Elements of a Successful Plant Maintenance Plan — ...
TPM Metrics & Measurement: Drive Performance Excellence with TPM | MaintWiz
Hazim Gaber - A Lean Six Sigma Black Belt
How to Implement Kaizen in Your Organization for Continuous Improvement Success
Natural Gas fundamentals and GRU for associated gas trap.pptx
Vertical turbine pump explains installed in power plants
علي نفط.pptx هندسة النفط هندسة النفط والغاز
Best Architecture in Kovilpatti - Amar Dexign Scape.pdf
Data Science with R Final yrUnit II.pptx
Role of In Vitro and In Vivo Testing biomedical engineering

Introduction to Node MCU

  • 1.
  • 2.
  • 3.
  • 4.
    We will nowhave connectivity for anything. Fromany time, any place connectivity for anyone!!!5
  • 5.
    Various Names, OneConceptFor over a decade after the introduction of the termInternet-of-Things,different organizations andworking groups have been providing variousdefinitions.• M2M (Machine to Machine)• “Internet of Everything” (Cisco Systems)• “World Size Web” (Bruce Schneier)• “Skynet” (Terminator movie)• Cloud of Things• Web of Things6
  • 6.
  • 7.
    What is NodeMCU?The NodeMCU (Node MicroController Unit) is an opensource software and hardware development environmentthat is built around a very inexpensive System-on-a-Chip(SoC) called the ESP8266. An Arduino-like device Main component: ESP8266 Withprogrammable pins And built-inwifi Power via USB Low cost8
  • 8.
    What you cando with it? Program it via C or LUA Access it via wifi (ex. HTTP) Connect pins to any device(in or out)9
  • 9.
  • 10.
  • 11.
    ESP8266 Block DiagramFigure: ESP8266EX Block Diagram12
  • 12.
  • 13.
    Download and installthe Arduino Software14
  • 14.
    Programming an Arduino•The Arduino softwareconsists of a developmentenvironment (IDE) and thecore libraries.• The IDE is written in Javaand based onthe processing environment.• The core libraries arewritten in C and C++ andcompiled using avr-gcccompiler.15
  • 15.
  • 16.
    Program StructureSetup( ){//A function that runs once at the start of a program and is used toset //pinMode or initialize serial communication}loop( ){// This function includes the code to be executed continuously – readinginputs, //triggering outputs, etc.// This function is the core of all Arduino programs and does the bulk ofthe //work.}17
  • 17.
  • 18.
  • 19.
  • 20.
    Activity 1.1Type :Team of 2 Duration : 20 MinutesSingle LED blink program using web.Anode of LED Cathode ofLED21
  • 21.
    #include <ESP8266WiFi.h>#include <WiFiClient.h>constchar* ssid = "XXXX"; //Mention SSIDconst char* password = "XXXX"; //Mention passwordint ledPin = 5; //pin D1 of nodemcuWiFiServer server(80);void setup() {Serial.begin(115200);delay(10);22
  • 22.
    pinMode(ledPin, OUTPUT);digitalWrite(ledPin, LOW);//Connect to WiFi networkSerial.println();Serial.println();WiFi.mode(WIFI_AP);/* You can remove the password parameter if youwant the AP to be open. */Serial.print("Connecting to ");Serial.println(ssid);23
  • 23.
    WiFi.begin(ssid, password);while (WiFi.status()!= WL_CONNECTED) {delay(500);Serial.print(".");}Serial.println("");Serial.println("WiFi connected");// Start the serverserver.begin();Serial.println("Server started");24
  • 24.
    // Print theIP addressSerial.print("Use this URL to connect: ");Serial.print("http://");Serial.print(WiFi.localIP());Serial.println("/");}25
  • 25.
    void loop(){// Checkif a client has connectedWiFiClient client = server.available();if (!client){return;}// Wait until the client sends some dataSerial.println("new client");while (!client.available()){delay(1);}26
  • 26.
    // Read thefirst line of the requestString request = client.readStringUntil('r');Serial.println(request);client.flush();// Match the requestint value = LOW;if (request.indexOf("/LED=ON") != -1) {digitalWrite(ledPin, HIGH);value = HIGH;}if (request.indexOf("/LED=OFF") != -1) {digitalWrite(ledPin, LOW);value = LOW;}27
  • 27.
    // Return theresponseclient.println("HTTP/1.1 200 OK");client.println("Content-Type: text/html");client.println(""); // do not forget this oneclient.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>");28
  • 28.
  • 29.
  • 30.
    Activity 1.2Type :Team of 2 Duration : 20 MinutesTwo LEDs blink program using web31
  • 31.
    #include <ESP8266WiFi.h>#include <WiFiClient.h>constchar* ssid = "xxxx"; //Mention SSIDconst char* password = "xxxx"; //Mention passwordint ledPin = 5; //pin D2 of nodemcuint ledPin1 = 4; //pin D1 of nodemcuWiFiServer server(80);void setup() {Serial.begin(115200);delay(10);pinMode(ledPin1, OUTPUT);pinMode(ledPin, OUTPUT);digitalWrite(ledPin, LOW);32
  • 32.
    // Connect toWiFi networkSerial.println();Serial.println();WiFi.mode(WIFI_AP);/* You can remove the password parameter if you want the AP to be open. */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 serverserver.begin();Serial.println("Server started");33
  • 33.
    // Print theIP addressSerial.print("Use this URL to connect: ");Serial.print("http://");Serial.print(WiFi.localIP());Serial.println("/");}void loop(){// Check if a client has connectedWiFiClient client = server.available();34
  • 34.
    if (!client){return;}// Waituntil the client sends some dataSerial.println("new client");while (!client.available()){delay(1);}// Read the first line of the requestString request = client.readStringUntil('r');Serial.println(request);client.flush();35
  • 35.
    // Match therequestint value = LOW;if (request.indexOf("/LED=ON") != -1) {digitalWrite(ledPin, HIGH);value = HIGH;}if (request.indexOf("/LED=OFF") != -1) {digitalWrite(ledPin, LOW);value = LOW;}if (request.indexOf("/LED1=ON") != -1) {digitalWrite(ledPin1, HIGH);value = HIGH;}if (request.indexOf("/LED1=OFF") != -1) {digitalWrite(ledPin1, LOW);value = LOW;}36
  • 36.
    // Return theresponseclient.println("HTTP/1.1 200 OK");client.println("Content-Type: text/html");client.println(""); // do not forget this oneclient.println("<!DOCTYPE HTML>");client.println("<html>");client.print("Led pin is now: ");if (value == HIGH) {client.print("On");} else {client.print("Off");}37
  • 37.
    client.println("<br><br>");client.println("<a href="/LED=ON""><button>Turn On</button></a>");client.println("<ahref="/LED=OFF""><button>Turn Off</button></a><br />");client.println("<br><br>");client.println("<a href="/LED1=ON""><button>Turn On1</button></a>");client.println("<a href="/LED1=OFF""><button>Turn Off1</button></a><br />");client.println("</html>");delay(1);Serial.println("Client disonnected");Serial.println("");}38
  • 38.
    Serial communicationWhat isserial communication ?39
  • 39.
    The word serialmeans "one after the other." What is Baud rate ?Number of symbols transferred per sec40
  • 40.
    Serial Display FunctionsSerial.begin(baud_rate)//baud rate(characters per sec) between computer andboard is typically 9600 although you can work withother speeds by changing settings of COM Port Serial.print(value),//value could be any data and even string Serial.println(value)//print in new line41
  • 41.
    Eg. Print INDIAon serial monitorvoid setup( ){Serial.begin(9600);// 9600 is default baud rate of serial comport of a computer}void loop( ){Serial.println(“INDIA”); // Send the value “INDIA”}42
  • 42.
  • 43.
    Activity 1.3Type :Team of 2 Duration : 20 MinutesWi-Fi Network Scanning by NodeMCU44
  • 44.
    #include <ESP8266WiFi.h>void setup(){Serial.begin(115200);// Set WiFi to station modeWiFi.mode(WIFI_STA);WiFi.disconnect();delay(100);Serial.println("Setup done");}void loop(){Serial.println("scan start");int n = WiFi.scanNetworks(); // WiFi.scanNetworks willreturn the number of networksfoundSerial.println("scan done");45
  • 45.
    if (n ==0)Serial.println("no networks found");else{Serial.print(n);Serial.println(" networks found");for (int i = 0; i < n; ++i){// Print SSID and RSSI for each network foundSerial.print(i + 1);Serial.print(": ");Serial.print(WiFi.SSID(i));Serial.print(" (");Serial.print(WiFi.RSSI(i));Serial.print(")");Serial.println((WiFi.encryptionType(i) == ENC_TYPE_NONE) ? " " :"*");delay(10);}46
  • 46.
  • 47.
    Learning OutcomesAt theend of the workshop the student should be able to1. Explain the importance of platform based development2. Understand The importance of NodeMCU and demonstrateits interfacing with various devices and sensors.48
  • 48.
    For more informationcontact:amarjeetsinght@gmail.comlinkedin.com/in/amarjeetsingh-thakur-5491595549
  • 49.

[8]ページ先頭

©2009-2025 Movatter.jp