100% found this document useful (1 vote)
93 views33 pages

NodeMCU Based Relay

NodeMCU is an open source IoT platform that allows things to connect to the internet and transfer data using WiFi. It provides functionality like GPIO, PWM, ADC. This project will cover NodeMCU, its communication protocols like UART, I2C, SPI, and how to set up a web server using NodeMCU to build an interactive web page. The web page will accept user input through a form, process the input, and display the output on another page.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
93 views33 pages

NodeMCU Based Relay

NodeMCU is an open source IoT platform that allows things to connect to the internet and transfer data using WiFi. It provides functionality like GPIO, PWM, ADC. This project will cover NodeMCU, its communication protocols like UART, I2C, SPI, and how to set up a web server using NodeMCU to build an interactive web page. The web page will accept user input through a form, process the input, and display the output on another page.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 33

NodeMCU based

Fault Detection

An IoT Project
WHAT WE WILL BE COVERING?
What is NodeMCU and Why do we use them?

Communication Protocols

Pin Configuration of NodeMCU

Programming Kit for NodeMCU

Installing Board Packages

How to connect NodeMCU to WiFi

How to build Webserver


What is NodeMCU? Why NodeMCU?
NodeMCU is an open source platform based on • Low cost and high features
the ESP8266 that allows things to be connected • Comes with micro USB Port
and data to be transferred using the Wi-Fi
protocol. Furthermore, it may solve many of the • Having storage upto 4MBytes
project's demands on its own by providing some • Development board is compact in size
of the most important functionalities of
microcontrollers such as GPIO, PWM, ADC, and • Current consumption in deep sleep mode is
so on. lesser in Node MCU

Power: USB
Developer: ESP8266 Open source Community
Memory: 128kBytes
Storage: 4MBytes
CPU: ESP8266(LX106)
Introductory Price: Rs. 620/- (approx.)
Communication
Protocols

UART
I2C
SPI

This Photo by Unknown Author is licensed under CC BY-NC-ND


UART

01 02 03 04
Universal Bidirectional, Consist of two 3 ways to operate
Asynchronous asynchronous data lines, TX for  Simplex,
Reception and (No Clock), and transmitting and Half-duplex,
Transmission. serial data RX for Full-duplex.
transmission. Receiving.
UART (continued)
Transmitting UART converts parallel
data from master device into serial data
to receiving UART.

Receiving UART then converts it back


into parallel form.

UART data transmission rate is known


as BAUD rate, and it should be same
for both UART devices.
UART (continued)
Advantages Disadvantages
• Simple operation • Cannot Use Multiple masters and
• No Clock Needed slaves.
• Low Transmission speed.
I2C SPI
•  Inter-Integrated-Circuit (I2C) • Serial Peripheral Interface
• Not used for PC-device • Uses four lines – MOSI, MISO, NCLK,
communication but instead with NSS
modules and sensors. • Used in places where speed is
• I2C uses an address system and a important. (eg. SD cards, display
shared bus modules or when info updates and
• Has a low pin/signal count even with changes quickly like thermometers)
numerous devices on the bus
UART vs I2C vs SPI
Protocol UART I2C SPI

Complexity Complex as device


Simple Easy to chain multiple devices
increases

Speed Slowest Faster than UART Fastest

Number of devices Up to 2 devices Up to 127, but gets complex Many, but gets complex

Number of wires 1 2 4

Duplex Full Duplex Half Duplex Full Duplex

No. of masters and slaves Single to Single Multiple slaves and masters 1 master, multiple slaves
Pin
Configuration
Pin Category Name Description

Power Micro-USB, 3.3V, GND, Micro-USB: NodeMCU can be powered through the USB port
Vin  
3.3V: Regulated 3.3V can be supplied to this pin to power the board
 
GND: Ground pins
 
Vin: External Power Supply

Control Pins EN, RST The pin and the button resets the microcontroller

Analog Pin A0 Used to measure analog voltage in the range of 0-3.3V

GPIO Pins GPIO1 to GPIO16 NodeMCU has 16 general purpose input-output pins on its board

SPI Pins SD1, CMD, SD0, CLK NodeMCU has four pins available for SPI communication.

UART Pins TXD0, RXD0, TXD2, NodeMCU has two UART interfaces, UART0 (RXD0 & TXD0) and UART1
RXD2 (RXD1 & TXD1). UART1 is used to upload the firmware/program.

I2C Pins   NodeMCU has I2C functionality support but due to the internal functionality of
these pins, you have to find which pin is I2C.
Programming Kit
Software to be used Hardware to be used

Arduino IDE (Integrated Development


NodeMCU Development Kit/Board consists of
Environment) is the software for Arduino. It
an ESP8266 wifi chip. ESP8266 chip has
is used for writing code, compiling the code
GPIO pins, serial communication protocol, etc.
to check if any errors are there and
features on it
uploading the code to the Arduino. It is a
cross-platform software which is available for
every Operating System
Installing Board
Package
How to Connect
with Wifi?
How to build
webserver?
Main Page
Action
Page
Library Required: ESP8266WebServer.h
Functions Description

server.send() Send web page

server.arg() Read argument from address and


returns it as a string
server.on("/", handleRoot); On address “/”, call the function
“handleRoot”
Include Libraries.

Put Html web page into


variable “MAIN_page”
• Define SSID and Password
• Define Object as “server”
• Define default port
number(80)
• Define Function
“handleRoot”, whenever
called it displays the main
web page.
• Define Function
“handleForm”.
• Whenever called it process
the user input and shows the
result in another webpage
(“actionpage”).
• Server.arg() reads the user
input and returns it as string.
• .toInt() method converts
string to integer.
• Moving into the setup.
• Server.on() calls the mentioned function on
the given address.
• Server.begin() starts the server.
• Moving into the loop.
• Server.handleClient() callback function
which monitors the presence of client and
delivers the requested HTML page.
IP address will be printed on Serial Monitor.
IP address The web page will be accessible through this IP address
Main Page
Action
Page

You might also like