Professional Documents
Culture Documents
Iot 1-14
Iot 1-14
INTRODUCTION
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 externa 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 categoricalexamples
where IOT is strongly established.
There are four main components used in lot:
I. Low-power embedded systems: Less battery consumption, high performance are the inverse
tactorsthat 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 areliable storage server.
3. Availability of big data: We know that IOT relies heavily on sensors, especially in real time
4. Networking connection: In order to communicate, internet connectivity is a must where each
physical object is represented by an IP address.
1.2 CHARACTERISTICS OF IT
• simplex - in one direction only, with no provision for the receiving device to
sendinformation back to the transmitting device.
• full duplex - both devices send and receive at the same time)
Dept. of CSE, VKIT 2022-2023 Page 3
INTERNET OF THINGS
Receiver: All operations of the UART hardware are controlled by an internal clock
signal which runs at a multiple of the data rate, typically 8 or 16 times the bit rate. The
receiver tests the state of the incoming signal on each clock pulse, looking for the
beginning of the start bit. If the apparent start bit lasts at least one-half of the bit time,
it is valid and signals the start of a new character. If not, it is considered a spurious
pulse and is ignored. After waiting a further bit time, the state of the line is again
sampled and the resulting level clocked into a shift register. After the required number
of bit periods for the character length (5 to 8 bits, typically) have elapsed, the contents
of the shift register are made available (in parallel fashion) to the receiving system.
The UART will set a flag indicating new data is available, and may also generate a
processor interrupt to request that the host processor transfers the received data.
Communicating UARTs have no shared timing system apart from the communication
signal. Typically, UARTs resynchronize their internal clocks on each change of the
data line that is not considered a spurious pulse. Obtaining timing information in this
manner, they reliably receive when the transmitter is sending at a slightly different
speed than it should. Simplistic UARTs do not do this; instead they resynchronize on the
falling edge of the start bit only, and then read the centerof each expected data bit, and
this system works if the broadcast data rate is accurate enough to allow the stop bits to
be sampled reliably. It is a standard feature for a UART tostore the most recent
character while receiving the next. This "double buffering" gives a receiving computer
an entire character transmission time to fetch a received character. Many UARTs have a
small first-in, first-out (FIFO) buffer memory between the receiver shift register and the
host system interface. This allows the host processor even more timeto handle an
interrupt from the UART and prevents loss of received data at high rates.
Transmitter: Transmission operation is simpler as the timing does not have to be
determined from the line state, nor is it bound to any fixed timing intervals. As soon as
the sending system deposits a character in the shift register (after completion of the
previous character), the UART generates a start bit, shifts the required number of data
bits out to the line, generates and sends the parity bit (if used), and sends the stop bits.
Since full-duplex operation requires characters to be sent and received at the same
time, UARTS use two different shift registers for transmitted and received characters.
High performance UARTs
could contain a transmit FIFO (first in first out) buffer to allow a CPU or DMA
controller to deposit multiple characters in a burst into the FIFO rather than have to
deposit one character at a time into the shift register. Since transmission of a single or
multiple characters may take a long time relative to CPU speeds, a UART maintains a
flag showing busy status so that the host system knows if there is at least one character
in the transmit buffer or shift register: "ready for next character(s)" may also be
signaled with an interrupt.
Code:
void setup ()
{
// put your setup code here to run
onceSerial.begin(9600);
}
void loop (
{
//put your main code here to run repeatedly
Serial.println("HELLO WORLD");
delay (500);
}
Explanation:
• setup() and loop(): After creating a setup() function, which initializes and sets the
initial values, the loop() function does precisely what its name suggests, and loops
consecutively, allowing your program to change and respond. Use it to actively control
the Arduino board.
• serial.begin() and serial.println(): Serial begin is used to establish serial
communication. Serial communication is one way to allow devices to talk to each
other. Most often, you'll be using serial begin when you want to print something out to
your computer screen from your Arduino. This would also require the serial print
function.
• delay(): allows you to pause the execution of your Arduino program for a specified
period. For that purpose, the method requires you to supply it with a whole number
that specifies how many milliseconds the program should wait.
Output snapshot:
PROGRAM 2
Point-to-Point Communication: Two nodes directly communicating with each other without
any relay or compression of communication data are no longer the norm. While a simple
phone call can still be defined as a point-to-point communication, a VoIP call via. WhatsApp
or skype can technically be considered point to multipoint communication, as your data input
is first received by a cloud or gateway, which then encrypts and broadcasts your data to its
final destination. Understanding the meaning of point to point communication makes it easier
to understand the (oftentimes blurred, but fundamental) differences between M2M and IoT
networks In the context of telecommunication, a point to point communication (also known as
P2P) is an established connection between two nodes that can be used to communicate back
and forth. The most prominent example of point to point communication is a simple
telephone call, where one phone is connected with another, and both nodes can send and
receive audio. Early on in the advent of telecommunication, these P2P connections were
established using circuit-switched landlines. However, nowadays point to point
communication in modem networks is made possible by complex fiber-optic networks.
Different types of P2P connections can transmit different types of information, be it digital or
analog signals. A mote is a wireless transceiver that also acts as a remote sensor. The ability
to log onto a network from a distant location. Generally, this implies a computer, a modem,
and some remote access software to connect to the network.
Radio Frequency (RF): Radio frequency (RF) is the oscillation rate of an alternating electric
current or voltage or of a magnetic, electric or electromagnetic field or mechanical system in
the frequency range from around 20 kHz to around 300 GHz. This is roughly between the
upper limit of audio frequencies and the lower limit of infrared frequencies; these are the
frequencies at which energy from an oscillating current can radiate off a conductor into space
as radio waves. Different sources specify different upper and lower bounds for the frequency
range. Medical applications of radio frequency (RF) energy, in the form of electromagnetic
waves (radio waves) or electrical currents, have existed for over 125 years, and now include
diathermy, hyperthermy treatment of cancer, electrosurgery scalpels used to cut and cauterize
in operations, and radiofrequency
ablation. Magnetic resonance imaging (MRI) uses radio frequency waves to generate images
of the human body. Radio frequencies are used in communication devices such as
transmitters, receivers, computers, televisions, and mobile phones, to name a few. Radio
frequencies are also applied in carrier current systems including telephony and control
circuits. The MOS integrated circuit is the technology behind the current proliferation of
radio frequency wirelesstelecommunications devices such as cellphones.
Code:
Sender--
//HC-12 messenger send/receive
#include
SoftwareSerialmy Serial (2,3);
//RXTX void setup ()
{
Serial.begin(9600);
my
Serial.begin(9600);
}
void loop()
{
If (Serial.available() > 0)
{
//Read from serial monitor and send over
HC-12String input = Serial.readString();
mySerial.println(input);
}
if(my Serial.available() > 1)
{
//Read from HC-12and
String input=mySerial.readString();
Serial.println(input);
}
delay(20);
}
Receiver
//HC-12 messenger send/receive
#include
SoftwareSerialmy Serial(2, 3);
//RX, TX void setup() {
Serial.begin(9600);
mySerial.begin(9600);
}
void loop () {
if (Serial.available() > 0){//Read from
serialmonitorandsend over HC-12
String input = Serial readString();
mySerial.println(input);
Dept. of CSE, VKIT 2022-2023 Page 9
INTERNET OF THINGS
Explanation:
• setup() and loop(): After creating a setup() function, which initializes and sets the
initial values, the loop() function does precisely what its name suggests, and loops
consecutively, allowing your program to change and respond. Use it to actively control
the Arduino board.
• serial.begin() and serial.println(): Serial begin is used to establish serial
communication. Serial communication is one way to allow devices to talk to each
other. Most often, you'll be using serial begin when you want to print something out to
your computer screen from your Arduino. This would also require the serial print
function.
• delay(): allows you to pause the execution of your Arduino program for a specified
period. For that purpose, the method requires you to supply it with a whole number
that specifies how many milliseconds the program should wait.
• SoftwareSerial Header: The SoftwareSerial library allows serial communication on
other digital pins of an Arduino board, using software to replicate the functionality
(hence the name "SoftwareSerial"). It is possible to have multiple software serial ports
with speeds up to 115200 bps. A parameter enables inverted signaling for devices
which require that protocol. Serial.available(): Get the number of bytes (characters)
available for reading from the serial port. This is data that's already arrived and stored
in the serial receive buffer (which holds 64 bytes). Serial.available() inherits from the
Stream utility class.
• Serial.readString(): It reads characters from the serial buffer into a String. The
function terminates if it times out (see setTimeout()). Serial.readString() inherits from
the Stream utility class.
Output:
PROGRAM 3
MULTI-POINT TO SINGLEPOINTCOMMUNICATION
OF MOTES OVER THERADIO FREQUENCY
Point-to-multipoint is the most popular approach for wireless communications that have a
large number of nodes, end destinations or end users. Point to Multipoint generally assumes
there is a central base station to which remote subscriber units or customer premises
equipment (CPE) (a term that was originally used in the wired telephone industry) are
connected over the wireless medium. Connections between the base station and subscriber
units can be either line-of sight or, for lower-frequency radio systems, non-line-of-sight where
link budgets permit. Generally, lower frequencies can offer non- line-of-sight connections.
Various software planning tools can be used to determine feasibility of potential connections
using topographic data as well as link budget simulation. Often the point to multipoint links
are installed to reduce the cost of infrastructure and increase the number of CPE's and
connectivity. The telecommunications signal in a point-to- multipoint system is typically bi-
directional, TDMA or channelized. Systems using frequency- division duplexing (FDD) offer
full- duplex connections between base station and remote sites, and time-division duplex
(TDD) systems offer half-duplex connections.
The base station may have a single omnidirectional antenna or multiple sector antennas, the
latter of which allowing greater range and capacity. The most common network type in which
backhaul is implemented is a mobile network. A backhaul of a mobile network, also referred
to as mobile-
backhaul connects a cell site towards the core network. The two main methods of mobile
backhaul implementations are fiber-based backhaul and wireless point-to-point backhaul. [2]
Other methods, such as copper-based wireline, satellite communications and point- to-
multipoint wireless technologies are being phased out as capacity and latency requirements
become higher in4G and 5G networks.
In both the technical and commercial definitions, backhaul generally refers to the side of the
network that communicates with the global Internet, paid for at wholesale commercial access
rates to or at an Internet exchange point or other core network access location. Sometimes
middle mile networks exist between the customer's own LAN and those exchanges. This can
be a local WAN connection. Cell phones communicating with a single cell tower constitute a
local subnetwork; the connection between the cell tower and the rest of the world begins with a
backhaul link to the core of the internet service provider's network (via a point of presence). A
backhaul may include wired, fiber optic and wireless components. Wireless sections may
include using microwave bands and mesh and edge network topologies that may use a high-
capacity wireless channel to get packets tothe microwave or fiber links.
Radio Frequency (RF): Radio frequency (RF) is the oscillation rate of an alternating electric
current or voltage or of a magnetic, electric or electromagnetic field or mechanical system in
the frequency range from around 20 kHz to around 300 GHz. This is roughly between the
upper limit of audio frequencies and the lower limit of infrared frequencies; these are the
frequencies at which energy from an oscillating current can radiate off a conductor into space
as radio waves. Different sources specify different upper and lower bounds for the frequency
range. Medical applications of radio frequency (RF) energy, in the form of electromagnetic
waves (radio waves) or electrical currents, have existed for over 125 years, and now include
diathermy, hyperthermy treatment of cancer, electrosurgery scalpels used to cut and cauterize
in operations, and radiofrequencyablation. Magnetic resonance imaging (MRI) uses radio
frequency waves to generate images of the human body. Radio frequencies are used in
communication devices such as transmitters, receivers, computers, televisions, and mobile
phones, to name a few. Radio frequencies are also applied in carrier current systems including
telephony and control circuits. The MOS integrated circuit is the technology behind the current
proliferation of radio frequency wireless telecommunications devices such as cellphones.
Code:
Wire.begin();
Serial.begin(96
00);while
(!Serial);
monitorSerial.println("\nI2C Scanner");
}
void loop0
{
byte error
address;int
nDevices;
Serial.println("Scanning...");
nDevices = 0;
for (address=1; address<127; address++)
{
Wire.beginTransmission(addre
ss);error =
Wire.endTransmission();
if(error == 0)
{
Serial.print("I2C device
found ataddress Ox")
if(address<1
6)
Serial.print("
0");
Serial.print(address,HE
X);Serial.println("!");
nDevices++; }
else if
(error=
=4)
{
Serial.print("Unkown error address
0x");if(address<16)
Serial.print("0");
Serial.println(address,HE
X);
}}
if(nDevices==0)
Serial.println("No 12C devices
found\n");Else
Serial.println("done\n");
delay(5000); //wait 5 seconds for next scan
}
Explanation:
• setup() and loop(): After creating a setup() function, which initializes and sets the
initialvalues, the loop() function does properly what its name suggests, and loops
consecutively, allowing your program to change and respond. Use it to actively
control the Arduino board.
• delay(): allows you to pause the execution of your Arduino program for a specified
period. For that purpose, the method requires you to supply it with a whole number
thatspecifies how many milliseconds the program should wait.
• serial.begin() and serial.println(): Serial begin is used to establish serial
communication. Serial communication is one way to allow devices to talk to each
other.Most often, you'll be using serial begin when you want to print something out
to your computer screen from your Arduino. This would also require the serial print
function.
• wire header: This library allows you to communicate with I2C/TWI devices. On the
Arduino boards with the R3 layout (1.0 pinout), the SDA (data line) and SCL (clock
line)are on the pin headers close to the AREF pin. The Arduino Due has two
I2C/TWI interfaces SDA1 and SCL1 are near to the AREF pin and the additional one
is on pins 20
Dept. of CSE, VKIT 2022-2023 Page 17
INTERNET OF THINGS
and 21.
• beginTransmission(): This function begins a transmission to the 12C peripheral
devicewith the given address. Subsequently, queue bytes for transmission with the
write() function and transmit them by calling endTransmission().
• end Transmission(): This function ends a transmission to a peripheral device that
was begun by beginTransmission() and transmits the bytes that were queued by
write(). As ofArduino 1.0.1, endTransmission() accepts a boolean argument changing
its behavior for compatibility with certain I2C devices. If true, endTransmission()
sends a stop message after transmission, releasing the 12C bus. If false,
endTransmission() sends a restart message after transmission. The bus will not be
released, which prevents another controller device from transmitting between
messages. This allows one controller deviceto send multiple transmissions while in
control. The default value is true.
• Error address: A target address is written to a memory in an electronic system
and subsequently output on an address path through which the memory is
addressable. Anaddressing error is detected by determining whether the target
address output on the address path is detected at the memory.
Output Snapshot:
PROGRAM 4
12C PROTOCOL
STUDY
12C stands for Inter-Integrated Circuit. It is a bus interface connection protocol incorporated
into devices for serial communication. It was originally designed by Philips Semiconductor in
1982. Recently, it is a widely used protocol for short-distance communication. It is also
known as Two Wired Interface (TWI).
Working of I2C Communication Protocol: It uses only 2 bi-directional open-drain lines for
datacommunication called SDA and SCL. Both these lines are pulled high.
• Serial Data (SDA) - Transfer of data takes place through this pin.
• Serial Clock (SCL) - It carries the clock
signal.12C operates in 2 modes -
• Master mode
• Slave mode
Each data bit transferred on SDA line is synchronized by a high to the low pulse of each
clock onthe SCL line.
According to I2C protocols, the data line cannot change when the clock line is high, it can
change only when the clock line is low. The 2 lines are open drain, hence a pull-up resistor is
required so that the lines are high since the devices on the 12C bus are active low. The data is
transmitted in
Dept. of CSE, VKIT 2022-2023 Page 19
INTERNET OF THINGS
Read/Write Bit:
A high Read/Write bit indicates that the master is sending the data to the slave, whereas a low
Read/Write bit indicates that the master is receiving data from the slave.
ACK/NACK Bit:
After every data frame, follows an ACK/NACK bit. If the data frame is received successfully
thenACK bit is sent to the sender by the receiver.
Addressing:
The address frame is the first frame after the start bit. The address of the slave with which the
master wants to communicate is sent by the master to every slave connected with it. The slave
thencompares its own address with this address and sends ACK.
Code:
#include
int ADXLAddress = 0x3C;
#define X_Axis_Register_DATAX0 0X0D
#define X_Axis_Register_DATAXI 0x0E
#define X_Axis_Register_DATAX0 0X0D
#define Y_Axis_Register_DATAX1 0x0E
#define Z_Axis_Register_DATAX2 0x0F
#define X_Axis_Register_DATAX1 0x0E
#define Power_Register 0x2D
X0,X1,X2,X_out;void setup()
{
Wire.begin();
Serial.begin(96
00);
delay(5000);
Wire.beginTransmission (A
DXLAddress);
Wire.write(Power_Register);
(00001000)
Wire.write(8);
Dept. of CSE, VKIT 2022-2023 Page 21
Wire.endTransmission
();}
INTERNET OF THINGS
void loop()
{
Wire.beginTransmission(ADXLAddre
ss);
Wire.write(X_Axis_Register_DATA
X0);
Wire.write(Y_Axis_Register_DATA
XI);
Wire.write(Z_Axis_Register_DATA
X2);
Wire.endTransmission();
Wire.requestFrom(ADXLAddress
,3);if(Wire.available()<=3)
{
XO=Wire.read();
registerX1=Wire.rea
d();X2
Wire.read();}
Serial.print("X0=");
Serial.print(X0);
Serial.print("X1=");
Serial.println(X1);
Serial.print("X2=");
Serial.println(X2);
}
Explanation:
setup() and loop(): After creating a setup() function, which initializes and sets the initial
values, the loop() function does precisely what its name suggests, and loop consecutively,
allowing your program to change and respond. Use it to actively control the Arduino board.
delay(): allows you to pause the execution of your Arduino program for a specified period.
For
Dept.that purpose,
of CSE, VKIT the method requires you to2022-2023
supply it with a whole number that specifies
Page 22
how many milliseconds the program should wait.
INTERNET OF THINGS
serial.begin() and serial.println(): Serial begin is used to establish serial communications.
Serial communication is one way to allow devices to talk to each other. Most often, you'll be
using serial
begin when you want to print something out to your computer screen from your Arduino.
This would also require the serial print function.
wire header: This library allows you to communicate with I2C/TWI devices. On the Arduino
boards with the R3 layout (1.0 pinout), the SDA (data line) and SCL (clock line) are on the
pin headers close to the AREF pin. The Arduino Due has two I2C/TWI interfaces SDA1 and
SCL1 are near to the AREF pin and the additional one is on pins 20 and 21.
begin Transmission(): This function begins a transmission to the I2C peripheral device with
the given address. Subsequently, queue bytes for transmission with the write() function and
transmit them by calling endTransmission().
end Transmission(): This function ends a transmission to a peripheral device that was begun
by beginTransmission() and transmits the bytes that were queued by write(). As of Arduino
1.0.1, endTransmission() accepts a boolean argument changing its behavior for compatibility
with certain I2C devices. If true, endTransmission() sends a stop message after transmission,
releasing the I2C bus. If false, end Transmission() sends a restart message after transmission.
The bus will not be released, which prevents another controller device from transmitting
between messages. This allows one controller device to send multiple transmissions while in
control. The default value is true.
Output of Snapshot:
PROGRAM 5
Temperature: It is a physical quantity that expresses hot and cold or a measure of the
average kinetic energy of the atoms or molecules in the system. It is the manifestation of
thermal energy, present in all matter, which is the source of the occurrence of heat, the flow of
energy from a hotter body in contact with a colder body. Temperature is measured with a
thermometer, are calibrated in various temperature scales that historically have used various
reference points and thermometric substances for definition. The most common scales are the
Celsius scale (formerly called "centigrade", denoted as °C), the Fahrenheit scale (denoted as
°F), and the Kelvin scale (denoted as K), the last of which is predominantly used for scientific
purposes by conventions of the International System of Units (SI). The lowest theoretical
temperature is absolute zero, at which no more thermal energy can be extracted from a body.
Experimentally, it can only be approached very closely (100 pK), but not reached, which is
recognized in the third law of thermodynamics.
Relative Humidity: Relative humidity of air is defined as the ratio of the vapor pressure of
air to its saturation vapor pressure. The equilibrium relative humidity (ERH) of a food product
is defined as relative humidity of the air surrounding the food that is in equilibrium with its
environment. When the equilibrium is obtained, the ERH (in percent) is equal to the water
activity multiplied by 100, i.e. ERH (%) = aw 100. When a food is exposed to a constant
humidity, the product will gain or lose moisture until the ERH is reached. The moisture
migration significantly affects the physical and chemical properties of the food, as previously
described.
Working of temperature and humidity sensor: Temperature and humidity sensors have
two different ways of collecting data and measuring humidity and temperature. One type
measure Relative Humidity (also known as RH) and the other type measures Absolute
Humidity (also known as AH) smaller purposes and larger ones are usually used for industrial
applications. Some of these sensors are interfaced with a micro-controller for measuring the
related data instantaneously. For example, the DHT11 temperature and humidity sensor is
one of these digital temperature and humidity sensor with Arduino as its interface. It can also
Dept.other
use of CSE, VKITcontrollers such as Raspberry2022-2023
micro- Page 25
Pi, etc. These sensors have capacitive humidity
sensing elements as
INTERNET OF THINGS
well as a thermistor which is used to sense the environment's temperature. There are two
electrodes in the humidity sensing element (capacitor) and a moisture holding substrate works
as a dielectric between these two electrodes. Whenever there is a change in the humidity
levels, changes occur to the capacitance value accordingly. There's an integrated IC in the unit
that receives the measured data and processes the resistance values that have been changed
due to the change in humidity, and converts the data into a digital form for the readers. So,
this is how digital temperature and humidity sensors such as DHT11 measure humidity.
The easiest explanation would be that these sensors use a negative temperature coefficient
thermistor for measuring temperature. When there's an increase in the temperature of the
environment, this element would cause a decrease in its resistance value. Moreover, some
temperature and humidity sensors with display have been designed which provide visual
reporting of the humidity and the temperature and create a better experience for those using
such sensors. Some of the newer temperature and humidity sensors with Wi-Fi have become
popular these days as well that connects over Wi-Fi (or Bluetooth) enabling you to remotely
monitor the humidity and the temperature of the place you've placed the sensor in with the
help of an app that you can install on your phone. These sensors are great for when you are
away and need to monitor the temperature and the humidity of the place. They have pretty
good accuracy too.
Humidity and Sensor applications: As we mentioned above, these sensors can be found in
many devices and they have a wide variety of applications! They can even help the patients
who have trouble breathing by enabling them to keep the humidity and the temperature of the
place at the optimum level. To predict weather conditions, weather stations use these sensors
too. They can be used in heating systems, ventilation systems and even air conditioning
systems. These sensors can also be used for greenhouses where the humidity values should be
checked constantly. Museums can benefit from them as well since the artifacts and the
objects in these places should be kept under certain conditions.
Code:
#includ
e dht
DHT;
#define
DHT11_PIN 7void
Dept. of CSE, VKIT 2022-2023 Page 26
setup()
INTERNET OF THINGS
{
Serial.begin(96
00);void loop()
{
int chk-DHT.read11
(DHT11_PIN);
Serial.print("Temperature = ");
Serial.println(DHT.temperature)
; Serial.print("Humidity = ");
Serial.println(DHT.hmidity);
delay(1000);
Explanation:
setup() and loop(): After creating a setup() function, which initializes and sets the initial
values,the loop() function does precisely what its name suggests, and loops consecutively,
allowing your program to change and respond. Use it to actively control the Arduino board.
delay(): allows you to pause the execution of your Arduino program for a specified period.
For that purpose, the method requires you to supply it with a whole number that specifies
how manymilliseconds the program should wait.
DHT header: It has all the functions needed to get the humidity and temperature readings
fromthe sensor.
Output Snapshot: