0% found this document useful (0 votes)
112 views35 pages

Sample IoT - Lab - File - Experiment - 1 - To - 6

Uploaded by

Manas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
112 views35 pages

Sample IoT - Lab - File - Experiment - 1 - To - 6

Uploaded by

Manas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 35

NOIDA INSTITUTE OF ENGINEERING AND TECHNOLOGY

GREATER NOIDA
Department of CSE(IoT)
School of Computer Sciences in Emerging Technologies

Lab File
of

IoT LAB USING ARDUINO and Node MCU


(BCSIOT-0353)
(3rd Semester)
Session (2024 – 2025)

Affiliated to Dr. A.P.J Abdul Kalam Technical University, Uttar Pradesh, Lucknow

Submitted By: Submitted To:

Student Name: Mr. Mayank Deep Khare

Roll No: Ms. Vatika Jalali

Section:
[BCSIOT0353]IoT LAB USING ARDUINO and Node MCU 2024

Index
B. TECH. SECOND YEAR (CSE(IoT)) 3rd Sem

Course Code BCSIOT0353 LTP Credit

Course Title IoT LAB USING ARDUINO and Node MCU 0 0 4 2

Lab Experiments

Course Objective: To familiarize the students with the basics of the Internet of Things,
sensors, development boards, actuators, hardware, and protocols.
Course Outcomes (CO)

Course outcome: After completion of this course students will be able to: Bloom’s
Knowledge
Level(KL)
Describe the functionality of computing, sensing, and actuating
CO 1 K1
components of the Internet of Things.
CO2 Develop IoT applications using Arduino IDE. K6
Design, develop, and deploy real-time mini projects of IoT
CO3 K6
Applications.

List of Practical’s
Sr No Program Title CO Date Sign
Installation of Arduino IDE and introduction to tools, assembly, and CO 1
1
libraries.
Getting Programming board Info and configuring boot loader settings CO 1
2
using Arduino IDE.
Study and design IoT reference architecture for IoT-based applications CO 1
3
like Smart home

Student Name: Roll No Department of CSE(IoT), SoCSET, NIET


[BCSIOT0353]IoT LAB USING ARDUINO and Node MCU 2024

Study Hardware Architecture and Pin Out of Arduino UNO Board. CO 1


4 Compare Arduino Uno Arduino Nano and Arduino Mega. Identification
of their use case according to a given scenario.
Study Hardware Architecture and Pin Out of Node MCU and ESP8266. CO 1
5
Identification of their use case according to the given snapshot.
a. Study Pin out Architecture of Sensors and actuators CO 1
b. DHT 11 Sensor
c. MQ 135 Sensor
d. MQ 7 Sensor
e. MQ 3 Sensor
f. Ultrasonic Sensor HC-04
g. Rain Sensor
6 h. Soil moisture Sensor
i. PIR Sensor
j. LDR Sensor
k. Line Sensor
l. Colour Sensor
m. Servo Motor
n. Relay

a. Working with structures using Arduino IDE CO 2


b. Working with Variables using Arduino IDE
c. Working with Flow control using Arduino IDE
d. Working with Digital i/o using Arduino IDE
e. Working with Analog i/o using Arduino IDE
f. Working with the Time function using Arduino IDE
7 g. Working with Math functions using Arduino IDE
h. Working with Random functions using Arduino IDE
i. Working with Serial communication using Arduino IDE
j. Working with loops and control statements using Arduino IDE
k. Working with PinMode function using Arduino IDE
l. Working with analog Read, analog Write, digital Read, digital
Write using Arduino IDE
m. Blinking LED Program using Arduino Uno
a. Write a program using Arduino Uno to generate a random number CO 2
between 0 to 25. Use 4 LEDs (Red, Green, Blue, and Yellow) and design
8 LED patterns as
(i) if the random number is less than 5 then only the Red LED
should glow.

Student Name: Roll No Department of CSE(IoT), SoCSET, NIET


[BCSIOT0353]IoT LAB USING ARDUINO and Node MCU 2024

(ii) if the random number is between 5-10 then only Blue LED
should glow.
(iii)if the random number is between 11-20 then only Yellow LED
should glow.
(iv) if the random number is greater than 20 then only Green LED
should glow.
b. Write a program using Arduino uno for addition of digits of a user-
defined number. Example: number is 257 then output should be 14.
c. Write a program to take LED color as input from the user and glow
that LED using Arduino Uno.

a. Interfacing of DHT 11 Sensor with Arduino Uno. Implement an LED CO 2


mechanism for notifying rise in temperature.
b. Interfacing of MQ 135/MQ7 Sensor with Arduino Uno. Implement
alarm mechanism for notifying rise in amount of hazardious gases in
9 air.
c. Interfacing of MQ 3 Sensor with Arduino Uno. Implement alarm
mechanism for checking amount of alcohol in the air.
d. Interfacing of Ultrasonic Sensor HC-04 with Arduino Uno.

a. Interfacing of Rain Sensor with Arduino Uno. Implement a buzzer CO 2


mechanism as the sensor identify rain.
b. Interfacing of Soil Moisture Sensor with Arduino Uno.
10
c. Interfacing of PIR Sensor with Arduino Uno.
d. Interfacing of LDR Sensor with Arduino Uno.
e. Interfacing of LCD with Arduino Uno
f. Interfacing of I2C LCD with Arduino Uno
a. Interfacing Bluetooth Module with Arduino Uno CO 2
b. Connecting Node MCU with Wi-Fi hotspots using Arduino IDE

11 c. Interfacing of DHT 11 Sensor with Node MCU


d. Interfacing of MQ 135 Sensor with Node MCU
e. Interfacing of MQ 7 Sensor with Node MCU
f. Interfacing of MQ 3 Sensor with Node MCU
12 a. Interfacing of Ultrasonic Sensor HC-04 with Node MCU CO 2

Student Name: Roll No Department of CSE(IoT), SoCSET, NIET


[BCSIOT0353]IoT LAB USING ARDUINO and Node MCU 2024

b. Interfacing of Rain Sensor with Node MCU


c. Interfacing of Soil moisture Sensor with NodeMCU
d. Interfacing of PIR Sensor with Node MCU
e. Interfacing of LDR Sensor with Node MCU
a. Sending Data to Thingspeak Cloud Server using Node MCU CO 2
13 b. Detection of LPG Gas using MQ6 and Node MCU. Notify
Thingspeak server that "LPG gas Leakage has been detected

14 Controlling LED with Node MCU using Blynk cloud App. CO 2

Development of Mini Project CO 3


15 Sample Projects:
Introduction to IoT Projects.xlsx

Student Name: Roll No Department of CSE(IoT), SoCSET, NIET


[BCSIOT0353]IoT LAB USING ARDUINO and Node MCU 2024

Experiment- 1

Aim: Installation of Arduino IDE and introduction to tools, assembly, and


libraries.

Arduino IDE: Arduino IDE is an open-source software that is used to write and upload code
to Arduino boards. The IDE application suits different operating systems, such as Windows,
Mac OS X, and Linux. It supports the programming languages C and C++. Here, IDE stands
for Integrated Development Environment. The program or code written in the Arduino IDE is
often called as sketching. We need to connect the Genuino and Arduino board with the IDE
to upload the sketch written using the Arduino IDE software. The sketch is saved with the
extension '.ino.'

The steps to download the Arduino software are listed below:

1. Go to the official website of Arduino (https://www.arduino.cc/) > Click on SOFTWARE <


click on DOWNLOADS Or Open the URL https://www.arduino.cc/en/Main/Software

2. When the download finishes, proceed with the installation, and please allow the driver
installation process when you get a warning from the operating system.

3. Choose the components to install.

Figure1.1 Installation options

4. Choose the installation directory.

Student Name: Roll No Department of CSE(IoT), SoCSET, NIET


[BCSIOT0353]IoT LAB USING ARDUINO and Node MCU 2024

Figure 1.2 Installation directory

5. Installation in progress

Figure 1.3 Installation in progress

The process will extract and install all the required files to execute properly the Arduino
Software (IDE).

Tools for Arduino Development

a) Arduino IDE

The Arduino Integrated Development Environment (IDE) is the official software used to
program the Arduino board. It supports writing, compiling, and uploading code (known as
sketches) to the board. Some key features include:

Student Name: Roll No Department of CSE(IoT), SoCSET, NIET


[BCSIOT0353]IoT LAB USING ARDUINO and Node MCU 2024

• Code editor with syntax highlighting.


• Built-in libraries for quick prototyping.
• Serial Monitor to display output from the board.

Alternative IDEs like PlatformIO, Arduino Web Editor, and Visual Studio Code with the
Arduino extension are also popular for more advanced projects.

b) Arduino Boards

There are several types of Arduino boards, each suited for different applications:

• Arduino Uno: The most popular model, great for beginners.


• Arduino Mega: Ideal for projects requiring more I/O pins.
• Arduino Nano: A compact version with similar functionality to the Uno.
• Arduino Leonardo: Capable of emulating a USB keyboard or mouse.

Each board has different features, but they all can be programmed using the Arduino IDE.

c) Programmer & Serial Tools

• USB Cable: Used to connect the Arduino board to the computer for programming.
• Serial Monitor/Plotter: A tool in the Arduino IDE for debugging and displaying
messages from the Arduino.

d) Peripheral Tools

To extend the functionality of Arduino, you often use additional hardware such as:

• Sensors: For detecting physical properties (temperature, motion, light, etc.).


• Actuators: Like motors or LEDs, used to perform actions.
• Breadboards: Useful for prototyping circuits without soldering.
• Wires, Resistors, and Capacitors: Basic electronic components to build circuits.

Assembly: Building an Arduino Circuit

To assemble an Arduino project, you'll follow these general steps:

a) Connecting Components

• Powering the Arduino: The board can be powered via USB or an external power
source (typically 7-12V).
• GPIO Pins: Use the digital and analog pins to connect components like sensors,
LEDs, and motors.
o Digital pins (D0-D13) can be used for reading or sending digital signals
(on/off).
o Analog pins (A0-A5) read varying voltages, typically from sensors.

Student Name: Roll No Department of CSE(IoT), SoCSET, NIET


[BCSIOT0353]IoT LAB USING ARDUINO and Node MCU 2024

b) Using a Breadboard

A breadboard allows easy, temporary connections. Components like resistors, LEDs, and
wires are placed into the holes on the breadboard and connected to the Arduino via jumper
wires. It’s used for prototyping and testing circuits without soldering.

c) Wiring Examples

