UNIT-3 - IOT AND ARDUNIO PROGRAMMING NOTES
UNIT-3 - IOT AND ARDUNIO PROGRAMMING NOTES
UNIT III
IOT AND ARDUINO PROGRAMMING
What Is Iot:
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. This technology allows for the collection
and sharing of data from a vast network of devices, creating opportunities for more efficient
and automated systems.
Internet of Things (IoT) is the networking of physical objects that contain electronics
embedded within their architecture in order to communicate and sense interactions amongst
each other or with respect to the external environment. In the upcoming years, IoT-based
technology will offer advanced levels of services and practically change the way people lead
their daily lives. 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.
IoT is network of interconnected computing devices which are embedded in everyday
objects, enabling them to send and receive data. Over 9 billion ‘Things’ (physical objects)
are currently connected to the Internet, as of now. In the near future, this number is expected
to rise to a whopping 20 billion.
There are two ways of building IoT:
1. Form a separate internetwork 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 “anytime, anyplace, anything in connectivity.”
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).
Different types of Sensors:
1. Temperature Sensors
2. Image Sensors
3. Gyro Sensors
Page No. - 1
AD3404-EMBEDDED SYSTEMS AND IOT Unit: III
4. Obstacle Sensors
5. RF Sensor
6. IR Sensor
7. MQ-02/05 Gas Sensor
8. LDR Sensor
9. Ultrasonic Distance Sensor
Nanotechnology: as the name suggests, these are extremely small devices with
dimensions usually less than a hundred nanometers.
Smart networks: (ex: mesh topology).
Page No. - 2
AD3404-EMBEDDED SYSTEMS AND IOT Unit: III
Working of IoT
Characteristics of the Internet of Things
The Internet of Things (IoT) is characterized by the following key features that are mentioned
below.
1. Connectivity
Connectivity is an important requirement of the IoT infrastructure. Things of IoT should be
connected to the IoT infrastructure. Anyone, anywhere, anytime can connect, this should be
guaranteed at all times. For example, the connection between people through Internet devices
like mobile phones, and other gadgets, also a connection between Internet devices such as
routers, gateways, sensors, etc.
2. Intelligence and Identity
The extraction of knowledge from the generated data is very important. For example, a sensor
generates data, but that data will only be useful if it is interpreted properly. Each IoT device
has a unique identity. This identification is helpful in tracking the equipment and at times for
querying its status.
3. Scalability
The number of elements connected to the IoT zone is increasing day by day. Hence, an IoT
setup should be capable of handling the massive expansion. The data generated as an
outcome is enormous, and it should be handled appropriately.
4. Dynamic and Self-Adapting (Complexity)
Page No. - 3
AD3404-EMBEDDED SYSTEMS AND IOT Unit: III
IoT devices should dynamically adapt themselves to changing contexts and scenarios.
Assume a camera meant for surveillance. It should be adaptable to work in different
conditions and different light situations (morning, afternoon, and night).
5. Architecture
IoT Architecture cannot be homogeneous in nature. It should be hybrid, supporting different
manufacturers ‘ products to function in the IoT network. IoT is not owned by anyone
engineering branch. IoT is a reality when multiple domains come together.
6. Safety
There is a danger of the sensitive personal details of the users getting compromised when all
his/her devices are connected to the internet. This can cause a loss to the user. Hence, data
security is the major challenge. Besides, the equipment involved is huge. IoT networks may
also be at risk. Therefore, equipment safety is also critical.
7. Self Configuring
This is one of the most important characteristics of IoT. IoT devices are able to upgrade their
software in accordance with requirements with a minimum of user participation. Additionally,
they can set up the network, allowing for the addition of new devices to an already-existing
network.
8. Interoperability
IoT devices use standardized protocols and technologies to ensure they can communicate
with each other and other systems. Interoperability is one of the key characteristics of the
Internet of Things (IoT). It refers to the ability of different IoT devices and systems to
communicate and exchange data with each other, regardless of the underlying technology or
manufacturer.
9. Embedded Sensors and Actuators
Embedded sensors and actuators are critical components of the Internet of Things (IoT). They
allow IoT devices to interact with their environment and collect and transmit data.
10. Autonomous operation
Autonomous operation refers to the ability of IoT devices and systems to operate
independently and make decisions without human intervention. This is a crucial characteristic
of the Internet of Things (IoT) and enables a wide range of new applications and services.
Configuring an Internet of Things (IoT)
Identify your IoT components: Determine the devices and sensors you will be using in your
IoT network. These could include sensors, actuators, gateways, and edge devices.
Choose a Communication Protocol:
Decide on the communication protocol you'll use for your devices to exchange data.
Common protocols include MQTT, CoAP, HTTP, and AMQP. Choose a protocol based on
factors like the type of data you'll be transmitting, the reliability needed, and the network
environment.
Page No. - 4
AD3404-EMBEDDED SYSTEMS AND IOT Unit: III
Set Up Network Infrastructure: Ensure you have a stable and secure network infrastructure in
place. This might include Wi-Fi, Ethernet, cellular, or even LoRaWAN for long-range low-
power communication.
Device Registration and Onboarding: Register each IoT device to your network. This might
involve provisioning them with necessary credentials (such as certificates) to ensure secure
communication.
Security Measures: Implement security mechanisms to protect your IoT ecosystem from
unauthorized access, data breaches, and cyberattacks. This could involve using encryption,
secure bootstrapping, device authentication, and firewalls.
Data Collection and Transmission: Configure devices to collect the required data from
sensors and other sources. Set up rules for data transmission frequency, conditions, and
thresholds. Ensure that data is sent efficiently to minimize network usage predictive
maintenance.
Agriculture: Soil moisture sensors, GPS trackers for livestock, and automated irrigation
systems.
Smart Cities: Connected streetlights, waste management systems, and traffic monitoring.
Automotive: Connected vehicles, vehicle-to-vehicle (V2V) communication, and self-
driving cars.
Benefits of IoT Devices:
Efficiency: IoT devices can optimize processes, reduce waste, and enhance resource
utilization.
Automation: Tasks can be automated based on real-time data, leading to improved
productivity.
Data-Driven Insights: IoT devices provide data that can be analyzed to gain insights,
make informed decisions, and identify trends.
Remote Monitoring and Control: Devices can be monitored and controlled remotely,
enabling real-time adjustments.
Enhanced User Experience: IoT devices create personalized experiences and
convenience for users.
Page No. - 5
AD3404-EMBEDDED SYSTEMS AND IOT Unit: III
Scalability: Handling a large number of devices and data points can be challenging.
Power Management: Ensuring devices have adequate power and optimizing energy
consumption.
Data Management: Efficiently handling and processing the vast amount of data generated
by IoT devices.
Page No. - 6
AD3404-EMBEDDED SYSTEMS AND IOT Unit: III
11. Security Measures: Security is critical in IoT to protect data, devices, and networks from
unauthorized access and cyberattacks. Security measures include encryption, authentication,
access controls, and regular software updates.
12. Power Management: IoT devices often operate on limited power sources such as
batteries. Power management strategies are essential to optimize energy consumption and
extend the device's operational lifespan.
13. Data Analytics and Insights: Analyzing the data collected from IoT devices can yield
valuable insights
for making informed decisions, predicting trends, and improving operations.
14. Machine Learning and Artificial Intelligence (AI): IoT systems can leverage machine
learning and AI to improve automation, anomaly detection, and decision-making based on
real-time data.
Modern Applications:
1. Smart Grids and energy saving
2. Smart cities
3. Smart homes/Home automation
4. Healthcare
5. Earthquake detection
6. Radiation detection/hazardous gas detection
7. Smartphone detection
8. Water flow monitoring
9. Traffic monitoring
10. Wearables
11. Smart door lock protection system
12. Robots and Drones
13. Healthcare and Hospitals, Telemedicine applications
14. Security
15. Biochip Transponders(For animals in farms)
16. Heart monitoring implants(Example Pacemaker, ECG real time tracking)
Advantages of IoT :
1. Improved efficiency and automation of tasks.
2. Increased convenience and accessibility of information.
Page No. - 7
AD3404-EMBEDDED SYSTEMS AND IOT Unit: III
Disadvantages of IoT :
1. Security concerns and potential for hacking or data breaches.
2. Privacy issues related to the collection and use of personal data.
3. Dependence on technology and potential for system failures.
4. Limited standardization and interoperability among devices.
5. Complexity and increased maintenance requirements.
6. High initial investment costs.
7. Limited battery life on some devices.
8. Concerns about job displacement due to automation.
9. Limited regulation and legal framework for IoT, which can lead to confusion and
uncertainty.
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.
Difference between IoT devices and Computers:
Page No. - 8
AD3404-EMBEDDED SYSTEMS AND IOT Unit: III
The hardware and software built-in in the The hardware and software built-in in the
IoT devices are streamlined for that computers are streamlined to do many
particular task. tasks(such as calculation, gaming, music
player, etc. )
IoT devices can be cheaper and faster at a A computer can be expensive and slower
particular task than computers, as IoT at a particular task than an IoT device.
devices are made to do that particular task.
Examples: Music Player- iPod, Alexa, Examples: Desktop computers, Laptops,
smart cars, etc. etc.
Difference between IoT devices and 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.
Introduction to Arduino
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 boards were initially created to help the students with the non-technical
background. The designs of Arduino boards use a variety of controllers and microprocessors.
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.
Types of Arduino
The flexibility of the Arduino board is enormous so that one can do anything they imagine.
This board can be connected very easily to different modules such as obstacle sensors,
presence detectors, fire sensors, GSM Modules GPS modules, etc.
The main function of the Arduino board is to control electronics through reading inputs &
changing it into outputs because this board works like a tool. This board is also used to make
different electronics projects in the field of electronics, electrical, robotics, etc.
Features of Different Types of Arduino Boards
The features of different types of Arduino boards are listed in the tabular form.
Page No. - 9
AD3404-EMBEDDED SYSTEMS AND IOT Unit: III
Arduino Due
LilyPad Arduino Board
Arduino Bluetooth
Arduino Diecimila
RedBoard Arduino Board
Arduino Mega (R3) Board
Arduino Leonardo Board
Arduino Robot
Arduino Esplora
Arduino Pro Mic
Arduino Ethernet
Arduino Zero
Fastest Arduino Board
Page No. - 10
AD3404-EMBEDDED SYSTEMS AND IOT Unit: III
Page No. - 11
AD3404-EMBEDDED SYSTEMS AND IOT Unit: III
Arduino Nano
As compared with the Arduino Uno board, it is small in size. The devices like mini USB and
Arduino IDE are necessary to build the projects. This board mainly includes analog pins-8,
digital pins-14 with the set of an I/O pin, power pins-6 & RST (reset) pins-2. Please refer to
this link to know more about Arduino Nano Board.
Arduino Micro
The Arduino Micro board mainly depends on the ATmega32U4 based Microcontroller that
includes 20-sets of pins where the 7-pins are PWM pins, 12-analog input pins. This board
includes different components like an ICSP header, RST button, small USB connection,
crystal oscillator-16MHz. The USB connection is inbuilt and this board is the shrunk version
of the Leonardo board.
Arduino Micro
Arduino Due
This Arduino board depends on the ARM Cortex-M3 and it is the first Arduino
microcontroller board. This board includes digital I/O pins-54 where 12-pins are PWM o/p
pins, analog pins -12, UARTs-4, a CLK with 84 MHz, an USB OTG, DAC-2, a power jack,
TWI-2, a JTAG header, an SPI header, two buttons for reset & erase.
Page No. - 12
AD3404-EMBEDDED SYSTEMS AND IOT Unit: III
Arduino Due
This board works with 3.3V where the highest voltage that the pins of input/output can stand
is 3.3V because providing a high voltage to any I/O pin can lead to damage the board This
board is simply connected to a computer through a small USB cable otherwise it can be
powered through an AC to DC adapter. This Arduino Due board is suitable with all shields of
Arduino at 3.3V.
LilyPad Arduino Board
The Lily Pad Arduino board is a wearable e-textile technology expanded by Leah “
Buechley” and considerately designed by “Leah and SparkFun”. Each board was
imaginatively designed with huge connecting pads & a smooth back to let them to be sewn
into clothing using conductive thread. This Arduino also comprises of I/O, power, and also
sensor boards which are built especially for e-textiles. These are even washable!
Page No. - 13
AD3404-EMBEDDED SYSTEMS AND IOT Unit: III
The microcontroller board like Arduino Diecimila mainly depends on the ATmega168. This
board includes digital I/O pins -14 where 6-pins can be used like PWM outputs & analog
inputs-6, a USB connection, a crystal oscillator-16 MHz, an ICSP header, a reset button & a
power jack. This board can be connected to a computer through a USB cable and it can be
activated using a battery and an AC-DC adapter.
Arduino Diecimila
As the name suggests, the meaning of Diecimila in Italian is 10,000 which means that marks
the truth that above 10k Arduino boards have been designed. In a set of USB Arduino boards,
it is the latest one as compared with other versions.
RedBoard Arduino Board
The RedBoard Arduino board can be programmed using a Mini-B USB cable using the
Arduino IDE. It will work on Windows 8 without having to modify your security settings. It
is more constant due to the USB or FTDI chip we used and also it is entirely flat on the back.
Creating it is very simple to utilize in the project design. Just plug the board, select the menu
option to choose an Arduino UNO and you are ready to upload the program. You can control
the RedBoard over a USB cable using the barrel jack.
RedBoard Arduino Boards
The RedBoard Arduino board can be programmed using a Mini-B USB cable using the
Arduino IDE. It will work on Windows 8 without having to modify your security settings. It
is more constant due to the USB or FTDI chip we used and also it is entirely flat on the back.
Creating it is very simple to utilize in the project design. Just plug the board, select the menu
option to choose an Arduino UNO and you are ready to upload the program. You can control
the RedBoard over a USB cable using the barrel jack.
Page No. - 14
AD3404-EMBEDDED SYSTEMS AND IOT Unit: III
Page No. - 15
AD3404-EMBEDDED SYSTEMS AND IOT Unit: III
operating. Every board is a complete Arduino board and its programming can be done
through the Arduino IDE. These are microcontroller boards that depend on the ATmega32u4.
The pins of this Robot are mapped to actuators and sensors onboard. The process of
programming the robot is the same as the Arduino Leonardo board. It is also named a small
computer and it is extensively used in robotics.
This board includes the speaker, color screen, buttons-5, motors-2, a digital compass, an SD
card reader, potentiometers-2 & floor sensors-5. The library of this robot can be used for
controlling the sensors as well as the actuators.
Arduino Esplora
The Arduino Esplora includes a small computer known as a microcontroller including a
number of inputs & outputs. The inputs of this board are a light sensor, four buttons, a
microphone, an accelerometer, joystick, a slider, a temperature sensor, etc whereas the
outputs are a 3 color LED, a buzzer. This kind of Arduino board looks like a videogame
controller.
The programming of this board can be done using Arduino Software like IDE which takes the
data from the inputs and controls the output like a keyboard or a mouse. As compared with all
other types of Arduino boards, this esplora is totally different because the inputs, as well as
outputs, are connected to the board already.
Arduino Esplora
So connecting the components like actuators or sensors is very simple. Thus, programming is
somewhat different as compared with other types of Arduino boards. This esplora board
includes its own library so that the data from the sensors & actuators are very easy to read
and write.
Arduino Pro Mic
The Arduino Pro Micro board is the same as the Arduino Mini board apart from the
ATmega32U4 Microcontroller. This pro mic board includes digital I/O pins-12, pulse width
modulation (PWM) pins-5, serial connections of Tx & Rx &10-bit ADC.
Arduino Ethernet
Page No. - 16
AD3404-EMBEDDED SYSTEMS AND IOT Unit: III
The Arduino Ethernet board depends on the microcontroller like ATmega328. This kind of
microcontroller board includes analog pins-5, digital I/O pins-14, RST button, an RJ45
connection, crystal oscillator, a power jack, ICSP header, etc. The connection of the Arduino
board can be done through the Ethernet shield to the internet.
Arduino Zero
This is a powerful as well as simple 32-bit board and it provides the best platform for
innovative projects like wearable technology, smart IoT devices, crazy robotics, high-tech
automation, etc. This board expands by providing improved performance, permitting a range
of project opportunities & performs like a great educational tool.
Arduino Zero
This board includes analog input pins-6, digital I/O pins-14, a power jack, AREF button,
UART port pins, a USB connector & an In-Circuit Serial Programming (ICSP) header, a
power header, etc.
This board is power-driven through the SAMD21 microcontroller based on Atmel. The main
feature of this is EDBG (Embedded Debugger) based on Atmel and it provides a complete
debug interface without using extra hardware.
Fastest Arduino Board
Designing one of the best Arduino development boards that are familiar with Arduino MEGA
& UNO is the hifive1 board that includes a 320 MHz RISC-V microcontroller unit. This kind
of fastest board has Cortex M-7 with a 400 MHz microcontroller unit.
Flash memory – upto 2Mbytes
RAM -1 Mbyte
DMA controllers -4
Communication peripherals- Up to 35
16-bit Max Resolution with 3× ADCs
D/A converters with 2× 12-bit
Page No. - 17
AD3404-EMBEDDED SYSTEMS AND IOT Unit: III
Page No. - 18
AD3404-EMBEDDED SYSTEMS AND IOT Unit: III
Structure of Sketch
The function setup() is the point where the code starts, just like the main() function in C and
C++
I/O Variables, pin modes are initialized in the Setup() function
Loop() function, as the name suggests, iterates the specified task in the program
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.
Let us start with the Structure. Software structure consist of two main functions −
Setup( ) function - The setup() function is called when a sketch starts. Use it to initialize
the variables (not declaration), pin modes, start using libraries, etc. The setup function will
only run once, after each power up or reset of the Arduino board.
Loop( ) function - 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
Page No. - 19