Iot Repaired

Download as pdf or txt
Download as pdf or txt
You are on page 1of 38

Practical File Of

INTERNET OF THINGS &


ARTIFICIAL INTELLIGENCE LAB
(CSEN 1110)

Diploma Engineering in Computer Science

Submitted By: Submitted To:


Name: Anita Khandelwal
Roll No: CSE Department
Branch: PDMU Bahadurgarh
CONTENTS

Sr.no Name of the Experiment Date Signature

1 Introduction of internet of things (IOT)

2 Applications, architecture, protocols

3 Physical design/Logical design of IOT

4 Functional blocks of iot, communication models

5 Role of AL in iot and its applications

6 Basics of C language using Arduino IDE

7 Variables, datatype, loops, control statement,


function

8 Introduction to Artificial intelligence (AI), Machine


learning(ML), Deep learning(DL)

9 Write a prolog program to perform arithmetic


operations.
10. To write a program to sense the available networks
using Arduino.
EXPERIMENT No: 1

Aim: Introduction to Internet of Things.


Theory:
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.
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 four main components used in IOT:

1. Low-power embedded systems: Less battery consumption, high performance are the
inverse factors that play a significant role during the design of electronic systems.

2. 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.

3. 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.

4. 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 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)
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 extremely small devices with
dimensions usually less than a hundred nanometers.

Characteristics of iot:
 Massively scalable and efficient
 IP-based addressing will no longer be suitable in the upcoming future.
 An abundance of physical objects is present that do not use IP, so iot is made possible.
 Devices typically consume less power. When not in use, they should be automatically
programmed to sleep.
 A device that is connected to another device right now may not be connected in another
instant of time.
 Intermittent connectivity – iot devices aren’t always connected. In order to save bandwidth
and battery consumption, devices will be powered off periodically when not in use.
Otherwise, connections might turn unreliable and thus prove to be inefficient.
As a quick note, iot incorporates trillions of sensors, billions of smart systems, and millions of
applications.
Application Domains: iot is currently found in four different popular domains:
1. Manufacturing/Industrial business – 40.2%
2. Healthcare – 30.3%
3. Security – 7.7%
4. Retail – 8.3%

Modern Applications:
1. Smart Grids and energy saving
2. Smart cities
3. Smart homes
4. Healthcare
5. Earthquake detection
6. Radiation detection/hazardous gas detection
7. Smartphone detection
8. Water flow monitoring
9. Traffic monitoring
10. Wearables
Advantages of IOT Disadvantages of IOT

 Communication  Lagging of standard


 Automation compatibility
 Remote control  More opportunities for failure
 More information  Loss of privacy or security
 Better decision  More dependent on technology
 Continuous monitoring
 Time saving
 Money saving
 Efficient handling

What exactly is the Internet of things?


It refers to providing network connectivity & computing capabilities to everyday
sensors and objects, allowing them to exchange and consume data without any
human intervention or with minimal human interference.
The Internet of things is, thus, a dynamic global network infrastructure with self-
configuring capabilities based on standard and interoperable communication
protocols where physical and virtual things have identities, physical attributes, and
virtual personalities and use intelligent interfaces seamlessly integrated into the
information network, often communicate data associated with users and their
environment.

Summary: Thus on the whole Setting up the IoT environment includes,


 Identifying the problem and the purpose.
 Identifying the data collection challenges.
 Identifying the cloud platform for data storage.
 Coding into the processor to meet your expected need after data analysis.
 Enhancing the advantages and diminishing the disadvantages of IOT .
EXPERIMENT No: 2

Aim: Application, Architecture & Protocols of IOT.

Applications of IOT:
Iot application run on iot devices and can be created to be specific to almost every industry
and vertical, including healthcare, industrial automation, smart homes and buildings,
automotive and wearable technology. Increasingly, iot applications are using AL and machine
learning to add intelligence to devices.

There are some applications of iot which is as follow:-

1. IoT Applications in Agriculture


For indoor planting, IoT makes monitoring and management of micro-climate
conditions a reality, which in turn increases production. For outside planting, devices
using IoT technology can sense soil moisture and nutrients, in conjunction with weather
data, better control smart irrigation and fertilizer systems. If the sprinkler systems
dispense water only when needed, for example, this prevents wasting a precious
resource.

2. IoT Applications in Consumer Use


For the private citizen, IoT devices in the form of wearables and smart homes make life easier.
Wearables cover accessories such as Fitbit, smartphones, Apple watches, health monitors, to
name a few. These devices improve entertainment, network connectivity, health, and fitness.

3. IoT Applications in Healthcare


First and foremost, wearable IoT devices let hospitals monitor their patients’ health at home,
thereby reducing hospital stays while still providing up to the minute real-time information that
could save lives. In hospitals, smart beds keep the staff informed as to the availability, thereby
cutting wait time for free space. Putting IoT sensors on critical equipment means fewer
breakdowns and increased reliability, which can mean the difference between life and death.

