Sample IoT - Lab - File - Experiment - 1 - To - 6
Sample IoT - Lab - File - Experiment - 1 - To - 6
GREATER NOIDA
Department of CSE(IoT)
School of Computer Sciences in Emerging Technologies
Lab File
of
Affiliated to Dr. A.P.J Abdul Kalam Technical University, Uttar Pradesh, Lucknow
Section:
[BCSIOT0353]IoT LAB USING ARDUINO and Node MCU 2024
Index
B. TECH. SECOND YEAR (CSE(IoT)) 3rd Sem
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
(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.
Experiment- 1
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.'
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.
5. Installation in progress
The process will extract and install all the required files to execute properly the Arduino
Software (IDE).
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:
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:
Each board has different features, but they all can be programmed using the Arduino IDE.
• 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:
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.
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.
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.
Experiment- 2
Aim: Getting Programming board Info and configuring boot loader settings
using Arduino IDE.
o Plug your Arduino board into your computer using a USB cable.
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.
§ Board Name
o Navigate to hardware/arduino/avr/boards.txt.
• Upload a basic sketch (e.g., Blink) to test if the bootloader is functioning correctly.
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.
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.
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.
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.
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.
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.
EEPROM 1 KB 1 KB 4 KB
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.
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.
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
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 &
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.
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).
• 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.
• 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.
These use cases demonstrate the versatility of NodeMCU and ESP8266, especially for
projects needing low-power, internet-connected devices for monitoring, automation, and
control.
Experiment- 6
a. DHT 11
4 GND Ground.
Parameter Specification
Humidity Resolution 1% RH
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:
2 GND Ground.
4 DO Digital output (high or low based on the threshold set via potentiometer).
Parameter Specification
c. Pinout of MQ 7 Sensor
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:
2 GND Ground.
4 DO Digital output (high or low based on the threshold set via potentiometer).
• 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.
The MQ-7 is designed to detect Carbon Monoxide (CO) and has the following resolution
specifications:
Parameter Specification
Heater Voltage (Cycle) 1.5V for 90 seconds (low); 5.0V for 60 seconds (high)
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:
2 DOUT Digital output: Binary signal based on threshold set via potentiometer.
3 GND Ground.
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.
Parameter Specification
4 GND Ground.
Parameter Specification
Operating Voltage 5V DC
Operating Current 15 mA
Accuracy ±3 mm
2 GND Ground.
Note: On some modules, the pins may be labeled differently (e.g., "S" for Signal instead of
AO or DO).
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
2 GND Ground.
Parameter Specification
3 GND Ground
Some PIR sensors may have additional pins or potentiometers for adjusting sensitivity and
delay.
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:
Motion Detection Resolution Detects general body heat movement, not detailed shapes
• 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.
Pin Description
*Note: Some line sensors have configurable analog/digital outputs for each channel. Check
the specific datasheet for details.
Sensor Resolution
2 GND Ground.
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: