Iot Unit 3 Full Notes
Iot Unit 3 Full Notes
Iot Unit 3 Full Notes
An IoT ecosystem consists of web-enabled smart devices that use embedded systems -- such as processors, sensors and
communication hardware -- to collect, send and act on data they acquire from their environments.IoT devices share the
sensor data they collect by connecting to an IoT gateway, which acts as a central hub where IoT devices can send data.
Before the data is shared, it can also be sent to an edge device where that data is analyzed locally. Analyzing data locally
reduces the volume of data sent to the cloud, which minimizes bandwidth consumption.
What Are IoT Devices? IoT devices are hardware devices, such as sensors, gadgets, appliances and other
machines that collect and exchange data over the Internet. They are programmed for certain applications and can
be embedded into other IoT devices. For example, an IoT device in your car can identify the traffic ahead and send
out a message automatically to the person you are about to meet of your impending delay.
How do IoT Devices Work? Different IoT devices have different functions, but they all have similarities in terms of how
they work. Firstly, IoT devices are physical objects that sense things going on in the physical world. They contain an
integrated CPU, network adapter and firmware, and are usually connected to a Dynamic Host Configuration Protocol
server. It also requires an IP address to function over the network. Most IoT devices are configured and managed through a
software application. For example, an app on your smartphone to control the lights in your home. Some devices also have
integrated web servers, which eliminates the need for external applications. For example, the lights switch on immediately
when you enter a room. Examples are:-
Home Security :The key driver behind smart and secure homes is IoT. A variety of sensors, lights, alarms and cameras
(all of which can be controlled from a smartphone) are connected via IoT to provide 24x7 security.
Activity Trackers :Smart home security cameras provide alerts and peace of mind. Activity trackers are sensor devices
that can monitor and transmit key health indicators in real-time. You can track and manage your blood pressure, appetite,
physical movement and oxygen levels.
The Internet of Things (IoT) is the network of physical objects/devices like vehicles, buildings, cars, and other items
embedded with electronics, software, sensors, and network connectivity that enables these objects to collect and exchange
data. IoT devices have made human life easier. The IoT devices like smart homes, smart cars have made the life of
humans very comfortable. IoT devices are now being a part of our day-to-day life.
Computers:
A computer is a hardware device embedded with software in it. The computer does most of the work like calculations,
gaming, web browsers, word processors, e-mails, etc. The main function of a computer is to compute the functions, to run
the programs. It takes input from the computer and then computes/processes it and generates the output.
Function of Computer
Overview of IoT Vs Computers:
One big difference between IoT devices and computers is that the main function of IoT devices is not to compute(not to be
a computer) and the main function of a computer is to compute functions and to run programs. But on IoT devices that is
not its main point, it has some other function besides that. As an example like in cars, the function of IoT devices are not to
compute anti-lock breaking or to do fuel injection, their main function from the point of view of a user is to be driven and to
move you from place to place and the computer is just to help that function. For example, The main function of the car is not
to compute like anti-lock breaking or to do fuel injection their main function from the point of view of a user is to drive, to
move you from place to place. But when we embed software in it then the software can be able for fuel limit detection.
IoT devices are special-purpose devices.Examples: Music Computers are general-purpose devices.Examples: Desktop
Player- iPod, Alexa, smart cars, etc. computers, Laptops, etc.
a. Device Selection
● Purpose and Requirements: Determine the specific use case and requirements for the IoT device (e.g.,
temperature monitoring, security cameras, smart lighting).
● Compatibility: Ensure compatibility with existing systems and other IoT devices.
● Specifications: Review technical specifications, such as power requirements, connectivity options, and sensor
capabilities.
● Power Supply: Connect the device to a power source, which could be a battery, USB, or AC power.
● Location: Place the device in an optimal location for connectivity and sensor effectiveness.
● Mounting: If necessary, mount the device using brackets, screws, or adhesive pads.
2. Network Configuration
a. Connectivity Options
● Wi-Fi: Common for home and office environments. Requires SSID and password configuration.
● Bluetooth: Used for short-range communication. Often used for initial setup before switching to Wi-Fi.
● Ethernet: Provides stable and reliable connections, commonly used in industrial settings.
● Cellular: Ideal for remote locations without Wi-Fi or Ethernet access.
● LoRaWAN and Zigbee: Used for low-power, long-range communication in IoT networks.
b. Network Setup
● Access Point Connection: Connect the device to the local network via Wi-Fi or Ethernet.
● Network Credentials: Enter the network SSID and password for Wi-Fi connections.
● Static IP vs. DHCP: Decide whether to assign a static IP address or use DHCP for automatic IP assignment.
● Firewall and Security: Configure firewall settings to allow communication with the device while ensuring security.
3. Device Configuration
a. Software/Firmware Updates
● Check for Updates: Ensure the device firmware is up-to-date to benefit from the latest features and security
patches.
● Automatic Updates: Enable automatic updates if supported by the device.
b. Device Settings
● Time and Date: Set the correct time and date, often done automatically if the device connects to the internet.
● Localization: Configure language and regional settings.
● Sensor Calibration: Calibrate sensors if necessary for accurate readings.
● Selection of Platform: Choose a cloud platform like AWS IoT, Microsoft Azure IoT, or Google Cloud IoT.
● Account Setup: Create and configure an account on the chosen platform.
● Device Registration: Register the device on the cloud platform, typically involving unique device identifiers and
authentication tokens.
b. Data Management
● Data Collection: Set up data collection parameters, such as frequency and type of data collected.
● Data Storage: Configure where and how data is stored, either locally or on the cloud.
● Data Processing: Define rules for processing data, including triggers and actions based on specific conditions.
c. Third-Party Integrations
5. Security Measures
● User Authentication: Implement strong authentication mechanisms, such as multi-factor authentication (MFA).
● Device Authentication: Use secure methods for device authentication, such as certificates or hardware-based
security modules.
b. Data Encryption
● In-Transit: Encrypt data transmitted over networks using protocols like TLS/SSL.
● At-Rest: Encrypt stored data to protect it from unauthorized access.
c. Network Security
● Firewalls: Use firewalls to protect the device from unauthorized network access.
● VPNs: Implement Virtual Private Networks (VPNs) for secure remote access to devices.
Basic Components
1. Smart devices and sensors – Device connectivity
Devices and sensors are the components of the device connectivity layer. These smart sensors are continuously collecting
data from the environment and transmit the information to the next layer.The latest techniques in semiconductor technology
are capable of producing micro smart sensors for various applications.
2. Gateway
● IoT Gateway manages the bidirectional data traffic between different networks and protocols. Another function of
the gateway is to translate different network protocols and make sure interoperability of the connected devices and
sensors.
● Gateways can be configured to perform pre-processing of the collected data from thousands of sensors locally
before transmitting it to the next stage. In some scenarios, it would be necessary due to the compatibility of the
TCP/IP protocol.
● IoT gateway offers a certain level of security for the network and transmitted data with higher-order encryption
techniques. It acts as a middle layer between devices and the cloud to protect the system from malicious attacks
and unauthorized access.
3. Cloud
● The Internet of Things creates massive data from devices, applications, and users, which has to be managed in an
efficient way. IoT cloud offers tools to collect, process, manage and store huge amounts of data in real time.
Industries and services can easily access these data remotely and make critical decisions when necessary.
● Basically, the IoT cloud is a sophisticated, high-performance network of servers optimized to perform high-speed
data processing of billions of devices, traffic management, and deliver accurate analytics. Distributed database
management systems are one of the most important components of the IoT cloud.
● Cloud system integrates billions of devices, sensors, gateways, protocols, and data storage and provides predictive
analytics. Companies use these analytics data to improve products and services, preventive measures for certain
steps, and build their new business model accurately.
4. Analytics
● Analytics is the process of converting analog data from billions of smart devices and sensors into useful insights
which can be interpreted and used for detailed analysis. Smart analytics solutions are inevitable for IoT systems for
the management and improvement of the entire system.
● One of the major advantages of an efficient IoT system is real-time smart analytics which helps engineers to find
out irregularities in the collected data and act fast to prevent an undesired scenario. Service providers can prepare
for further steps if the information is collected accurately at the right time.
● Big enterprises use the massive data collected from IoT devices and utilize the insights for their future business
opportunities. Careful analysis will help organizations to predict trends in the market and plan ahead for a
successful implementation.
5. User interface
● User interfaces are the visible, tangible part of the IoT system which users can access. It is one of the significant
components of Internet of things where user control the system and collect information. Designers will have to
make sure of a well-designed user interface for minimum effort for users and encourage more interactions.
● Modern technology offers much interactive design to ease complex tasks into simple touch panel controls.
Multicolor touch panels have replaced hard switches in our household appliances, and the trend is increasing for
almost every smart home device.
● The user interface design has higher significance in today’s competitive market; it often determines the user
whether to choose a particular device or appliance. Users will be interested in buying new devices or smart gadgets
if it is very user-friendly and compatible with common wireless standards.
The Arduino software is open-source. The source code for the Java environment is released under the GPL and the C/C++
microcontroller libraries are under the LGPL.
Sketch − The first new terminology is the Arduino program called “sketch”.
Structure
Arduino programs can be divided in three main parts: Structure, Values (variables and constants), and Functions. In this
tutorial, we will learn about the Arduino software program, step by step, and how we can write the program without any
syntax or compilation error.
void setup() {
void loop() {
SETUP() The setup() function is called when a sketch starts. Use it to initialize the variables, pin modes, start using
libraries, etc. The setup function will only run once, after each power up or reset of the Arduino board.
Loop ( ) After creating a setup() function, which initializes and sets the initial values, the loop() function does precisely
what its name suggests, and loops consecutively, allowing your program to change and respond. Use it to actively control
the Arduino board.
Sketches
1. Setup Function: This function runs once when the Arduino is powered on or reset. It is used to initialize variables,
pin modes, start using libraries, etc.
2. Loop Function: After the setup() function completes, the loop() function runs repeatedly in a loop. This is where the
main logic of the program resides.
void setup() {
void loop() {
/* This is a
multi-line comment */
Variables and Data Types: Arduino supports several data types, including:
Digital I/O
Arduino has digital pins that can be used as input or output.
Setting Pin Modes: Use pinMode() in the setup() function to set a pin as either INPUT or OUTPUT.
void setup() {
Writing to a Digital Pin: Use digitalWrite() to set a digital pin HIGH or LOW.
void loop() {
Reading from a Digital Pin: Use digitalRead() to read the value of a digital pin.
void loop() {
if (buttonState == HIGH) {
} else {
Analog I/O
Arduino can also read analog signals using its analog pins.
Reading Analog Values: Use analogRead() to read values from analog pins. The function returns a value between 0 and
1023.
void loop() {
delay(1000);
}
Writing Analog Values: Use analogWrite() to write PWM signals to digital pins capable of PWM (denoted by ~ on the
board).
void loop() {
delay(10);
delay(10);
Serial Communication
Serial communication is crucial for debugging and communicating with other devices.
Initializing Serial Communication: Use Serial.begin() in the setup() function to initialize the serial communication.
void setup() {
Sending Data: Use Serial.print() and Serial.println() to send data to the serial monitor.
void loop() {
Serial.println(sensorValue);
delay(1000);
void loop() {
if (Serial.available() > 0) {
Serial.println(incomingByte);
} }
Using Libraries
Libraries are pre-written code that provide extra functionality. For example, to control an LCD screen, you would include the
LiquidCrystal library.
#include <LiquidCrystal.h>
void setup() {
lcd.begin(16, 2);
lcd.print("Hello, World!");
void loop() {
1. Blinking an LED
A simple program to blink an LED connected to pin 13.
void setup() {
pinMode(13, OUTPUT);
void loop() {
2. Reading a Potentiometer
Reading a potentiometer value and printing it to the serial monitor.
void setup() {
Serial.begin(9600);
void loop() {
Serial.println(sensorValue);
delay(1000);
3. Button Press
Turning on an LED when a button is pressed.
void setup() {
pinMode(buttonPin, INPUT);
pinMode(ledPin, OUTPUT);
void loop() {
if (buttonState == HIGH) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}
4. Temperature Sensor
Reading a temperature sensor (e.g., LM35) and displaying the temperature on an LCD.
#include <LiquidCrystal.h>
void setup() {
lcd.begin(16, 2);
Serial.begin(9600);
void loop() {
lcd.setCursor(0, 0);
lcd.print("Temp: ");
lcd.print(temperatureC);
lcd.print(" C");
Serial.print("Temperature: ");
Serial.print(temperatureC);
Serial.println(" C");
delay(1000);
Pins
Digital Pins:
Digital pins are the workhorses of Arduino projects, offering a binary interface for communication with external devices.
They are capable of being configured as either inputs or outputs, allowing for versatile interaction with the physical world.
As inputs, digital pins can detect the state of switches, buttons, or sensors, while as outputs, they can control LEDs, relays,
or other digital components.One of the significant advantages of digital pins is their simplicity and ease of use. They operate
on a straightforward logic level, where a voltage above a certain threshold (typically around 2.5 volts) is interpreted as HIGH
or logic 1, and a voltage below that threshold is considered LOW or logic 0. This binary nature makes digital pins ideal for
tasks that involve simple on/off control or reading digital signals.
Digital pins can also serve as communication interfaces for various protocols such as UART (Universal Asynchronous
Receiver-Transmitter), SPI (Serial Peripheral Interface), or I2C (Inter-Integrated Circuit). For instance, the Arduino Software
Serial library allows you to emulate additional serial ports using digital pins, enabling communication with multiple serial
devices simultaneously.
Analog Pins:
Analog pins provide the Arduino with the ability to read analog voltage levels, converting them into digital values using the
built-in analog-to-digital converter (ADC). This capability is essential for interfacing with analog sensors that provide
continuous voltage outputs proportional to physical quantities like temperature, light intensity, or pressure.The analogRead()
function in Arduino software reads the voltage level present at an analog pin and converts it into a digital value ranging from
0 to 1023 (for 10-bit ADC resolution). This digital value represents the relative magnitude of the analog signal, allowing you
to perform calculations or make decisions based on the input received from analog sensors.Additionally, analog pins can be
repurposed as digital pins when needed, providing flexibility in pin allocation for different project requirements. This feature
is particularly useful in scenarios where the number of available digital pins is insufficient, and utilizing analog pins as digital
I/O expands the capabilities of the Arduino board.
PWM Pins:
Pulse Width Modulation (PWM) pins enable the generation of analog-like signals by rapidly switching a digital pin on and off
at varying duty cycles. This technique allows you to control the average voltage output, effectively simulating analog signals
for tasks such as dimming LEDs, controlling motor speed, or generating audio tones.PWM pins on Arduino boards typically
operate at a fixed frequency (around 490 Hz), but their duty cycle can be adjusted to achieve the desired output voltage
level. The analogWrite() function in Arduino software sets the duty cycle of a PWM pin, with values ranging from 0 (0% duty
cycle, effectively off) to 255 (100% duty cycle, fully on).
Power Pins:
Arduino boards provide several power pins to supply voltage and ground connections for external components. The 5V pin
delivers a regulated 5-volt output, suitable for powering most sensors, actuators, and peripherals. Conversely, the 3.3V pin
provides a lower voltage output, which is useful for interfacing with components that require a reduced voltage level.Ground
pins are essential for completing electrical circuits and providing a reference voltage level for measurements. They ensure
that the voltage across components remains stable and consistent, preventing potential issues like voltage spikes or
floating ground levels.
Reset Pin:
The reset pin on Arduino boards allows you to restart the microcontroller, restoring it to its initial state. This pin can be
controlled either manually by connecting it to ground or programmatically by writing a LOW signal to it using digital I/O
operations. Resetting the Arduino is often necessary for debugging purposes, reinitializing variables, or restarting the
program execution flow.
I2C Pins:
Inter-Integrated Circuit (I2C) pins enable two-wire serial communication between the Arduino and I2C-compatible devices
such as sensors, RTC (Real-Time Clock) modules, or EEPROM (Electrically Erasable Programmable Read-Only Memory).
I2C communication utilizes a bus architecture with a shared data line (SDA) and a shared clock line (SCL), allowing multiple
devices to communicate with the Arduino using a single pair of pins. This feature simplifies wiring and reduces pin usage,
making it ideal for projects that require interfacing with multiple I2C devices.
Digital Pins:
Digital pins on Arduino boards can operate in two modes: input and output. When configured as input, these pins can read
either a high (5V) or low (0V) voltage level. When set as output, they can output either a high or low voltage level.
Digital Input:
Digital input pins are commonly used to read the state of switches, buttons, or digital sensors. Here's a theoretical
explanation along with a sample Arduino sketch:
const int buttonPin = 2; // Define the pin connected to the push button
void setup() {
pinMode(buttonPin, INPUT); // Set the button pin as input
Serial.begin(9600); // Initialize serial communication for debugging
}
void loop() {
int buttonState = digitalRead(buttonPin); // Read the state of the button
if (buttonState == HIGH) { // Check if button is pressed
Serial.println("Button pressed!"); // Print message to serial monitor
}
delay(100); // Add a small delay to debounce the button
}
Digital Output:
Digital output pins are used to control digital devices such as LEDs, relays, or other digital components. They can be set to
either a high or low voltage level to turn the device on or off.
const int ledPin = 13; // Define the pin connected to the LED
void setup() {
pinMode(ledPin, OUTPUT); // Set the LED pin as output
}
void loop() {
digitalWrite(ledPin, HIGH); // Turn on the LED
delay(1000); // Wait for 1 second
digitalWrite(ledPin, LOW); // Turn off the LED
delay(1000); // Wait for 1 second
}
Analog Pins:
Analog pins on Arduino boards are used to read analog voltage levels from sensors or generate analog output using Pulse
Width Modulation (PWM). They can read voltages between 0 and 5 volts, converting them into digital values.
Analog Input:
Analog input pins are used to read analog voltage levels from sensors such as potentiometers, light sensors, or
temperature sensors. The Arduino's analog-to-digital converter (ADC) converts these voltages into digital values.
const int potentiometerPin = A0; // Define the pin connected to the potentiometer
void setup() {
Serial.begin(9600); // Initialize serial communication for debugging
}
void loop() {
int sensorValue = analogRead(potentiometerPin); // Read the value from the potentiometer
float voltage = sensorValue * (5.0 / 1023.0); // Convert sensor value to voltage (0-5V)
Serial.print("Analog voltage: "); // Print label
Serial.print(voltage); // Print voltage value
Serial.println("V"); // Print units
delay(500); // Add a small delay for stability
}
void setup() {
pinMode(ledPin, OUTPUT); // Set the LED pin as output
}
void loop() {
analogWrite(ledPin, 128); // Set LED brightness to approximately 50% (out of 255)
delay(1000); // Wait for 1 second
analogWrite(ledPin, 0); // Turn off the LED
delay(1000); // Wait for 1 second
}
Arduino Shields
● Arduino shields are the boards, which are plugged over the Arduino board to expand its functionalities. There are
different varieties of shields used for various tasks, such as Arduino motor shields, Arduino communication shields,
● Shield is defined as the hardware device that can be mounted over the board to increase the capabilities of the
projects. It also makes our work easy. For example, Ethernet shields are used to connect the Arduino board to the
Internet.
● The pin position of the shields is similar to the Arduino boards. We can also connect the modules and sensors to
the shields with the help of the connection cable.
● Arduino motor shields help us to control the motors with the Arduino board.
○ The shields can be attached and detached easily from the Arduino board. It does not require any complex wiring.
○ It is easy to connect the shields by mounting them over the Arduino board.
Types of Shields
Ethernet shield
○ The Ethernet shields are used to connect the Arduino board to the Internet. We need to mount the shield on the top
of the specified Arduino board.
○ The USB port will play the usual role to upload sketches on the board.
○ The latest version of Ethernet shields consists of a micro SD card slot. The micro SD card slot can be interfaced
with the help of the SD card library.
○ We can also connect another shield on the top of the Ethernet shield. It means that we can also mount two shields
on the top of the Arduino board.
Xbee Shield
○ We can communicate wirelessly with the Arduino board by using the Xbee Shield with Zigbee.
○ It reduces the hassle of the cable, which makes Xbee a wireless communication model.
○ The Xbee wireless module allows us to communicate outdoor upto 300 feet and indoor upto 100 feet.
Proto shield
○ The shield consists of two LED pads, two power lines, and SPI signal pads.
○ The IOREF (Input Output voltage REFerence) and GND (Ground) are the two power lines on the board.
○ We can also solder the SMD (Surface Mount Device) ICs on the prototyping area. A maximum of 24 pins can be
integrated onto the SMD area.
Relay shield
○ The Arduino digital I/O pins cannot bear the high current due to its voltage and current limits. The relay shield is
used to overcome such situation. It provides a solution for controlling the devices carrying high current and voltage.
○ It also provides NO/NC interfaces and a shield form factor for the simple connection to the Arduino board.
○ The NO (Normally Open), NC (Normally Closed), and COM pins are present on each relay.
Motor shield
○ The motor shield helps us to control the motor using the Arduino board.
○ It controls the direction and working speed of the motor. We can power the motor shield either by the external
power supply through the input terminal or directly by the Arduino.
○ We can also measure the absorption current of each motor with the help of the motor shield.
○ The motor shield is based on the L298 chip that can drive a step motor or two DC motors. L298 chip is a full bridge
IC. It also consists of the heat sinker, which increases the performance of the motor shield.
○ The applications of the motor shield are intelligent vehicles, micro-robots, etc.
LCD shield
○ The keypad of LCD (Liquid Crystal Display) shield includes five buttons called as up, down, left, right, and select.
○ There are 6 push buttons present on the shield that can be used as a custom menu control panel.
○ It consists of the 1602 white characters, which are displayed on the blue backlight LCD.
○ The five keys present on the board helps us to make the selection on menus and from board to our project.
○ The LCD shield is popularly designed for the classic boards such as Duemilanove, UNO, etc.
Bluetooth shield
○ The Bluetooth shield can be used as a wireless module for transparent serial communication.
○ It includes a serial Bluetooth module. D0 and D1 are the serial hardware ports in the Bluetooth shield, which can be
used to communicate with the two serial ports (from D0 to D7) of the Arduino board.
○ We can install Groves through the two serial ports of the Bluetooth shield called a Grove connector. One Grove
connector is digital, while the other is analog.
○ The communication distance of the Bluetooth shield is upto 10m at home without any obstacle in between.
○ It has a touchpad interface that allows to integrate the Arduino board with the touch shield.
○ The Capacitive touchpad shield consists of 12 sensitive touch buttons, which includes 3 electrode connections and
9 capacitive touch pads.
○ The board can work with the logic level of 3.3V or 5V.