4. IoT Applications in Insurance


Even the insurance industry can benefit from the IoT revolution. Insurance companies can offer
their policyholders discounts for IoT wearables such as Fitbit. By employing fitness tracking,
the insurer can offer customized policies and encourage healthier habits, which in the long run,
benefits everyone, insurer, and customer alike.

5. IoT Applications in Manufacturing


The world of manufacturing and industrial automation is another big winner in the IoT
sweepstakes. RFID and GPS technology can help a manufacturer track a product from its start
on the factory floor to its placement in the destination store, the whole supply
chain from start to finish. These sensors can gather information on travel time, product
condition, and environmental conditions that the product was subjected to.

6. IoT Applications in Retail


IoT technology has a lot to offer the world of retail. Online and in-store shopping sales figures
can control warehouse automation and robotics, information gleaned from IoT sensors. Much
of this relies on RFIDs, which are already in heavy use worldwide.

7. IoT Applications in Transportation


By this time, most people have heard about the progress being made with self-driving cars. But
that’s just one bit of the vast potential in the field of transportation. The GPS, which, if you
think of it, is another example of IoT, is being utilized to help transportation companies plot
faster and more efficient routes for trucks hauling freight, thereby speeding up delivery times.

8. IoT Applications in Utilities/Energy


IoT sensors can be employed to monitor environmental conditions such as humidity,
temperature, and lighting. The information provided by IoT sensors can aid in the creation of
algorithms that regulate energy usage and make the appropriate adjustments, eliminating the
human equation.

Architecture of iot
An iot architecture is the system of numerous elements that range from sensors, protocols,
actuators, to cloud services and layers. Besides, devices and sensors the internet of things(IOT)
architecture layers are distinguished to track the consistency of a system through protocols and
gateways.
The architecture of IoT depends upon its functionality and implementation in different sectors. Still,
there is a basic process flow based on which IoT is built.

So, from the above image it is clear that there is 4 layers are present that can be divided
as follows: Sensing Layer, Network Layer, Data processing Layer, and Application
Layer.
These are explained as following below.
1. Sensing Layer –
Sensors, actuators, devices are present in this Sensing layer. These Sensors or Actuators
accepts data(physical/environmental parameters), processes data and emits data over
network.

2. Network Layer –
Internet/Network gateways, Data Acquisition System (DAS) are present in this layer. DAS
performs data aggregation and conversion function (Collecting data and aggregating data
then converting analog data of sensors to digital data etc). Advanced gateways which
mainly opens up connection between Sensor networks and Internet also performs many
basic gateway functionalities like malware protection, and filtering also some times
decision making based on inputted data and data management services, etc.
3. Data processing Layer –
This is processing unit of IoT ecosystem. Here data is analyzed and pre- processed before
sending it to data center from where data is accessed by software applications often
termed as business applications where data is monitored and managed and further actions
are also prepared. So here Edge IT or edge analytics comes into picture.

4. Application Layer –
This is last layer of 4 stages of IoT architecture. Data centers or cloud is management stage
of data where data is managed and is used by end-user applications like agriculture, health
care, aerospace, farming, defense, etc.

Protocols of iot
Iot data protocols are used to connect low-power iot devices. They provide communication
with hardware on the user side without the need for any internet connection. The connectivity
in iot data protocol and standards is through a wired or cellular network.

Why are IoT protocols important?

The benefit and value of IoT comes from enabling the components to communicate; this ability
to communicate is what moves data from endpoint devices through the IoT pipeline to central
servers.
This communication happens via IoT protocols, which ensure that data sent from endpoint
devices, such as sensors, is received and understood by the next and subsequent steps in the
connected environment, whether the next step for that data is to another endpoint device or a
gateway or an application.

How many protocols are there in iot?


Six types of IoT protocols and network standards. Devices are generally connected to the
internet with an IP (internet protocol) network. But, devices can also be connected locally via
Bluetooth or NFC (near-field communication). The differences between both types of
connections are power, range, and memory used.

Which protocol is most widely used in IoT?


Wifi. It is one of the most popular IoT communication protocols. This connection type works
best for the LAN environment and offers fast data transfer. Capable to process large amounts
of data, it is the go-to choice for many developers.

IoT Data Protocols


 MQTT (Message Queuing Telemetry Transport) An MQTT (Message Queuing
Telemetry Transport) is a lightweight IoT data protocol. ...
 CoAP (Constrained Application Protocol) ...
 AMQP (Advanced Message Queuing Protocol) ...
 DDS (Data Distribution Service) ...
 HTTP (Hyper Text Transfer Protocol) ...
 WebSocket. ...
 WiFi. ...
 Bluetooth.

IoT Protocols

