Cs3691-Unit 3
Cs3691-Unit 3
UNIT-3
IMPORTANT QUESTIONS
PART-A
1) What is Arduino?
Arduino UNO is known as Open source development board as it allow us to interact with
real world by uploading program on this board.Arduino can interact with sensors, motors,
actuators and electro magnets etc.
Arduino Mega
Arduino UNO
Arduino Nano
ii) Make the Internet ever more expansive, but this requires hard-core technologies
such as rigorous cloud computing and rapid big data storage (expensive).
4) What is the Internet Of Things (IoT)?
Internet of Things (IoT) is a network of physical objects or people called “things” that are
embedded with software, electronics, network, and sensors that allow these objects to collect and
exchange data. The goal of IoT is to extend to internet connectivity from standard devices like
computer, mobile, tablet to relatively dumb devices like a toaster.
Page | 1
CS3691-Embedded Systems and IOT Prepared by: E U Iniyan,AP/ECE
The full form of IoT is the Internet of The full form of IIoT is the Industrial Internet of
Things. Things.
The quality of data is medium to high. The quality of data is high to very high.
Smoke sensor
Temperature sensors
Pressure sensor
Motion detection sensors
Gas sensor
Proximity sensor
IR sensors
Page | 2
CS3691-Embedded Systems and IOT Prepared by: E U Iniyan,AP/ECE
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, etc.
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.
A period of a pulse consists of an ON cycle (5V) and an OFF cycle (0V). The fraction for which
the signal is ON over a period is known as a duty cycle.
A function is a block of code that has a name and a block of statements that are executed when
the function is called.
PART-B
IoT stands for Internet of Things. It refers to the interconnectedness of physical devices, such
as appliances and vehicles, that are embedded with software, sensors, and connectivity which
enables these objects to connect and exchange data.
Page | 3
CS3691-Embedded Systems and IOT Prepared by: E U Iniyan,AP/ECE
Advancements in medicine, power, gene therapies, agriculture, smart cities, and smart homes
are just a very few of the categorical examples where IoT is strongly established.
Low-power embedded systems: Less battery consumption, high performance are the
inverse factors that play a significant role during the design of electronic systems.
Sensors: Sensors are the major part of any IoT application. It is a physical device that
measures and detects certain physical quantities and converts it into signal which can be
provided as an input to processing or control unit for analysis purpose.
Different types of Sensors:
1. Temperature Sensors
2. Image Sensors
3. Gyro Sensors
4. Obstacle Sensors
5. RF Sensor
6. IR Sensor
7. MQ-02/05 Gas Sensor
8. LDR Sensor
9. Ultrasonic Distance Sensor
Control Units: It is a unit of small computer on a single integrated circuit containing
microprocessor or processing core, memory and programmable input/output
devices/peripherals. It is responsible for major processing work of IoT devices and all
logical operations are carried out here.
Cloud computing: Data collected through IoT devices is massive, and this data has to be
stored on a reliable storage server. This is where cloud computing comes into play. The
data is processed and learned, giving more room for us to discover where things like
electrical faults/errors are within the system.
Availability of big data: We know that IoT relies heavily on sensors, especially in real-
time. As these electronic devices spread throughout every field, their usage is going to
trigger a massive flux of big data.
Networking connection: In order to communicate, internet connectivity is a must, where
each physical object is represented by an IP address. However, there are only a limited
number of addresses available according to the IP naming. Due to the growing number of
devices, this naming system will not be feasible anymore. Therefore, researchers are
looking for another alternative naming system to represent each physical object.
There are two ways of building IoT:
1. Form a separate internet work including only physical objects.
2. Make the Internet ever more expansive, but this requires hard-core technologies such as
rigorous cloud computing and rapid big data storage (expensive).
In the near future, IoT will become broader and more complex in terms of scope. It will change
the world in terms of
Page | 4
CS3691-Embedded Systems and IOT Prepared by: E U Iniyan,AP/ECE
IoT Enablers:
RFIDs: uses radio waves in order to electronically track the tags attached to each physical
object.
Sensors: devices that are able to detect changes in an environment (ex: motion detectors).
Nanotechnology: as the name suggests, these are tiny devices with dimensions usually less
than a hundred nanometers.
Smart networks: (ex: mesh topology).
Page | 6
CS3691-Embedded Systems and IOT Prepared by: E U Iniyan,AP/ECE
Computers
IOT Devices
Arduino is a project, open-source hardware, and software platform used to design and build
electronic devices. It designs and manufactures microcontroller kits and single-board interfaces
for building electronics projects.
The Arduino board consists of sets of analog and digital I/O (Input / Output) pins, which are
further interfaced to breadboard, expansion boards, and other circuits. Such boards feature the
model, Universal Serial Bus (USB), and serial communication interfaces, which are used for
loading programs from the computers.
What is Arduino?
Page | 7
CS3691-Embedded Systems and IOT Prepared by: E U Iniyan,AP/ECE
Arduino is a software as well as hardware platform that helps in making electronic projects. It is
an open source platform and has a variety of controllers and microprocessors. There are various
types of Arduino boards used for various purposes.
The Arduino is a single circuit board, which consists of different interfaces or parts. The board
consists of the set of digital and analog pins that are used to connect various devices and
components, which we want to use for the functioning of the electronic devices.
The analog pins in Arduino are mostly useful for fine-grained control. The pins in the Arduino
board are arranged in a specific pattern. The other devices on the Arduino board are USB port,
small components (voltage regulator or oscillator), microcontroller, power connector, etc.
There are many types of Arduino boards available in the market but all the boards have one thing
in common: they can be programmed using the Arduino IDE. The reasons for different types of
boards are different power supply requirements, connectivity options, their applications etc.
Arduino boards are available in different sizes, form factors, different no. of I/O pins etc. Some
of the commonly known and frequently used Arduino boards are Arduino UNO, Arduino Mega,
Arduino Nano, Arduino Micro and Arduino Lilypad.
There are add-on modules called Arduino Shields which can be used to extend the functionalities
of the Arduino boards. Some of the commonly used shields are Arduino Proto shield, Arduino
WiFi Shield and Arduino Yun Shield.
4)Explain in detail about the General purpose input/output pins of Arduino UNO.
General-Purpose Input Output (GPIO) is a digital pin of an IC. It can be used as input or output
for interfacing devices.
Page | 8
CS3691-Embedded Systems and IOT Prepared by: E U Iniyan,AP/ECE
Digital Output
Arduino (ATmega) digital pins can be configured as output to drive output devices. We have to
configure these pins to use as output.
To configure these pins, pinMode() function is used which set direction of pin as input or output.
These pin produce output in terms of HIGH (5 V or 3.3 V) or LOW (0 V). We can set output on
these pins using digitalWrite () function.
Digital Input
To read data from senor or from any device/circuit, we need to configure digital pin as input.
Arduino pin are set as digital input (default). So, there is no need to configure pin as input.
To configure pin as digital input, pinMode() function is used. We can read data from GPIO pin
using digitalRead() function.
digitalRead(pin)
Sometimes switching between one state to another or pins configured as input with
nothing connected to them may arise situation of High-impedance state i.e. floating state.
This state may report random changes in pin state.
To avoid this state, there is option of adding pull-up (to +5V) or pull-down (to Gnd)
resistor which helps to set the input to a known state. Following image show the high
impedance (undefine) state and pull-up resistor.
Page | 10
CS3691-Embedded Systems and IOT Prepared by: E U Iniyan,AP/ECE
Arduino (ATmega) has in-built configurable pull-up resistor. These resistors enable
using pinMode() with mode set to INPUT_PULLUP. When connecting a device or
sensor to a pin configured as input with pull-up, the other end should be connected to
ground.
We can configure input pull-up in another way too. If we set direction of pin as input and
then write HIGH value on that pin will turn on the pull-up resistor. In other manner, if we
write HIGH on pin configured as OUTPUT and then configure that pin as input will also
enable the pull-up resistor.
A PWM signal consists of two main components that define its behaviour: a duty cycle and
a frequency.
A period of a pulse consists of an ON cycle (5V) and an OFF cycle (0V). The fraction for which
the signal is ON over a period is known as a duty cycle.
Through PWM technique, we can control the power delivered to the load by using ON-OFF
signal. The PWM signals can be used to control the speed of DC motors and to change the
intensity of the LED.
Pulse Width Modulated signals with different duty cycle are shown below
Page | 11
CS3691-Embedded Systems and IOT Prepared by: E U Iniyan,AP/ECE
Frequency of Signal
The frequency of a signal determines how fast the PWM completes a cycle (i.e. 1000 Hz would
be 1000 cycles per second) which means how fast it switches between ON (high) and OFF (low)
states. By repeating this ON-OFF pattern at a fast-enough rate, and with a certain duty cycle, the
output will appear to behave like a constant voltage analog signal when providing power to
devices.
Arduino Uno has 6 8-bit PWM channels. The pins with symbol ‘~’ represents that it has PWM
support. These PWM pins are shown in below image.
Page | 12
CS3691-Embedded Systems and IOT Prepared by: E U Iniyan,AP/ECE
duty cycle – it lies in between 0 (0%, always off) – 255 (100%, always on).
e.g. analogWrite (3, 127) //generates pwm of 50% duty cycle
Page | 13
CS3691-Embedded Systems and IOT Prepared by: E U Iniyan,AP/ECE
Program written using Arduino IDE is called as Sketch. Compiler used in Arduino IDE is C/C++
library with AVR compiler.
1.Structure
2.Values
3.Functions
1.Structure:
The basic structure of the Arduino programming language is fairly simple and runs in
at least two parts. These two required parts, or functions, enclose blocks of
statements.
void setup()
statements;
void loop()
statements;
Where setup() is the preparation, loop() is the execution. Both functions are required
The setup function should follow the declaration of any variables at the very
beginning of the program. It is the first function to run in the program, is run only
The loop function follows next and includes the code to be executed continuously –
Page | 14
CS3691-Embedded Systems and IOT Prepared by: E U Iniyan,AP/ECE
reading inputs, triggering outputs, etc. This function is the core of all Arduino
setup()
The setup() function is called once when your program starts. Use it to initialize pin
statements to run.
void setup()
loop()
After calling the setup() function, the loop() function does precisely what its name
suggests, and loops consecutively, allowing the program to change, respond, and
void loop()
2.Functions:
A function is a block of code that has a name and a block of statements that are executed when
the function is called. The functions void setup() and void loop() have already been discussed
and other built-in functions will be discussed later.
Page | 15
CS3691-Embedded Systems and IOT Prepared by: E U Iniyan,AP/ECE
Custom functions can be written to perform repetitive tasks and reduce clutter in a program.
Functions are declared by first declaring the function type. This is the type of value to be
returned by the function such as 'int' for an integer type function. If no value is to be returned the
function type would be void. After type, declare the name given to the function and in
parenthesis any parameters being passed to the function.
type functionName(parameters)
statements;
The following integer type function delayVal() is used to set a delay value in a program by
reading the value of a potentiometer. It first declares a local variable v,sets v to the value of the
potentiometer which gives a number between 0-1023, then divides that value by 4 for a final
value between 0-255, and finally returns that value back to the main program.
int delayVal()
3. Variables:
A variable is a way of naming and storing a numerical value for later use by the
program. As their namesake suggests, variables are numbers that can be continually
changed as opposed to constants whose value never changes. A variable needs to be
declared and optionally assigned to the value needing to be stored.
The following code declares a variable called inputVariable and then assigns it the value
obtained on analog input pin 2:
Page | 16
CS3691-Embedded Systems and IOT Prepared by: E U Iniyan,AP/ECE
‘inputVariable’ is the variable itself. The first line declares that it will contain an int,
short for integer. The second line sets the variable to the value at analog pin 2. This
makes the value of pin 2 accessible elsewhere in the code. Once a variable has been
assigned, or re-assigned, you can test its value to see if it meets certain conditions, or you
can use its value directly. As an example to illustrate three useful operations with
variables, the following code tests whether the inputVariable is less than 100, if true it
assigns the value 100 to inputVariable, and then sets a delay based on inputVariable
which is now a minimum of 100:
Constants
The Arduino language has a few predefined values, which are called constants. They
are used to make the programs easier to read. Constants are classified in groups.
True/False
These are Boolean constants that define logic levels. FALSE is easily defined as 0
(zero) while TRUE is often defined as 1, but can also be anything else except zero.
So in a Boolean sense, -1, 2, and -200 are all also defined as TRUE.
if (b == TRUE);
doSomething;
High/Low
These constants define pin levels as HIGH or LOW and are used when reading or
Page | 17
CS3691-Embedded Systems and IOT Prepared by: E U Iniyan,AP/ECE
writing to digital pins. HIGH is defined as logic level 1, ON, or 5 volts while LOW is
digitalWrite(13, HIGH);
Input/Output
Constants used with the pinMode() function to define the mode of a digital pin as
pinMode(13, OUTPUT);
LED_BUILTIN
Most Arduino boards have a pin connected to an on-board LED in series with a resistor. The
constant LED_BUILTIN is the number of the pin to which the on-board LED is connected.
Most boards have this LED connected to digital pin 13.
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, etc.
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.
Page | 18
CS3691-Embedded Systems and IOT Prepared by: E U Iniyan,AP/ECE
o The shields can be attached and detached easily from the Arduino board. It does not require
any complex wiring.
o It is easy to connect the shields by mounting them over the Arduino board.
o The hardware components on the shields can be easily implemented.
Types of Shields
o Ethernet shield
o Xbee Shield
o Proto shield
o Relay shield
o Motor shield
o LCD shield
o Bluetooth shield
o Capacitive Touchpad Shield
Ethernet shield
o 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.
o The USB port will play the usual role to upload sketches on the board.
o 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.
o 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
o We can communicate wirelessly with the Arduino board by using the Xbee Shield with
Zigbee.
o It reduces the hassle of the cable, which makes Xbee a wireless communication model.
Page | 19
CS3691-Embedded Systems and IOT Prepared by: E U Iniyan,AP/ECE
o The Xbee wireless module allows us to communicate outdoor upto 300 feet and indoor
upto 100 feet.
Proto shield
o 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
o 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.
o The shield consists of four relays and four LED indicators.
o It also provides NO/NC interfaces and a shield form factor for the simple connection to the
Arduino board.
o The LED indicators depicts the ON/OFF condition of each relay.
o The relay used in the structure is of high quality.
o The NO (Normally Open), NC (Normally Closed), and COM pins are present on each
relay.
o The relay shield is shown below:
o The applications of the Relay shield include remote control, etc.
Motor shield
o The motor shield helps us to control the motor using the Arduino board.
o 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.
Page | 20
CS3691-Embedded Systems and IOT Prepared by: E U Iniyan,AP/ECE
o We can also measure the absorption current of each motor with the help of the motor shield.
o 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.
o It can drive inductive loads, such as solenoids, etc.
o The operating voltage is from 5V to 12V.
o The applications of the motor shield are intelligent vehicles, micro-robots, etc.
LCD shield
o The keypad of LCD (Liquid Crystal Display) shield includes five buttons called as up,
down, left, right, and select.
o There are 6 push buttons present on the shield that can be used as a custom menu control
panel.
o It consists of the 1602 white characters, which are displayed on the blue backlight LCD.
o The LED present on the board indicates the power ON.
o The five keys present on the board helps us to make the selection on menus and from board
to our project.
o The LCD shield is popularly designed for the classic boards such as Duemilanove, UNO,
etc.
Bluetooth shield
o The Bluetooth shield can be used as a wireless module for transparent serial
communication.
o 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.
o 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.
o The communication distance of the Bluetooth shield is upto 10m at home without any
obstacle in between.
Page | 21
CS3691-Embedded Systems and IOT Prepared by: E U Iniyan,AP/ECE
o It has a touchpad interface that allows to integrate the Arduino board with the touch shield.
o The Capacitive touchpad shield consists of 12 sensitive touch buttons, which includes 3
electrode connections and 9 capacitive touch pads.
o The board can work with the logic level of 3.3V or 5V.
o We can establish a connection to the Arduino project by touching the shield.
Page | 22