• Blinking LED: A basic circuit where you connect an LED to one of the digital pins of
the Arduino and write a program to turn it on and off.
• Temperature Sensor: Connect a temperature sensor (like an LM35) to one of the
analog pins to read temperature data.

d) Power Considerations

Ensure you match the voltage and current ratings of components. For example, an LED
requires a current-limiting resistor to prevent it from burning out.

Arduino Libraries

Libraries in Arduino are pre-written code that make it easy to interface with components or
perform complex tasks. Rather than writing code from scratch, libraries help speed up
development.

a) Popular Arduino Libraries

• Servo Library: For controlling servo motors.


• Wire Library: For I2C communication (often used for sensors).
• LiquidCrystal Library: For interfacing with LCD displays.
• SPI Library: For communicating with SPI devices.
• Adafruit and SparkFun Libraries: Libraries provided by these companies offer
support for many third-party modules and sensors.

b) Installing Libraries

Libraries can be installed via the Arduino IDE by following these steps:

• Open the Arduino IDE, go to Sketch > Include Library > Manage Libraries.
• In the Library Manager, search for a library and click Install.

c) Custom Libraries

You can also write your own libraries if you have a complex set of tasks that you reuse
across projects.

Student Name: Roll No Department of CSE(IoT), SoCSET, NIET


[BCSIOT0353]IoT LAB USING ARDUINO and Node MCU 2024

Experiment- 2

Aim: Getting Programming board Info and configuring boot loader settings
using Arduino IDE.

Getting Board Info in Arduino IDE

1. Connect the Arduino Board:

o Plug your Arduino board into your computer using a USB cable.

2. Select the Board and Port:

o Open the Arduino IDE.

o Go to Tools > Board, and select your Arduino board model (e.g., Arduino
Uno, Nano, etc.).

o Go to Tools > Port, and select the correct COM port where your Arduino is
connected.

3. Get Board Info:

o Go to Tools > Get Board Info.

o The IDE will display details like:

§ Board Name

§ VID (Vendor ID)

§ PID (Product ID)

§ Serial Number (if supported by the board)

Configuring Bootloader Settings

1. Select the Correct Board and Processor:

o Go to Tools > Board, and select the correct board.

o If the board has different processor options (e.g., ATmega328P or


ATmega328P (Old Bootloader) for Arduino Nano), select the correct one
under Tools > Processor.

Student Name: Roll No Department of CSE(IoT), SoCSET, NIET


[BCSIOT0353]IoT LAB USING ARDUINO and Node MCU 2024

2. Burn Bootloader (if necessary):

o If your board requires a bootloader update or reinstallation:

1. Connect an ISP Programmer (e.g., USBasp, Arduino as ISP) to your


board. Alternatively, another Arduino board can act as an ISP.

2. In the Arduino IDE:

§ Go to Tools > Programmer, and select the appropriate


programmer (e.g., Arduino as ISP, USBasp, etc.).

§ Connect the programmer to the target board correctly (refer


to your programmer and board documentation).

§ Go to Tools > Burn Bootloader.

3. Wait for the process to complete. Once done, your board's


bootloader will be configured.

Configuring Advanced Bootloader Options

To customize bootloader settings (e.g., baud rate, clock speed):

1. Edit the boards.txt file in the Arduino IDE directory:

o Navigate to hardware/arduino/avr/boards.txt.

o Locate your board configuration and modify the parameters (e.g.,


upload.speed, bootloader.file, etc.).

2. Save the changes and restart the Arduino IDE.

Verify Bootloader Configuration

• Upload a basic sketch (e.g., Blink) to test if the bootloader is functioning correctly.

• If the upload is successful, your board's bootloader is properly configured.

Student Name: Roll No Department of CSE(IoT), SoCSET, NIET


[BCSIOT0353]IoT LAB USING ARDUINO and Node MCU 2024

Experiment- 3

Aim: Study and design IoT reference architecture for IoT-based applications
like Smart Home.

Internet of Things (IoT) technology has a wide range of applications, and its use is growing
faster. The Internet of Things (IoT) is the networking of physical objects with electronics
embedded within their architecture to communicate and sense interactions amongst each
other or with the external environment. In this article, we will discuss the architecture of
the Internet of Things.
Architecture of IoT
The architecture of IoT is divided into four different layers i.e. Sensing Layer, Network
Layer, Data processing Layer, and Application Layer.

Figure 3.1 IoT Architecture

A smart home allows homeowners to control appliances, thermostats, lights, and other
devices remotely through an internet connection using a smart phone or tablet. Smart
homes can be set up with wireless or hardwired systems. Smart home technology provides
homeowners with convenience and cost savings.

Student Name: Roll No Department of CSE(IoT), SoCSET, NIET


[BCSIOT0353]IoT LAB USING ARDUINO and Node MCU 2024

There are several basic functions for a smart home:


• Smart homes can increase comfort, safety, convenience, and interactivity of family
life, as well as optimize people’s lifestyles.
• The smart home can support remote payment.
• A smart home can monitor and interact with the home via mobile phone and remote
network, and timely processing.
• “Smart Home” realizes in real-time the meter readings and the security service of
the humidity, temperature, water, electricity, and gas sensors, which provide more
convenient conditions for high-quality service.
• Support perfect intelligent service.
Figure 3.2 shows the smart-home and IoT based, main components, and their inter-
connectivity. Here in the smart home environment, we can see the typical devices
connected to a local area network (LAN). Now days, it might be ZigBee, BLE, Wi-Fi or other
proprietary RF communication. This enables communication among the sensors, actuators,
and outside of it. Connected to the LAN are a server and its database. The server controls
the devices, logs its activities, provides reports, answers queries, and executes the
appropriate commands.
For more comprehensive or common tasks, the smart home server transfers data to the
cloud, and remotely activate tasks init using APIs, application programming interface
processes. Besides, IoT home appliances are connected to the internet and the LAN, and so
expands smart home to include IoT. The connection to the internet allows the end-user
application to communicate with smart home enabling resident to get information and
remotely activate tasks.

Figure 3.2 Building an IoT-based architecture model for smart homes

Student Name: Roll No Department of CSE(IoT), SoCSET, NIET


[BCSIOT0353]IoT LAB USING ARDUINO and Node MCU 2024

A smart home system is controlled automatically. To accomplish this, the smart home
system which we designed adopts wireless communication to build a local home network in
order to sense the objects or devices at home, and it uses 4G or Ethernet to connect the
local home network to the Internet for communication in order to support remote control
and management.

Figure 3.3: Architecture of the IoT-based smart home system

In this architecture model figure 3.3, the sensors and the actuating layer is mainly
responsible for data collection or commands receiving. Network layer of the system
including environment sensors like temperature, humidity, gas, or body sensors, and so on.
And then, the data are processed respectively by the terminals and transmitted to the
gateway which locates in the middle of the sensing layer and network layer through a self-
organizing network (wireless communication). The gateway receives and deals with the data
from all the sensors, and transmits them through the Internet to the remote management
platform. On the other hand, the management platform can support different applications
such as healthcare, security, video monitoring, and entertainment. Users can log in to the
platform to execute each application and management platform sends different commands
or data to the gateway through the Internet. The gateway analyzes the received data and
starts different actuators mechanisms.

Student Name: Roll No Department of CSE(IoT), SoCSET, NIET


[BCSIOT0353]IoT LAB USING ARDUINO and Node MCU 2024

Experiment- 4

Aim: Study Hardware Architecture and Pin Out of Arduino UNO Board.
Compare Arduino Uno Arduino Nano and Arduino Mega. Identification of
their use case according to a given scenario.

Arduino UNO

The Arduino UNO is a standard board of Arduino. Here UNO means 'one' in Italian. It was
named as UNO to label the first release of Arduino Software. It was also the first USB board
released by Arduino. It is considered as the powerful board used in various projects.
Arduino.cc developed the Arduino UNO board.

Arduino UNO is based on an ATmega328P microcontroller. It is easy to use compared to


other boards, such as the Arduino Mega board, etc. The board consists of digital and analog
Input/Output pins (I/O), shields, and other circuits.

The Arduino UNO includes 6 analog pin inputs, 14 digital pins, a USB connector, a power
jack, and an ICSP (In-Circuit Serial Programming) header. It is programmed based on IDE,
which stands for Integrated Development Environment. It can run on both online and offline
platforms.

Figure 4.1 Components of Arduino UNO board

Student Name: Roll No Department of CSE(IoT), SoCSET, NIET


[BCSIOT0353]IoT LAB USING ARDUINO and Node MCU 2024

Let's discuss each component in detail.

o ATmega328 Microcontroller- It is a single chip Microcontroller of the ATmel family.


The processor code inside it is of 8-bit. It combines Memory (SRAM, EEPROM, and
Flash), Analog to Digital Converter, SPI serial ports, I/O lines, registers, timer,
external and internal interrupts, and oscillator.
o ICSP pin - The In-Circuit Serial Programming pin allows the user to program using the
firmware of the Arduino board.
o Power LED Indicator- The ON status of LED shows the power is activated. When the
power is OFF, the LED will not light up.
o Digital I/O pins- The digital pins have the value HIGH or LOW. The pins numbered
from D0 to D13 are digital pins.
o TX and RX LED's- The successful flow of data is represented by the lighting of these
LED's.
o AREF- The Analog Reference (AREF) pin is used to feed a reference voltage to the
Arduino UNO board from the external power supply.
o Reset button- It is used to add a Reset button to the connection.
o USB- It allows the board to connect to the computer. It is essential for the
programming of the Arduino UNO board.
o Crystal Oscillator- The Crystal oscillator has a frequency of 16MHz, which makes the
Arduino UNO a powerful board.
o Voltage Regulator- The voltage regulator converts the input voltage to 5V.
o GND- Ground pins. The ground pin acts as a pin with zero voltage.
o Vin- It is the input voltage.
o Analog Pins- The pins numbered from A0 to A5 are analog pins. The function of
Analog pins is to read the analog sensor used in the connection. It can also act as
GPIO (General Purpose Input Output) pins.

Comparison of Arduino Uno, Arduino Nano, and Arduino Mega

Feature Arduino Uno Arduino Nano Arduino Mega

Microcontroller ATmega328P ATmega328P ATmega2560


Operating Voltage 5V 5V 5V
Input Voltage 7-12V 7-12V 7-12V
Clock Speed 16 MHz 16 MHz 16 MHz
Flash Memory 32 KB (0.5 KB used 32 KB (0.5 KB 256 KB (8 KB used
by bootloader) used by by bootloader)
bootloader)
SRAM 2 KB 2 KB 8 KB

Student Name: Roll No Department of CSE(IoT), SoCSET, NIET


[BCSIOT0353]IoT LAB USING ARDUINO and Node MCU 2024

EEPROM 1 KB 1 KB 4 KB

Digital I/O Pins 14 (6 PWM) 14 (6 PWM) 54 (15 PWM)


Analog Input Pins 6 8 16
PWM Pins 6 6 15
UART (Hardware Serial) 1 1 4
I2C/TWI Yes Yes Yes
SPI Yes Yes Yes
USB Connection USB Type-B Mini USB USB Type-B
Size 68.6mm x 53.4mm 45mm x 18mm 101.52mm x
53.3mm
Price (Approx.) Moderate (~$20) Lower (~$15) Higher (~$35)

1. Arduino Uno
§ Scenario: Ideal for beginners and small to medium-scale projects, such as a simple
sensor monitoring system.
§ Use Case: Suitable for building basic IoT projects, such as temperature monitoring or
LED control, where limited I/O and moderate memory are sufficient.

2. Arduino Nano
• Scenario: Useful for compact projects requiring a smaller board, such as wearables
or embedded systems with limited space.

• Use Case: Excellent for small devices like a mini weather station or a portable
battery-operated sensor due to its size and similar features to the UNO.

3. Arduino Mega
• Scenario: Suitable for complex projects requiring more I/O pins and memory, such as
automation systems and robotics.
• Use Case: Ideal for advanced applications like a home automation hub or robotics
projects where multiple sensors and actuators are controlled simultaneously.

Student Name: Roll No Department of CSE(IoT), SoCSET, NIET


[BCSIOT0353]IoT LAB USING ARDUINO and Node MCU 2024

Experiment- 5

Aim: Study Hardware Architecture and Pin Out of Node MCU and ESP8266.
Identification of their use case according to the given snapshot.

NodeMCU is an open-source Lua based firmware and development board specially targeted
for IoT based Applications. It includes firmware that runs on the ESP8266 Wi-Fi SoC from
Espressif Systems, and hardware which is based on the ESP-12 module.

NodeMCU Development Board Pinout Configuration

Pin Name Description


Category

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

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

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


Pin

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

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

UART TXD0, RXD0, TXD2, NodeMCU has two UART interfaces, UART0 (RXD0 &

Student Name: Roll No Department of CSE(IoT), SoCSET, NIET


[BCSIOT0353]IoT LAB USING ARDUINO and Node MCU 2024

Pins RXD2 TXD0) and UART1 (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.

Figure 5.1 Pin Out of Node MCU ESP8266

NodeMCU ESP8266 Specifications & Features

• Microcontroller: Tensilica 32-bit RISC CPU Xtensa LX106


• Operating Voltage: 3.3V
• Input Voltage: 7-12V
• Digital I/O Pins (DIO): 16
• Analog Input Pins (ADC): 1
• UARTs: 1
• SPIs: 1
• I2Cs: 1
• Flash Memory: 4 MB
• SRAM: 64 KB
• Clock Speed: 80 MHz

Student Name: Roll No Department of CSE(IoT), SoCSET, NIET


[BCSIOT0353]IoT LAB USING ARDUINO and Node MCU 2024

• USB-TTL based on CP2102 is included onboard, Enabling Plug n Play


• PCB Antenna
• Small Sized module to fit smartly inside your IoT projects

NodeMCU and ESP8266 are widely used in IoT projects because they combine affordability,
flexibility, and Wi-Fi capability. Here are some common use cases:

1. Home Automation

• Description: Automate and remotely control home appliances (lights, fans, etc.) via
mobile apps or web interfaces.
• How it works: NodeMCU and ESP8266 can connect to Wi-Fi, making it easy to
control devices through the internet. They receive commands from apps (e.g., Blynk,
Home Assistant) or voice assistants (via IFTTT).

2. Weather Monitoring Station

• Description: Collect and transmit environmental data such as temperature,


humidity, and air quality.
• How it works: The ESP8266 can gather data from sensors (like DHT11 for
temperature and humidity) and send it to cloud services for real-time monitoring
and historical data analysis.

3. Smart Irrigation System

• Description: Automate watering for plants based on soil moisture levels.


• How it works: Using soil moisture sensors and a water pump relay, the ESP8266 can
trigger watering when soil dries up. This data can be monitored or controlled
remotely.

4. Wi-Fi Security Camera

• Description: Low-cost surveillance for home or office environments.


• How it works: Paired with a camera module (like OV7670), NodeMCU can capture
and send images to a server or notify the user if motion is detected.

5. Energy Monitoring System

• Description: Track electricity usage in real time.


• How it works: With current sensors, the ESP8266 can measure power consumption
of individual appliances and log it to a cloud service or app for analysis.

6. Smart Door Lock

• Description: Control a door lock remotely or unlock it via a password.

Student Name: Roll No Department of CSE(IoT), SoCSET, NIET


[BCSIOT0353]IoT LAB USING ARDUINO and Node MCU 2024

• How it works: Connect the ESP8266 to a solenoid door lock, and control it over Wi-
Fi. The device can also use an RFID or fingerprint module for authentication.

7. Air Quality Monitoring

• Description: Track levels of pollutants (CO2, PM2.5) for health and safety.
• How it works: ESP8266 collects data from air quality sensors (e.g., MQ135,
PMS5003) and uploads it to a cloud platform for alerts or monitoring.

8. Wearable Health Monitor

• Description: Portable device to monitor vitals like heart rate or temperature.


• How it works: ESP8266 can receive data from health sensors and send it to a mobile
app or cloud platform to track and analyze health metrics.

9. GPS Tracking System

• Description: Track the location of an object or vehicle.


• How it works: By integrating the ESP8266 with a GPS module, the device can send
location data to a server or app for tracking.

10. Voice-Controlled Assistant

• Description: Control devices via voice commands.


• How it works: ESP8266 can receive commands from an Alexa or Google Assistant via
IFTTT and control various connected devices in the home or office.

These use cases demonstrate the versatility of NodeMCU and ESP8266, especially for
projects needing low-power, internet-connected devices for monitoring, automation, and
control.

Student Name: Roll No Department of CSE(IoT), SoCSET, NIET


[BCSIOT0353]IoT LAB USING ARDUINO and Node MCU 2024

Experiment- 6

Aim: Study Pin out the Architecture of Sensors and actuators


a. DHT 11 Sensor
b. MQ 135 Sensor
c. MQ 7 Sensor
d. MQ 3 Sensor
e. Ultrasonic Sensor HC-04
f. Rain Sensor
g. Soil moisture Sensor
h. PIR Sensor
i. LDR Sensor
j. Line Sensor
k. Colour Sensor
l. Servo Motor
m. Relay

a. DHT 11

Figure 6.1 DHT 11

The DHT11 sensor has four pins. Here's the pinout:

Pin Name Description

1 VCC Power supply (3.3V to 5.5V).

2 Data Digital output for temperature and humidity data.

3 NC (Not Connected) No connection; leave unconnected.

4 GND Ground.

Student Name: Roll No Department of CSE(IoT), SoCSET, NIET


[BCSIOT0353]IoT LAB USING ARDUINO and Node MCU 2024

DHT11 Sensor Specifications and Resolution

Parameter Specification

Humidity Range 20% to 90% RH

Humidity Resolution 1% RH

Humidity Accuracy ±5% RH

Temperature Range 0°C to 50°C

Temperature Resolution 1°C

Temperature Accuracy ±2°C

Power Supply Voltage 3.3V to 5.5V

Output Signal Digital

Sampling Period 1 second or slower

b. Pinout of MQ-135 Gas Sensor

Figure 6.2 Pinout of MQ135

The MQ-135 gas sensor has four pins (or six, depending on the module version). Here's the
pinout for the typical 4-pin version:

Pin Name Description

1 VCC Power supply (typically 5V).

Student Name: Roll No Department of CSE(IoT), SoCSET, NIET


[BCSIOT0353]IoT LAB USING ARDUINO and Node MCU 2024

2 GND Ground.

3 AO Analog output (variable voltage corresponding to gas levels).

4 DO Digital output (high or low based on the threshold set via potentiometer).

Specifications and Resolution of MQ-135 Sensor


The MQ-135 sensor measures air quality and detect a wide range of gases, such as
ammonia, sulfur, benzene, and carbon dioxide. Here's its resolution information:

Parameter Specification

Detectable Gases Ammonia (NH3), Benzene (C6H6), Alcohol, Smoke, CO2

Concentration Range 10ppm – 1000ppm

Analog Output Voltage Range 0V – 5V

Digital Output Logic Levels 0 (Low) and 1 (High)

Preheat Time 20 seconds

Heater Voltage 5.0V ± 0.1V

Load Resistance (RL) 10kΩ – 47kΩ (typical RL = 20kΩ)

Sensitivity Adjustable via onboard potentiometer

c. Pinout of MQ 7 Sensor

Figure 6.3 Pinout of MQ7

Student Name: Roll No Department of CSE(IoT), SoCSET, NIET


[BCSIOT0353]IoT LAB USING ARDUINO and Node MCU 2024

The MQ-7 gas sensor typically has four pins or six terminals (depending on the module
version). Here's the pinout for the standard 4-pin version:

Pin Name Description

1 VCC Power supply (typically 5V).

2 GND Ground.

3 AO Analog output (voltage proportional to CO concentration).

4 DO Digital output (high or low based on the threshold set via potentiometer).

For sensors with six terminals:

• Two terminals are for the heater (H1 and H2), and the other four are for the sensor
signal (A and B pairs). In modules, these are integrated into the circuit.

Specifications and Resolution of MQ-7 Sensor

The MQ-7 is designed to detect Carbon Monoxide (CO) and has the following resolution
specifications:

Parameter Specification

Detectable Gas Carbon Monoxide (CO)

Concentration Range 20ppm – 2000ppm

Analog Output Voltage Range 0V – 5V

Digital Output Logic Levels 0 (Low) and 1 (High)

Sensitivity Adjustable via onboard potentiometer

Preheat Time 60 seconds

Heater Voltage (Cycle) 1.5V for 90 seconds (low); 5.0V for 60 seconds (high)

Load Resistance (RL) 10kΩ – 47kΩ (typical RL = 20kΩ)

Student Name: Roll No Department of CSE(IoT), SoCSET, NIET


[BCSIOT0353]IoT LAB USING ARDUINO and Node MCU 2024

d. Pinout of MQ3 Sensor

Figure 6.4 Pinout of MQ3

The MQ-3 sensor is used for detecting alcohol levels in the air. It typically has six pins, but in
many modules, only four pins are used. Here's the pinout for a typical module:

Pin Name Description

1 AOUT Analog output: Voltage proportional to alcohol concentration.

2 DOUT Digital output: Binary signal based on threshold set via potentiometer.

3 GND Ground.

4 VCC Power supply (5V).

If the standalone MQ-3 sensor (without a module) is used, the heater and signal pins are
labeled as H1, H2, A1, A2, B1, B2. The configuration may vary, and you should refer to the
datasheet.

Specifications and Resolution of MQ-3 Sensor

Parameter Specification

Detectable Gases Alcohol (ethanol), Benzene, Methane

Concentration Range 0.05 mg/L – 10 mg/L

Student Name: Roll No Department of CSE(IoT), SoCSET, NIET


[BCSIOT0353]IoT LAB USING ARDUINO and Node MCU 2024

Analog Output Voltage Range 0V – 5V

Digital Output Logic Levels 0 (Low) and 1 (High)

Preheat Time ≥20 seconds

Heater Voltage 5.0V ± 0.1V

Load Resistance (RL) 10kΩ – 47kΩ (typical RL = 20kΩ)

Sensitivity Adjustable via onboard potentiometer

Sensor Resistance Range (Rs) 2kΩ – 20kΩ in clean air

e. Pinout of Ultrasonic Sensor

Figure 6.5 Pinout of HC-SR04 ultrasonic sensor


The HC-SR04 ultrasonic sensor has four pins:

Pin Name Description

1 VCC Power supply (5V).

2 Trig Trigger pin: Sends an ultrasonic pulse (10 µs


HIGH).

3 Echo Echo pin: Outputs the pulse duration received.

4 GND Ground.

Student Name: Roll No Department of CSE(IoT), SoCSET, NIET


[BCSIOT0353]IoT LAB USING ARDUINO and Node MCU 2024

Specifications and Resolution of Ultrasonic Sensor

Parameter Specification

Operating Voltage 5V DC

Operating Current 15 mA

Ultrasonic Frequency 40 kHz

Measuring Distance 2 cm to 400 cm

Distance Resolution 0.3 cm

Accuracy ±3 mm

Measuring Angle <15° cone

Trigger Pulse Width 10 µs (minimum)

Output Pulse Width Proportional to distance (58 µs per cm)

f. Pinout of Rain Sensor

Figure 6.6 Pinout of the Rain sensor


A typical rain sensor module consists of a sensing plate and a control board with 3 or 4 pins.
Here’s the pinout for a standard 3-pin or 4-pin version:

Pin Name Description

1 VCC Power supply (3.3V to 5V).

Student Name: Roll No Department of CSE(IoT), SoCSET, NIET


[BCSIOT0353]IoT LAB USING ARDUINO and Node MCU 2024

2 GND Ground.

3 AO Analog output: Proportional to the water level detected on the plate.

4 DO Digital output: High/Low signal depending on the threshold set by the


potentiometer.

Note: On some modules, the pins may be labeled differently (e.g., "S" for Signal instead of
AO or DO).

Rain Sensor Specifications and Resolution

The rain sensor is a simple module used to detect water droplets or the presence of rain. Its
output characteristics and resolution depend on the control board settings.

Parameter Specification

Operating Voltage 3.3V – 5V

Analog Output Voltage Range 0V – 5V (varies with water levels).

Digital Output Logic Levels 0 (Low) and 1 (High).

Detection Area ~5cm x 4cm (sensing plate size).

Digital Output Sensitivity Adjustable using onboard potentiometer.

Sampling Period Instantaneous response upon contact.

Resolution (Analog Output) Proportional voltage from 0V – 5V.

g. Pinout of soil moisture sensor

Figure 6.7 Pinout of the Rain sensor

Student Name: Roll No Department of CSE(IoT), SoCSET, NIET


[BCSIOT0353]IoT LAB USING ARDUINO and Node MCU 2024

A typical soil moisture sensor module has two parts:

1. Probe: Detects moisture levels in the soil.


2. Signal Processing Module: Converts the probe readings into digital and analog
signals.
The module usually has four pins:
Pin Name Description

1 VCC Power supply (typically 3.3V or


5V).

2 GND Ground.

3 AO Analog output (variable voltage


based on soil moisture level).

4 DO Digital output (HIGH/LOW based


on the set threshold).

Soil Moisture Sensor Specifications and Resolution

Parameter Specification

Operating Voltage 3.3V – 5V

Analog Output Voltage 0V – 5V


Range
Digital Output Logic 0 (Low) and 1 (High)
Levels
Measurement Range 0% (dry) – 100% (wet)

Resolution 10-bit (if using an analog pin on


Arduino)

Threshold Adjustment Adjustable via onboard


potentiometer

Sampling Frequency As required (typically once every


few seconds)

Response Time < 500 ms

Student Name: Roll No Department of CSE(IoT), SoCSET, NIET


[BCSIOT0353]IoT LAB USING ARDUINO and Node MCU 2024

h. Pinout of PIR Sensor

Figure 6.8 Pinout of the PIR sensor


A Passive Infrared (PIR) sensor typically has three pins:

Pin Pin Name Description


Number

1 VCC Power Supply (Typically 3.3V or 5V)

2 OUT Digital Output Signal (High/Low)

3 GND Ground

Some PIR sensors may have additional pins or potentiometers for adjusting sensitivity and
delay.

PIR Sensor Resolution

PIR sensors don't have a traditional "resolution" like cameras or other imaging sensors.
Instead, their sensitivity and detection range are defined by the size, type, and arrangement
of their Fresnel lens and the specifications of the pyroelectric elements inside. Below is a
general description of parameters that may influence the "resolution" of a PIR sensor:

Parameter Typical Value/Range

Detection Range 5m to 10m (adjustable)

Field of View (FoV) 90° to 120°

Response Time 0.3s to 2s

Sensitivity Adjustment Via onboard potentiometer

Motion Detection Resolution Detects general body heat movement, not detailed shapes

Student Name: Roll No Department of CSE(IoT), SoCSET, NIET


[BCSIOT0353]IoT LAB USING ARDUINO and Node MCU 2024

i. Pinout of LDR Sensor

Figure 6.9 Pinout of the LDR sensor


An LDR (Light Dependent Resistor) is not a sensor in the sense of having dedicated pins for
power, ground, or output like an IC-based sensor. Instead, it is a light-sensitive passive
component with two terminals (no polarity).

Here's how it functions in a circuit:

• Pinout:
o Terminal 1: Connect to a voltage source (Vcc) through a pull-up resistor or
directly to an analog input pin if using a microcontroller.
o Terminal 2: Connect to ground (GND).
LDR Resolution and Behavior
LDR does not inherently provide a "resolution" as it outputs an analog resistance value that
changes with light intensity. However, when interfaced with an analog-to-digital converter
(ADC) on a microcontroller, its "resolution" is determined by the ADC's bit depth.

ADC Resolution Voltage Steps Notes

8-bit (256 steps) Vref/256V_{\text{ref}} / 256Vref/256 Can resolve low light


variations coarsely.

10-bit (1024 steps) Vref/1024V_{\text{ref}} / 1024Vref/1024 Better precision for light


intensity.

12-bit (4096 steps) Vref/4096V_{\text{ref}} / 4096Vref/4096 High precision for light


sensing.

• VrefV_{\text{ref}}Vref: Reference voltage for the ADC.


• The LDR’s resistance varies non-linearly with light intensity, typically measured in lux.
Example Circuit For interfacing the LDR with an ADC:

1. Connect one terminal of the LDR to Vcc.


2. Connect the other terminal to a resistor, forming a voltage divider.
3. Connect the junction of the LDR and resistor to an analog input pin of the
microcontroller.
4. Connect the other end of the resistor to GND.

Student Name: Roll No Department of CSE(IoT), SoCSET, NIET


[BCSIOT0353]IoT LAB USING ARDUINO and Node MCU 2024

j. Pinout of Line Sensor

Figure 6.10 Pinout of the 5 Channel Line sensor


Line sensors are commonly used in robotics for line-following applications. A popular
example of a line sensor is the QTR (Pololu) reflectance sensor array, which typically
contains multiple phototransistors or photodiodes and corresponding IR LEDs. Below is the
general pinout and sensor resolution information for such a sensor:

Pinout of Line Sensor

Pin Description

VCC Power supply (commonly 5V or 3.3V).

GND Ground connection.

OUT (Analog) Analog output for the respective sensor element.

OUT (Digital)* Digital output if configured for digital output.

Enable/CTRL Some arrays have an enable/disable pin for IR LEDs.

*Note: Some line sensors have configurable analog/digital outputs for each channel. Check
the specific datasheet for details.

Sensor Resolution

Number of Resolution (Total width in mm) Typical Usage


Sensors

1 Single point (specific alignment) Simple line detection.

3 Low-resolution array (~15-30mm) Basic line-following.

Student Name: Roll No Department of CSE(IoT), SoCSET, NIET


[BCSIOT0353]IoT LAB USING ARDUINO and Node MCU 2024

5 Medium resolution (~40-60mm) Line-following with curves.

8 High resolution (~80-100mm) Precise line tracking.

16 Very high resolution (~160mm) Advanced robotic navigation.

h. Pinout of Color Sensor

Figure 6.11 Pinout of the Color sensor


Pinout of TCS34725:

Pin Name Description

1 VIN Power supply input (3.3V or 5V).

2 GND Ground.

3 SDA Serial Data Line for I2C communication.

4 SCL Serial Clock Line for I2C communication.

5 INT Interrupt pin (used for notifying specific conditions).

Resolution of TCS34725:

The TCS34725 measures Red, Green, Blue, and Clear (ambient light) intensities. Its
resolution is given by the ADC (Analog-to-Digital Converter) bit depth and integration time
settings:

Integration Time Resolution Sensitivity

2.4 ms 12-bit Least sensitive.

24 ms 16-bit Medium sensitivity.

700 ms 16-bit Highest sensitivity.

Student Name: Roll No Department of CSE(IoT), SoCSET, NIET


[BCSIOT0353]IoT LAB USING ARDUINO and Node MCU 2024

j. servo Motor Pinout

Figure 6.12 Pinout of the Servo Motor


k. Relay Pinout

Figure 6.13 Pinout of the Relay

Student Name: Roll No Department of CSE(IoT), SoCSET, NIET

You might also like