These protocols are used to establish communication between a node device and a server over
the internet. it helps to send commands to an IoT device and receive data from an iot device
over the internet. we use different types of protocols that are present on both the server and
client-side and these protocols are managed by network layers like application, transport,
network, and link layer.
EXPERIMENT No: 3

Aim: Physical design/Logical design of IOT.


Physical Design of iot
The physical design of an Iot system is referred to as the Things/Devices and protocols that are
used to build an IoT system. all these things/Devices are called Node Devices and every device
has a unique identity that performs remote sensing, actuating and monitoring work. and the
protocols that are used to establish communication between the Node devices and servers over
the internet.
• The "Things" in IoT usually refers to IoT devices which have unique identities and can
perform remote sensing, actuating and monitoring capabilities.
• IoT devices can:
• Exchange data with other connected devices and applications (directly or indirectly),
• Collect data from other devices and process the data locally or
• Send the data to centralized servers or cloud-based application back-ends For
processing the data, or
• Perform some tasks locally and other tasks within the IoT infrastructure, based on temporal
and space constraints
Things
Basically Things refers to IoT Devices which have unique identities and can perform remote
sensing, actuating and monitoring capabilities. Things are is main part of IoT Application. IoT
Devices can be various type, Sensing Devices, Smart Watches, Smart Electronics appliances,
Wearable Sensors, Automobiles, and industrial machines. These devices generate data in some
forms or the other which when processed by data analytics systems leads to useful information
to guide further actions locally or remotely.

For example, Temperature data generated by a Temperature Sensor in Home or other place,
when processed can help in determining temperature and take action according to users. Above
picture, shows a generic block diagram of IoT device. It may consist of several interfaces for
connections to other devices. IoT Device has I/O interface for Sensors, Similarly for Internet
connectivity, Storage and Audio/Video. IoT Device collect data from on-board or attached
Sensors and Sensed data communicated either to other device or Cloud based sever. Today
many cloud servers available for especially IoT System. These Platfrom known as IoT
Platform. Actually these cloud especially design for IoT purpose. So here we can analysis and
processed data easily.

How it works ?
For example if relay switch connected to an IoT device can turn On/Off an appliance on the
commands sent to the IoT device over the Internet.
Logical Design of IoT
A logical design for an IoT system is the actual design of how its components (computers,
sensors, and actuators) should be arranged to complete a particular function. It doesn’t go
into the depth of describing how each component will be built with low-level programming
specifics.
IoT logical design includes:

1. IoT functional blocks:


IoT systems include several functional blocks such as Devices, communication,
security, services, and application. The functional blocks provide sensing, identification,
actuation, management, and communication capability. These functional blocks consist of
devices that handle the communication between the server and the host, enable monitoring
control functions, manage the data transfer, secure the IoT system using authentication and
different functions, and provide an interface for controlling and monitoring various terms.

2. IoT communications models


There are multiple kinds of models available in an Internet of Things system that is
used for communicating between the system and server, such as:
 Request-response model
 Push-pull model
 Publish-subscribe model
 Exclusive pair model

3. IoT communication APIs


APIs are used to communicate between the server and system in IoT. Some API’s
include:
 REST-based communication APIs
 Client-server
 Stateless
 Cacheable
 Websocket based communication API

Difference Between Physical and Logical Design of IoT

Physical Design Logical Design

Logical design is a high-level design and


Physical design is highly detailed.
doesn’t provide any detail.

Physical design is more graphical than


Logical design can be textual, graphic, or both.
textual; however, it can comprise both.

A physical design focuses on specific A logical design focuses on satisfying the design
solutions explaining how they are factors, including risks, requirements,
assembled or configured. constraints, and assumptions.
EXPERIMENT No: 4

Aim: Functional block of iot, communication models.


IoT systems include several functional blocks such as Devices, communication, security,
services, and application. The functional blocks provide sensing, identification, actuation,
management, and communication capability.

An IoT system comprises of a number of functional blocks that provide the system the
capabilities for identification, sensing, actuation, communication and management functional
blocks are:

Device: An IoT system comprises of devices that provide sensing, actuation, monitoring and
control functions.
Communication: Handles the communication for the IoT system.
Services: services for device monitoring, device control service, data publishing services and
services for device discovery.
Management: this blocks provides various functions to govern the IoT system. Security: this
block secures the IoT system and by providing functions such as authentication , authorization,
message and content integrity, and data security. Application: This is an interface that the users
can use to control and monitor various aspects of the IoT system. Application also allow users
to view the system status and view or analyze the processed data.

Functional block of iot


Communication Models in IoT (Internet of Things )
IoT devices are found everywhere and will enable circulatory intelligence in the future. For
operational perception, it is important and useful to understand how various IoT devices
communicate with each other. Communication models used in IoT have great value. The IoTs
allow people and things to be connected any time, any space, with anything and anyone, using
any network and any service.
Types of Communication Model :
1. Request & Response Model –
This model follows a client-server architecture.
 The client, when required, requests the information from the server. This request is usually
