Professional Documents
Culture Documents
Expt No 3 - 16010220062
Expt No 3 - 16010220062
Experiment No:3
Title: Controlling LED through an HTTP page Using Node MCU
COs to be achieved: Students will be able to design application of IoT using appropriate platform
CO3: Describe fundamentals of IoT
CO5: Apply concept of WSN and IoT for domain specific applications
Theory:
For ESP32:
https://espressif.github.io/arduino-esp32/package_esp32_index.json
step1. Choose Preferences in the File menu and enter the copied code in Additional Board
Manager URLs part. Then press OK.
Step2. Search the word ESP8266(Node MCU) in Boards>boards manager from Tools
menu. Then install ESP8266 boards. After complete installation, you will see the
INSTALLED label on ESP8266 boards.
After these two steps, you can see ESP8266 based boards such as NodeMCU in your
Arduino IDE boards list, and you can choose your desired board to upload the code.
Selection of Port :
2) Go to Tools > Port and select a COM port available. If the COM port is grayed out,
this means you don’t have the required USB drivers. Check the section Installing USB
Drivers before proceeding.
Connect your ESP8266 development board to your computer using a USB cable.
Now, follow the next steps to upload the code.
1) Go to Tools > Board, scroll down to the ESP8266 section and select your ESP8266
board.
2) Go to Tools > Port and select a COM port available. If the COM port is grayed out,
this means you don’t have the required USB drivers. Check the section Installing USB
Drivers before proceeding.
3) Press the upload button.
The code should be successfully uploaded to the board after a few seconds.
For ESP32 :
1. Open the Boards Manager. Go to Tools > Board >Boards Manager…
Search for ESP32 and install the “ESP32 by Espressif Systems“:
That’s it. It will be installed after a few seconds.
Then, go to Tools > Board and check that you have ESP32 boards available.
Overview:
Stepwise-Procedure:
Observation Table:
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
ESP8266WebServer
server(80);
void handleRoot() {
String html = "<form action=\"/LED_BUILTIN_on\" method=\"get\"><button
type=\"submit\" style=\"font-size:200px;
padding:200px;\">Off</button></form>";
html += "<form action=\"/LED_BUILTIN_off\" method=\"get\"><button
type=\"submit\" style=\"font-size:200px;
padding:200px;\">On</button></form>";
server.send(200, "text/html", html);
}
void handleSave() {
if (server.arg("pass") != "") {
Serial.println(server.arg("pass"));
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
delay(3000);
Serial.begin(115200);
Serial.println();
WiFi.begin(ssid, password);
delay(500);
Serial.print(".");
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address:");
Serial.println(WiFi.localIP());
server.on ( "/",
handleRoot );
server.begin();
server.on("/LED_BUILTIN_on", []() {
digitalWrite(LED_BUILTIN, 1);
Serial.println("on");
handleRoot();
});
server.on("/LED_BUILTIN_off", []() {
digitalWrite(LED_BUILTIN, 0);
Serial.println("off");
handleRoot();
});
void loop() {
server.handleClient();
void setup()
{
pinMode(LED, OUTPUT);
}
void loop(){
digitalWrite(LED , HIGH);
delay(1000);
digitalWrite(LED , LOW);
delay(1000);
Microprocessors and microcontrollers are both essential components in embedded systems, but
they serve different purposes and have distinct characteristics. Here are the key differences
between a microprocessor and a microcontroller:
1. **Functionality:**
2. **Components:**
- **Microprocessor:** Typically consists of just the CPU. It relies on external components
like memory, input/output devices, and other peripherals to form a complete computer system.
- **Microcontroller:** Integrates the CPU, memory (RAM and ROM), input/output ports,
timers, and sometimes other peripherals like analog-to-digital converters on a single chip.
3. **Applications:**
- **Microprocessor:** Used in general-purpose computing applications such as personal
computers, servers, and workstations.
- **Microcontroller:** Employed in dedicated control applications, such as in embedded
systems found in appliances, automotive systems, industrial automation, robotics, and more.
5. **Power Consumption:**
- **Microprocessor:** Typically designed for higher performance and may consume more
power.
- **Microcontroller:** Designed for efficiency, with lower power consumption, making them
suitable for battery-powered and low-power applications.
6. **Programming:**
- **Microprocessor:** Usually programmed in high-level languages and used for a variety of
applications.
- **Microcontroller:** Often programmed in low-level languages or assembly language and
tailored for specific tasks.
The NodeMCU is a low-cost open-source IoT (Internet of Things) platform based on the
ESP8266 Wi-Fi module. It provides an easy and inexpensive way to connect embedded systems
or devices to the internet and enable them to communicate with each other. Here are some
common uses and applications of NodeMCU:
1. **IoT Prototyping:** NodeMCU is popular for prototyping IoT projects due to its simplicity
and ease of use. It allows developers to quickly create and test connected devices.
2. **Home Automation:** NodeMCU can be used in home automation projects to control and
monitor devices such as lights, thermostats, door locks, and sensors over Wi-Fi.
3. **Sensor Networks:** It is often employed to create sensor networks where various sensors
(temperature, humidity, motion, etc.) are connected to NodeMCU modules, and the data is sent
to a central server or cloud platform.
8. **Smart Cities:** In the context of smart city initiatives, NodeMCU can be applied to create
intelligent solutions for monitoring and managing urban infrastructure, such as smart streetlights
or waste management systems.
9. **Remote Monitoring and Control:** NodeMCU allows remote monitoring and control of
devices. For example, you can use it to check the status of a device, receive notifications, or
control it remotely over the internet.
NodeMCU is compatible with the Arduino IDE, making it accessible to a wide community of
developers who are familiar with Arduino programming. It simplifies the process of integrating
Wi-Fi capabilities into projects, making it a popular choice for IoT enthusiasts and developers.
Conclusion:
Implemented and Understood Web page controlled LED using NodeMCU connected on a local
network.