IOT Lab manual-new
IOT Lab manual-new
1
Creating New Projects
To get started, navigate to the Wokwi Simulator website. From there, you’ll see the following
dashboard. You can use the app for free and without creating a user account.
2
Wokwi Main Sheet
3
• The ESP32 is a popular choice among other modules for the following two
reasons:
• Low Cost of ESP32: This board is available at low prices, starting at $6, which
makes it accessible for students, teachers, hobbyists, and professional users as
well. This makes it the best board for experimentation.
• Low Power Consumption: The ESP32 runs on very low power as compared to
the other options. It has mode states such as deep sleep to save the power and
this makes it ideal for the IoT and other such projects.
Features of ESP32:
• ESP32 is considered one of the best boards for IoT projects because of the
versatility and latest features that are in demand for such projects. The following
features will help you understand the functionalities of ESP32.
4
– Bluetooth Low Energy (BLE) is the latest technology that can be
used to connect devices like smart watches, fitness trackers, heart
rate monitors, etc.
• The ESP32 supports both types of Bluetooth; therefore, multiple types of devices
are suitable for use with it.
RESULTS:
5
Assignment Question
1. What is the Wokwi simulator, and how does it work for simulating microcontroller
projects?
2. What are the key differences between simulating a project on Wokwi versus testing on
actual hardware (e.g., ESP32 or Arduino)?
6
JSPM University Pune
Faculty of Science and Technology
School of Basic & Applied Sciences
F.Y. MCA , MSc. “Internet of Things and Applications”
Experiment No: 2 Date: / /
Aim: Arduino IDE Software Installation and Programming Concepts for Node MCU
DESCRIPTION:
The Arduino IDE is the primary tool we will use in the class for programming the ESP32 based
microcontroller, though there are a lot of other options, such as Visual Studio Code. We will
also use the Arduino programming language, which is essentially a wrapper of C/C++. You can
also use MicroPython, a subset of Python that designed for to run on a microcontroller.
However, we will not cover the syntax of MicroPython, and it is up to you to figure this out.
Depending on your operating system, the installation may vary. Contact TA if you encounter
any issues and we can figure it out together. Below we will use Windows system as an
example, with side notes for Mac users.
INSTALLATION STEPS:
1. Install Arduino IDE. We will use the Arduino IDE 2.2.1 version: here is the link for Windows
or MacOS.
2. Install ESP32 support. Go to File - Preference, as in Figure 1. In the box Additional boards
manger URLs, paste https://raw.githubusercontent.com/espressif/arduino-esp32/gh-
pages/package_esp32_index.json
3. Click OK.
4. Click Tools - Board: - Boards Manger in file click preferences
7
5. Paste the link for installing ESP 32 Board.
8
7. Select Version for ESP32
9
PROGRAMMING CONCEPT:
• pinMode() : The specific pin number is set as the INPUT or OUTPUT in the pinMode ()
function.
▪ Syntax is: pinMode (pin, mode);
▪ Eg : pinMode(13,OUTPUT);
10
represents 0v and 5v. digitalRead() is used by digital pin (0-13) of Arduino.
▪ Syntax : digitalRead(pin);
▪ Eg : digitalRead(13);
RESULTS:
Assignment Questions
1. What are the main features of the ESP32, and how does it differ from other
microcontrollers like the Arduino Uno or NodeMCU?
2. How do you set up and upload a simple program, like blinking an LED, to the ESP32 using
the Arduino IDE?
3. How can you connect the ESP32 to a Wi-Fi network.
4. What is the role of the GPIO pins on the ESP32, and how can you use them to control
sensors or actuators in a project?
11
JSPM University Pune
Faculty of Science and Technology
School of Basic & Applied Sciences
F.Y. MCA , MSc. “Internet of Things and Applications”
Experiment No: 3 Date: / /
Aim: Controlling GPIO pins and LED blinking using NodeMCU/ESP32 (Digital Write).
DESCRIPTION:
LED blinking is the most beginner & easy step to start experiments with ESP32.
Firstly identify anode (+ve) & cathode (-ve) leg of LED. Following diagram gives a
clear idea of LED. Now connect a resistor to positive leg and other end of resistor to
5V.Cathode will be connected to EPS32 GPIO, in this case pin 13. Final circuit will
look as below:
INTERFACING DIAGRAM:
12
PROCEDURE:
• Give the connections to the ESP32 board as shown in the connection diagram.
• Open Arduino IDE in the computer
• Create new file_--→ New
• Type your program and Save it in appropriate location in your computer.
• Compile your program by clicking Verify option in the menu.
• Once the program compiled successfully, connect the Arduino board to the
computer using USB cable. After connecting, go to Tools ----→Board ---→
Select Arduino/Genuine Uno option
• After selecting board, go to Tools ----→Port ---→ Select Arduino Uno COM port 3
PROGRAM:
RESULTS:
13
ANALYSIS AND INFERENCES:
Assignment Questions
1. What are the components required for blinking LED using ESP32?
2. What is the use of resistor in connection diagram.
3. What is the command used to declare the inputs/outputs?
4. List out the types of LED’s.
14
JSPM University Pune
Faculty of Science and Technology
School of Basic & Applied Sciences
F.Y. MCA , MSc. “Internet of Things and Applications”
Experiment No: 4 Date: / /
Aim: Controlling LED using push button with NodeMCU/ ESP32 (Digital Read).
DESCRIPTION:
In this experiment we simply hook up 5 volts to one side of a button and to the other
side of the button we connect pin 2. When you press the button it completes an
electrical connection, pin 2 will “see” the 5 volts and if we digitalRead() at pin 2, it will
report HIGH. During the times the button is not being pressed, pin 2 reports LOW.
We also have pin 2 connected to ground at all times through a resistor. This is because
when we read values at pin 2, we want to get either a HIGH or a LOW reported. If pin 2
is not connected to ground, then when the button is not being pressed it becomes what
is called a floating pin – it’s not connected to anything. Floating pins on the ESP32 are
fine for the most part – unless you are trying to record an input from them – then they
are bad, and can give you spurious information.
INTERFACING DIAGRAM:
15
PROCEDURE:
• Connect one of the E S P32 GND pins to one of the long power rails on
the bread board –this will be the ground rail.
• Connect the short leg of the LED to this same ground rail on the breadboard
thenconnect the long leg to a row on the breadboard.
• Connect the 220-ohm resistor from pin 11 to the same row that you have the
longleg of the LED attached.
• Place the pushbutton on the breadboard. Most buttons will straddle the
centertrench on the breadboard.
• Connect a jumper wire from the 5-volt pin to one side of the pushbutton.
• Connect a jumper wire from pin 7 to the other side of the pushbutton.
• Connect one side of the 10k resistor from the ground rail on the breadboard to
theother side to the pushbutton – on the same side that pin 7 connects.
PROGRAM:
16
RESULTS:
Assignment Questions
17
JSPM University Pune
Faculty of Science and Technology
School of Basic & Applied Sciences
F.Y. MCA , MSc. “Internet of Things and Applications”
Experiment No: 5 Date: / /
Aim: Interfacing potentiometer with NodeMCU/ ESP32 (Analog Read).
DESCRIPTION:
The potentiometer is a device that is used to measure the voltage or electric potential. It
provides a variable resistance when the shaft of the device is turned.
The potentiometer is a three-terminal device. It has a rotating contact that acts as an
adjustable voltage divider. The potentiometer structure consists of a sliding contact
(called wiper), a resistive element, electrical terminals, and housing.
The sliding contact moves along the resistive element, while the housing consists of the
wiper and the element.
WORKING:
The fixed input voltage is applied across the two ends terminal of a potentiometer,
which further produces the adjustable output voltage at the wiper or slider. As the slider
moves from one end to another, the divider can vary the output voltage from maximum
to Ground.
INTERFACING DIAGRAM:
18
PROCEDURE:
• Connect potentiometer to ESP32 Board.
• Connect one terminal of potentiometer to GND
• Connect other terminal to 5V supply.
• Connect middle terminal to ANALOG pin
PROGRAM:
RESULTS:
19
ANALYSIS AND INFERENCES:
Assignment Questions
20
JSPM University Pune
Faculty of Science and Technology
School of Basic & Applied Sciences
F.Y. MCA , MSc. “Internet of Things and Applications”
Experiment No: 6 Date: / /
Aim: Smart lighting system using LDR and NodeMCU/ ESP32.
DESCRIPTION:
LDR (Light Dependent Resistor) as the name states is a special type of resistor that
works on the photoconductivity principle means that resistance changes according to
the intensity of light. Its resistance decreases with an increase in the intensity of light.
It is often used as a light sensor, light meter, Automatic street light, and in areas where
we need to have light sensitivity. LDR is also known as a Light Sensor. LDR are usually
available in 5mm, 8mm, 12mm, and 25mm dimensions.
Two metal contacts are placed on both ends of the Zig-Zag shape these metal
contacts help in creating a connection with the LDRs. Now, a transparent coating is
applied on the top so that the zig- zag- shaped photosensitive material gets protected
and as the coating is transparent the LDR will be able to capture light from the outer
environment for its working.
21
INTERFACING DIAGRAM:
PROCEDURE:
• Connect other resistor leg to ground.
• Wire up the LED anode (positive, longer leg) to ESP32 pin 9.
• Drag a photoresistor from the components panel to your breadboard, so
itslegs plug into two different rows.
• Click to create a wire connecting one photoresistor leg to power.
PROGRAM:
22
RESULTS:
23
ANALYSIS AND INFERENCES:
Assignment Questions
1. What is LDR?
2. Which type of sensor is LDR?
3. Why LDR is used?
4. How LDR are Made?
24
JSPM University Pune
Faculty of Science and Technology
School of Basic & Applied Sciences
F.Y. MCA , MSc. “Internet of Things and Applications”
Experiment No: 7 Date: / /
Aim: Motion Detection using PIR Sensor and NodeMCU/ ESP32.
DESCRIPTION:
PIR stands for Passive Infrared Sensor. It is called passive sensor because it does
not emit the IR rays. It only receives the IR rays. PIR sensor allows to detect or
sense the motion. It is small, Inexpensive and low power device. It is non-wearable
device for that reason they are commonly found in appliances and gadgets used in
homes or businesses. It is having 3 pin structure where, o Pin 1 is Vcc (+5v) o Pin 2
is Output o Pin 3 is ground All pins must be connected with Arduino pins. PIR
sensor can detect animal/human movement in a requirement range. For Indoor
passive infrared Detection distances range from 25 cm to 20 m. For Outdoor
passive infrared, the detection distance ranges from 10 meters to 150 meters. It
detects infrared radiation from the environment. Once there is infrared radiation
from the human body particle with temperature, focusing on the optical system
causes the device to generate a sudden electrical signal.
25
Figure: Structure and Working Principle of PIR Sensor
INTERFACING DIAGRAM:
26
PROCEDURE:
• Give the connections to the ESP32 board as shown in the connection diagram.
• Open Arduino IDE in the computer
• Create new file File_--→ New
• Type your program and Save it in appropriate location in your computer.
• Compile your program by clicking Verify option in the menu.
• Once the program compiled successfully, connect the Arduino
board to the computer using USB cable.
• After connecting, go to Tools ----→Board ---→ Select Arduino/Genuino
Unooption.
• After selecting board, go to Tools ----→Port ---→ Select Arduino
UnoCOM port 3 (name may appear differently for other computers).
PROGRAM:
30
RESULTS:
31
ANALYSIS AND INFERENCES:
Assignment Questions
29
JSPM University Pune
Faculty of Science and Technology
School of Basic & Applied Sciences
F.Y. MCA , MSc. “Internet of Things and Applications”
Experiment No: 8 Date: / /
Aim: Temperature measurement using thermistor-LM35/DHT11 and NodeMCU/
ESP32.
DESCRIPTION:
A thermistor is a type of temperature sensor that changes its resistance with
temperature variations. Specifically, we will be using an NTC (Negative
Temperature Coefficient) thermistor, which has a higher resistance at lower
temperatures and lower resistance at higher temperatures. By measuring the
resistance of the thermistor, we can determine the temperature. The thermistor is
connected to the Arduino UNO using two wires. One end of the thermistor is
connected to the 5V pin of the Arduino, and the other end is connected to an
analog input pin (e.g., A0). Additionally, a resistor (typically 10k ohms) is connected
in parallel with the thermistor, with one end connected to the analog input pin and
the other end connected to ground.
INTERFACING DIAGRAM:
30
PROCEDURE:
• Give the connections to the Arduino board as shown in the connection diagram.
• Open Arduino IDE in the computer
• Create new file File_--→ New
• Type your program and Save it in appropriate location in your computer.
• Compile your program by clicking Verify option in the menu.
• Once the program compiled successfully, connect the Arduino
board to the computer using USB cable.
• After connecting, go to Tools ----→Board ---→ Select Arduino Uno option
• After selecting board, go to Tools ----→Port ---→ Select Arduino Uno COM
port 3 (name may appear differently for other computers).
**Note that this port option will be displayed only when board is connected to computer
• Now upload the program to the Arduino board by clicking Upload option.
• Observe the output.
PROGRAM:
31
RESULTS:
Assignment Questions
1. What is a thermistor?
2. How is the thermistor connected to the ESP32?
3. How can we convert the analog reading from the thermistor into temperature
values?
4. How can we improve the accuracy of temperature measurements
usingthe thermistor and ESP32?
5. What are some applications of temperature measurement using a thermistor and
ESP32?
32
JSPM University Pune
Faculty of Science and Technology
School of Basic & Applied Sciences
F.Y. MCA , MSc. “Internet of Things and Applications”
Experiment No: 9 Date: / /
Aim: Distance measurement using SR-04 and NodeMCU/ ESP32.
DESCRIPTION:
To Interface an Ultrasonic sensor to activate a buzzer and RED LED if the distance
between the sensor and object is less than 35 inches and activate Green LED and
OFF the buzzer when distance is more than 35 inches.
33
INTERFACING DIAGRAM:
PROCEDURE:
• Give the connections to the Arduino board as shown in the connection diagram.
• Open Arduino IDE in the computer
• Create new file File_--→ New
• Type your program and Save it in appropriate location in your computer.
• Compile your program by clicking Verify option in the menu.
• Once the program compiled successfully, connect the Arduino board to the
computer using USB cable.
• After connecting, go to Tools ----→Board ---→ Select Arduino/Genuino Uno
34
PROGRAM:
35
RESULTS:
Assignment Questions
36
JSPM University Pune
Faculty of Science and Technology
School of Basic & Applied Sciences
F.Y. MCA , MSc. “Internet of Things and Applications”
Experiment No: 10 Date: / /
Aim: Harmful gas monitoring using NodeMCU and ThingSpeak
APPRATUS: ESP32, Arduino IDE, Breadboard, Resistors, Gas Detecting sensor MQ-
135/MQ-2, connecting wires, supply source, Display.
DESCRIPTION:
This Experiment, reads the sensor analog output voltage and when the smoke reaches
certain level, it will make sound a buzzer and a red LED will turn on. When the output
voltage is below that level, a green LED will be on.
MQ-2 Smoke Sensor
The MQ-2 smoke sensor is sensitive to smoke and to the following flammable gases:
− LPG
− Butane
− Propane
− Methane
− Alcohol
− Hydrogen
The resistance of the sensor is different depending on the type of the gas. The smoke sensor
has a built-in potentiometer that allows you to adjust the sensor sensitivity according to how
accurate you want to detect gas. The voltage that the sensor outputs changes accordingly to
the smoke/gas level that exists in the atmosphere. The sensor outputs a voltage that is
proportional to the concentration of smoke/gas. In other words, the relationship between
voltage and gas concentration is the
37
following:
− The greater the gas concentration, the greater the output voltage
− The lower the gas concentration, the lower the output voltage
The output can be an analog signal (A0) that can be read with an analog input of the
Arduino or a digital output (D0) that can be read with a digital input of the Arduino.
PIN WIRING:
The MQ-2 sensor has 4 pins.
Pin -------- Wiring to Arduino
Uno
A0--------- Analog pins
D0 ---------Digital pins
GND--------- V
So, before jumping into the coding part, let's check whether we've assembled all the
necessary hardware components.
INTERFACING DIAGRAM:
38
PROCEDURE:
• Give the connections to the Arduino board as shown in the connection diagram.
• Open Arduino IDE in the computer
• Create new file File_--→ New
• Type your program and Save it in appropriate location in your computer.
• Compile your program by clicking Verify option in the menu.
• Once the program compiled successfully, connect the Arduino
boardto the computer using USB cable.
• After connecting, go to Tools ----→Board ---→ Select Arduino/Genuino Uno
option
• After selecting board, go to Tools ----→Port ---→ Select Arduino UnoCOM port 3
(name may appear differently for other computers).
PROGRAM:
39
RESULTS:
Assignment Questions
40
JSPM University Pune
Faculty of Science and Technology
School of Basic & Applied Sciences
F.Y. MCA , MSc. “Internet of Things and Applications”
Experiment No: 11 Date: / /
Aim: Servo motor (SG-90) control using ESP32.
DESCRIPTION:
In this lab, participants will learn how to control a servo motor (specifically, the SG-90
servo motor) using an Arduino UNO microcontroller. The lab aims to provide a hands-
on experience in understanding the principles of servo motor control and how to
interface it with the Arduino board.
The lab session will begin with an introduction to servo motors and their applications.
Participants will learn about the working principle of servo motors, which use feedback
control to precisely position the motor shaft. They will understand the structure of a
servo motor, including the motor, gears, and control circuitry.
INTERFACING DIAGRAM:
41
PROCEDURE:
• Give the connections to the Arduino board as shown in the connection diagram.
• Open Arduino IDE in the computer
• Create new file File_--→ New
• Type your program and Save it in appropriate location in your computer.
• Compile your program by clicking Verify option in the menu.
• Once the program compiled successfully, connect the Arduino board to the
computer using USB cable.
• After connecting, go to Tools ----→Board ---→ Select Arduino/Genuino Uno option
• After selecting board, go to Tools ----→Port ---→ Select Arduino
Uno COM port 3 (name may appear differently for other
computers).
PROGRAM:
48
RESULTS:
49
ANALYSIS AND INFERENCES:
Assignment Question
50
51