in the encoded format.
 This model is stateless since the data between the requests is not retained and each request
is independently handled.
 The server Categories the request, and fetches the data from the database and its resource
representation. This data is converted to response and is transferred in an encoded format
to the client. The client, in turn, receives the response.
 On the other hand — In Request-Response communication model client sends a request
to the server and the server responds to the request. When the server receives the request
it decides how to respond, fetches the data retrieves resources, and prepares the response,
and sends it to the client.

2. Publisher-Subscriber Model –
This model comprises three entities: Publishers, Brokers, and Consumers.
 Publishers are the source of data. It sends the data to the topic which are managed by the
broker. They are not aware of consumers.
 Consumers subscribe to the topics which are managed by the broker.
 Hence,
 Brokers responsibility is to accept data from publishers and send it to the appropriate
consumers. The broker only has the information regarding the consumer to which a
particular topic belongs to which the publisher is unaware of.

3. Push-Pull Model –
The push-pull model constitutes data publishers, data consumers, and data queues.
 Publishers and Consumers are not aware of each other.
 Publishers publish the message/data and push it into the queue. The consumers, present on
the other side, pull the data out of the queue. Thus, the queue acts as the buffer for the
message when the difference occurs in the rate of push or pull of data on the side of a
publisher and consumer.
 Queues help in decoupling the messaging between the producer and consumer. Queues
also act as a buffer which helps in situations where there is a mismatch between the rate at
which the producers push the data and consumers pull the data.
4. Exclusive Pair –
 Exclusive Pair is the bi-directional model, including full-duplex communication among
client and server. The connection is constant and remains open till the client sends a
request to close the connection.
 The Server has the record of all the connections which has been opened.
 This is a state-full connection model and the server is aware of all open
connections.
 WebSocket based communication API is fully based on this model.
EXPERIMENT No: 5

Aim: Role of AL in iot and its applications.


Role of AL in iot
The convergence of AI (Artificial Intelligence) and IoT can redefine the way industries,
business, and economies functions. AI enabled IoT creates intelligent machines that simulate
smart behavior and supports in decision making with little or no human interference.

Benefits of AI Enabled IoT


Artificial intelligence in the Internet of Things provides a wide range of advantages for
businesses and consumers, including proactive intervention, tailored experiences, and
intelligent automation.

Applications of Artificial Intelligence in Internet of Things

Artificial Intelligence and the Internet of Things is like a match made in Tech Heaven!!

While both of these disciplines have individual value, their true potential can only be realized
together. There are many different applications across multiple industries that require Artificial
Intelligence and Internet of Things. Some of these are given as follows:
1. Collaborative Robots
Ever wanted the help of a robot? Well, that’s exactly what you will get with Collaborative
Robots or Cobots. These Cobots are highly complex machines that are designed to help humans
in a shared workspace with environments ranging from office to industrial. They can be a robot
arm designed to perform tasks or even a complex robot designed to fulfill tough tasks.
2. Drones
Drones are aircraft without a human pilot (The piloting is done by the software!). They are
extremely useful as they can navigate unknown surroundings(even those beyond the reach of
the internet) and reach areas hazardous for humans such as offshore operations, mines, war
zones or burning buildings.
3. Smart Cities
When everything is getting smart, why not whole cities? Smart cities can be created with a
network of sensors that are attached to the physical city infrastructure. These sensors can be
used to monitor the city for various civic factors such as energy efficiency, air pollution, water
use, noise pollution, traffic conditions, etc.
4. Digital Twins
Digital Twins are twin (obviously!) objects in which one is a real-world object and the other
is its digital replica. These objects can range from airplane engines to wind turbines. Digital
Twins are mainly used to analyze the performance of the objects without using the traditional
testing methods and so reducing the costs required for testing.
5. Smart Retailing
This is shopping made smart! AI and IoT can be used by retailers to understand the customer
behavior (by studying the consumer online profile, in-store inventory, etc.) and then send real-
time personalized offers while the customer is in the store.
EXPERIMENT No: 6

Aim: Basics of C language using Arduino IDE.


An Arduino program that is written using C language programming is usually called a sketch.
The first thing that we need is Arduino IDE, which is available on the Arduino official website
free of cost. After downloading and installing Arduino IDE. Start the Arduino IDE.

How to download and install Arduino IDE


 This section demonstrate downloading, installation and testing of the software
you need for this tutorial
 Start the internet browser and enter the address arduino.cc and press enter
 Go to “Download the arduino IDE”
 It gives you different options for installation according to you operating system
 You can download Arduino IDE windows installer for windows. you can
download windows zip file for non-admin installation.you can download and
install windows app for windows 8.1 or windows 10

How to upload code to Arduino board


 Now lets see how to upload your first code to Arduino Uno using Arduino IDE.
Start with plugging your board into laptop using the USB cable. Micro usb end
which will be plugged into the board and the other end which will be plugged
into the PC.
 The power provided by the PC via USB cable is not much. Therefore Arduino
Uno board are provided with a power plug so that supply with greater power can
be connected to the board.
 The arduino IDE support a variety of different microcontroller boards.
Therefore, You must tell the IDE which board you will be using for writing your
program code
 For this purpose, open the IDE and go to the tools in the drop down menu of
tools, click on boards. It will show different available boards of arduino. as we
are using arduino UNO. We will select the arduino UNO board.
 The IDE does a pretty good job of automatically figuring out which USB port
you have selected to power and communicate with the microcontroller board.
 What we need to do now is load and run a program code to see that everything
is working properly. Although we could write a short program from scratch but
we can not do that yet because we simply do not have enough information under
our belt at this junction to make much of a learning experience from the process.
Rather writing our own program we will load and run a simple program that is
included as a part of the arduino IDE and it blinks an LED.
Basic building blocks of Arduino c programming
 Expressions
 Statements
 Statement blocks
 Functional blocks

Expressions in Arduino c programming


An expression is created by combining operands and operators.
What is operand?
Operand is simply a piece of data that is acted on by an operator. what is
operator?
Operator is often a mathematical or logical action that is performed on one or more
operands.
Types of expressins:-
 Addition Expressions
 Subtraction Expression
 Relational Expression
Rational expression in Arduino c programming

Statements in Arduino c programming

A statement is a complete C instruction for the computer. All C statements end with a semicolon.
Examples are
 i=50;
 a=b+c;
 m=d/2 ;
Order of precedence in Arduino programming

Arduino C programming resolves such ambiguities by assigning each operator a precedence or


priority level. Operator precedence refers to the order in which complex expressions are
resolved.
EXPERIMENT No: 7

Aim: Variables, datatype, loops, control statement, function.


Variables
A variable is nothing but a name given to a storage area that our programs can manipulate.
Each variable in C has a specific type, which determines the size and layout of the variable's
memory; the range of values that can be stored within that memory; and the set of operations
that can be applied to the variable.
The name of a variable can be composed of letters, digits, and the underscore character. It must
begin with either a letter or an underscore. Upper and lowercase letters are distinct because C
is case-sensitive.

Sr.No. Type & Description

1
char
Typically a single octet(one byte). It is an integer type.

2
Int
The most natural size of integer for the machine.

3
float
A single-precision floating point value.

4
double
A double-precision floating point value.

5
void
Represents the absence of type.

C programming language also allows to define various other types of variables, which we will
cover in subsequent chapters like Enumeration, Pointer, Array, Structure, Union, etc. For this
chapter, let us study only basic variable types.
Variable Definition in C
A variable definition tells the compiler where and how much storage to create for the variable.
A variable definition specifies a data type and contains a list of one or more variables of that
type.
Variable Declaration in C
A variable declaration provides assurance to the compiler that there exists a variable with the
given type and name so that the compiler can proceed for further compilation without requiring
the complete detail about the variable. A variable definition has its meaning at the time of
compilation only, the compiler needs actual variable definition at the time of linking the
program.
A variable declaration is useful when you are using multiple files and you define your variable
in one of the files which will be available at the time of linking of the program. You will use the
keyword extern to declare a variable at any place. Though you can declare a variable multiple
times in your C program, it can be defined only once in a file, a function, or a block of code.

Data type
Data types in c refer to an extensive system used for declaring variables or functions of different
types. The type of a variable determines how much space it occupies in storage and how the bit
pattern stored is interpreted.
The types in C can be classified as follows −

Sr.No. Types & Description

1
Basic Types
They are arithmetic types and are further classified into: (a) integer types and
(b) floating-point types.

2
Enumerated types
They are again arithmetic types and they are used to define variables that can
only assign certain discrete integer values throughout the program.

3
The type void
The type specifier void indicates that no value is available.

4
Derived types
They include (a) Pointer types, (b) Array types, (c) Structure types, (d) Union
types and (e) Function types.

The array types and structure types are referred collectively as the aggregate types. The type of
a function specifies the type of the function's return value.
Integer Types
The following table provides the details of standard integer types with their storage sizes and
value ranges −

Type Storage size Value range

char 1 byte -128 to 127 or 0 to 255

unsigned char 1 byte 0 to 255

signed char 1 byte -128 to 127

-32,768 to 32,767
int 2 or 4 bytes or -
2,147,483,648 to
2,147,483,647
unsigned int 2 or 4 bytes 0 to 65,535 or 0 to
4,294,967,295
short 2 bytes -32,768 to 32,767

unsigned short 2 bytes 0 to 65,535

long 8 bytes or (4bytes for 32 bit OS) -


9223372036854775808

to
9223372036854775807
unsigned long 8 bytes 0 to 18446744073709551615

To get the exact size of a type or a variable on a particular platform, you can use the size of
operator. The expressions size of(type) yields the storage size of the object or type in bytes.

Loop
A loop statement allows us to execute a statement or group of statements multiple times. Given
below is the general form of a loop statement in most of the programming languages −
C programming language provides the following types of loops to handle looping requirements.

Sr.No. Loop Type & Description

1 while loop
Repeats a statement or group of statements while a given condition is true. It tests
the condition before executing the loop body.

2 for loop
Executes a sequence of statements multiple times and abbreviates the code that
manages the loop variable.

3 do...while loop
It is more like a while statement, except that it tests the condition at the end of the
loop body.

4 nested loops
You can use one or more loops inside any other while, for, or do..while loop.

Loop Control Statements


Loop control statements change execution from its normal sequence. When execution leaves
a scope, all automatic objects that were created in that scope are destroyed.
C supports the following control statements.
Sr.No. Control Statement & Description

1 break statement
Terminates the loop or switch statement and transfers execution to the statement
immediately following the loop or switch.

2 continue statement
Causes the loop to skip the remainder of its body and immediately retest its
condition prior to reiterating.

3 goto statement
Transfers control to the labeled statement.

Function
A function is a group of statements that together perform a task. Every C program has at least
one function, which is main(), and all the most trivial programs can define additional functions.
You can divide up your code into separate functions. How you divide up your code among
different functions is up to you, but logically the division is such that each function performs a
specific task.
A function declaration tells the compiler about a function's name, return type, and parameters.
A function definition provides the actual body of the function.
The C standard library provides numerous built-in functions that your program can call. For
example, strcat() to concatenate two strings, memcpy() to copy one memory location to another
location, and many more functions.
A function can also be referred as a method or a sub-routine or a procedure, etc.
Defining a Function
The general form of a function definition in C programming language is as follows −
A function definition in C programming consists of a function header and a function body.
Here are all the parts of a function −
 Return Type − A function may return a value. The return_type is the data type of the
value the function returns. Some functions perform the desired operations without
returning a value. In this case, the return_type is the keyword void.
 Function Name − This is the actual name of the function. The function name and the
parameter list together constitute the function signature.
 Parameters − A parameter is like a placeholder. When a function is invoked, you pass
a value to the parameter. This value is referred to as actual parameter or
argument. The parameter list refers to the type, order, and number of the parameters of
a function. Parameters are optional; that is, a function may contain no parameters.
 Function Body − The function body contains a collection of statements that define what
the function does.
EXPERIMENT No: 8
Aim: Introduction to Artificial intelligence (AL), Machine learning (ML), Deep
learning(DL).
Artificial intelligence
Artificial Intelligence is an approach to make a computer, a robot, or a product to think how
smart human think. AI is a study of how human brain think, learn, decide and work, when it tries
to solve problems. And finally this study outputs intelligent software systems.
"It is a branch of computer science by which we can create intelligent machines which
can behave like a human, think like humans, and able to make decisions."
AI has developed a large number of tools to solve the most difficult problems in computer
science, like:-
 Search and optimization
 Logic
 Probabilistic methods for uncertain reasoning
 Classifiers and statistical learning methods
 Neural networks
 Control theory
 Languages

WHAT IS ARTIFICIAL INTELLIGENCE?


Artificial intelligence (AI) is a wide-ranging branch of computer science concerned with
building smart machines capable of performing tasks that typically require human intelligence.
There are four types of artificial intelligence-
1. Reactive Machines
2. Limited Memory
3. Theory of Mind
4. Self-Awareness
Examples of artificial intelligence-
 Siri, Alexa and other smart assistants
 Self-driving cars
 Robo-advisors
 Conversational bots
 Email spam filters
 Netflix's recommendations
Four different approaches that have historically defined the field of AI:
1. Thinking humanly
2. Thinking rationally
3. Acting humanly
4. Acting rationally

How is AI Used?
"AI is a computer system able to perform tasks that ordinarily require human intelligence...
Many of these artificial intelligence systems are powered by machine learning, some of them
are powered by deep learning and some of them are powered by very boring things like
rules."

Artificial intelligence generally falls under two broad categories:


 Narrow AI: Sometimes referred to as "Weak AI," this kind of
artificial intelligence operates within a limited context and is a simulation of
human intelligence. Narrow AI is often focused on performing a single task
extremely well and while these machines may seem intelligent, they are operating
under far more constraints and limitations than even the most basic human
intelligence.

 Artificial General Intelligence (AGI): AGI, sometimes referred to as "Strong


AI," is the kind of artificial intelligence we see in the movies, like the robots from
Westworld or Data from Star Trek: The Next Generation. AGI is a machine with
general intelligence and, much like a human being, it can apply that intelligence
to solve any problem.

Machine learning

Machine learning (ML) is a branch of artificial intelligence (AI) that enables computers to
“self-learn” from training data and improve over time, without being explicitly programmed.
Machine learning algorithms are able to detect patterns in data and learn from them, in order
to make their own predictions.
OR
Machine learning feeds a computer data and uses statistical techniques to help it "learn" how to
get progressively better at a task, without having been specifically programmed for that task,
eliminating the need for millions of lines of written code. Machine learning consists of both
supervised learning (using labeled data sets) and unsupervised learning (using unlabeled data
sets).
Machine learning is a subfield of artificial intelligence (AI). The goal of machine learning
generally is to understand the structure of data and fit that data into models that can be
understood and utilized by people.
Although machine learning is a field within computer science, it differs from traditional
computational approaches. In traditional computing, algorithms are sets of explicitly
programmed instructions used by computers to calculate or problem solve. Machine learning
algorithms instead allow for computers to train on data inputs and use statistical
analysis in order to output values that fall within a specific range. Because of this, machine
learning facilitates computers in building models from sample data in order to automate
decision-making processes based on data inputs.
Any technology user today has benefitted from machine learning. Facial recognition
technology allows social media platforms to help users tag and share photos of friends. Optical
character recognition (OCR) technology converts images of text into movable type.
Recommendation engines, powered by machine learning, suggest what movies or television
shows to watch next based on user preferences. Self-driving cars that rely on machine learning
to navigate may soon be available to consumers.
Machine learning is a continuously developing field. Because of this, there are some
considerations to keep in mind as you work with machine learning methodologies, or analyze
the impact of machine learning processes.

Machine Learning Steps


The task of imparting intelligence to machines seems daunting and impossible. But it is
actually really easy.
It can be broken down into 7 major steps :

1. Collecting Data:
Machines initially learn from the data that you give them. It is of the utmost importance to collect
reliable data so that your machine learning model can find the correct patterns. The quality of
the data that you feed to the machine will determine how accurate your model is. If you have
incorrect or outdated data, you will have wrong outcomes or predictions which are not relevant.

2. Preparing the Data:


After you have your data, you have to prepare it. You can do this by :

 Putting together all the data you have and randomizing it. This helps make sure that data is
evenly distributed, and the ordering does not affect the learning process.
 Cleaning the data to remove unwanted data, missing values, rows, and columns, duplicate
values, data type conversion, etc. You might even have to restructure the dataset and change
the rows and columns or index of rows and columns.
 Visualize the data to understand how it is structured and understand the relationship between
various variables and classes present.
 Splitting the cleaned data into two sets - a training set and a testing set. The training set is
the set your model learns from. A testing set is used to check the accuracy of your model
after training.

3. Choosing a Model:
A machine learning model determines the output you get after running a machine learning
algorithm on the collected data. It is important to choose a model which is relevant to the task
at hand. Over the years, scientists and engineers developed various
models suited for different tasks like speech recognition, image recognition, prediction, etc.

4. Training the Model:


Training is the most important step in machine learning. In training, you pass the prepared data
to your machine learning model to find patterns and make predictions. It results in the model
learning from the data so that it can accomplish the task set. Over time, with training, the model
gets better at predicting.

5. Evaluating the Model:


After training your model, you have to check to see how it’s performing. This is done by testing
the performance of the model on previously unseen data. The unseen data used is the testing
set that you split our data into earlier. If testing was done on the same data which is used for
training, you will not get an accurate measure, as the model is already used to the data, and
finds the same patterns in it, as it previously did. This will give you disproportionately high
accuracy.

6. Parameter Tuning:
Once you have created and evaluated your model, see if its accuracy can be improved in any
way. This is done by tuning the parameters present in your model. Parameters are the variables
in the model that the programmer generally decides. At a particular value of your parameter,
the accuracy will be the maximum. Parameter tuning refers to finding these values.

7. Making Predictions
In the end, you can use your model on unseen data to make predictions accurately.

Deep learning
Deep learning is a type of machine learning that runs inputs through a biologically- inspired
neural network architecture. The neural networks contain a number of hidden layers through
which the data is processed, allowing the machine to go "deep" in its learning, making
connections and weighting input for the best results.
OR
Deep learning is a branch of machine learning which is completely based on artificial neural
networks, as neural network is going to mimic the human brain so deep learning is also a kind
of mimic of human brain. In deep learning, we don't need to explicitly program everything.
The concept of deep learning is not new.
Working

Advantages :
 Best in-class performance on problems.
 Reduces need for feature engineering.
 Eliminates unnecessary costs.
 Identifies defects easily that are difficult to detect.
Disadvantages :
 Large amount of data required.
 Computationally expensive to train.
 No strong theoretical foundation.
Applications :
1. Automatic Text Generation –
Corpus of text is learned and from this model new text is generated, word-by- word
or character-by-character.
Then this model is capable of learning how to spell, punctuate, form sentences, or it
may even capture the style.
2. Healthcare –
Helps in diagnosing various diseases and treating it.
3. Automatic Machine Translation –
Certain words, sentences or phrases in one language is transformed into another language
(Deep Learning is achieving top results in the areas of text, images).
4. Image Recognition –
Recognizes and identifies peoples and objects in images as well as to understand content
and context. This area is already being used in Gaming, Retail, Tourism, etc.
5. Predicting Earthquakes -
Teaches a computer to perform viscoelastic computations which are used in predicting
earthquakes.

Difference between Machine Learning and Deep Learning :

Machine Learning Deep Learning


Works on small amount of Dataset for accuracy. Works on Large amount of
Dataset.
Dependent on Low-end Machine. Heavily dependent on
High-end Machine.
Divides the tasks into sub-tasks, solves them Solves problem end to
individually and finally combine the results. end.
Takes less time to train. Takes longer time to train.
Testing time may increase. Less time to test the data.

"Artificial intelligence is a set of algorithms and intelligence to try to mimic human intelligence.
Machine learning is one of them, and deep learning is one of those machine learning techniques."
EXPERIMENT No: 9

Aim: Write a prolog program to perform arithmetic operations.

Algorithm:

Step1: Declare variable names in domains section.

Step2: Declare user defined predicates like add, sub, mul etc according to no. of operations required.

Step3: Define all the functors with predicates names.

Step4: Apply the operators on the

variables. Step5: End all the functors with

period.

Source Code: Source Code:

domains

NUM1,NUM2,ANSADD,ANSSUB,ANSMUL,ANSDIV=integer

predicates

add(integer,intege

r)

sub(integer,intege

r)

mul(integer,intege

r)

iv(integer,integer)

go

clauses
go:- clearwindow(),
write("Enter the number"),nl, write("

NUM1 = "),readint(NUM1), write(" NUM2

= "),readint(NUM2),

add(NUM1,NUM2),nl,

sub(NUM1,NUM2),nl,

mul(NUM1,NUM2),nl,
div(NUM1,NUM2).add(NUM1,NUM2):-

ANSADD=NUM1+NUM2,

write("The Sum is = ",ANSADD).

domains

NUM1,NUM2,ANSADD,ANSSUB,ANSMUL,ANSDIV=integer

predicates

add(integer,integer)

sub(integer,integer)

mul(integer,integer)

div(integer,integer)

go

clauses

go:- clearwindow(),

write("Enter the number"),nl, write("

NUM1 = "),readint(NUM1), write("

NUM2 = "),readint(NUM2),

add(NUM1,NUM2),nl,

sub(NUM1,NUM2),nl,

sub(NUM1,NUM2):-

ANSSUB=NUM1-

NUM2,

write("The sub is = ",ANSSUB).

mul(NUM1,NUM2):-

ANSMUL=NUM1*NUM

2,

write("The multiply is = ",ANSMUL).


div(NUM1,NUM2):-

ANSDIV=NUM1/NUM

2,

write("The division is = ",ANSDIV).

Test data:

NUM1=45

NUM2=9

Output:
EXPERIMENT No: 10

Aim: write a program to sense the available networks using Arduino


COMPONENTS REQUIRED:
1. WiFi Module or ESP 8266 Module.
2. Connecting cable or USB cable.
ALGORITHM:
STEP 1: Start the process.
STEP 2: Start ->Arduino IDE -1.8.8
STEP 3: Then enter the coding in Arduino Software. STEP 4:
Compile the coding in Arduino Software.
STEP 5: Connect the USB cable to WiFi module.
STEP 6: Select tools -> select board -> Module node Mch.0.9CE ESP
1.2 modules -> select port.
STEP 7: Upload the coding in ESP Module node Mch.0.9CE and open serial
monitor to view the available networks.
STEP 8: Stop the process.
CODING:
#include <ESP8266WiFi.h> void setup() {
Serial.begin(115200); WiFi.mode(WIFI_STA);
WiFi.disconnect(); delay(100);
Serial.println("Setup done");
}
void loop() { Serial.println("scan start"); int n
= WiFi.scanNetworks(); Serial.println("scan
done"); if (n == 0) {
Serial.println("no networks found");
} else { Serial.print(n);
Serial.println(" networks found"); for (int i = 0; i <
n; ++i) { Serial.print(i + 1);
Serial.print(": ");

Serial.print(WiFi.SSID(i)); Serial.print(" (");


Serial.print(WiFi.RSSI(i)); Serial.print(")");
Serial.println((WiFi.encryptionType(i) == ENC_TYPE_NONE) ? " " : "*");
delay(10);
}
}
Serial.println(""); delay(5000);
}
OUTPUT:

You might also like