Cs3691-Unit 4
Cs3691-Unit 4
UNIT-4
IOT COMMUNICATION AND OPEN PLATFORMS
PART-A
1)What is Raspberry Pi?
Raspberry Pi is a computer which is capable of doing all the operations like a conventional
computer. It has other features such as onboard WiFi, GPIO pins, and Bluetooth in order to
communicate with external things.
Raspberry Pi 1 Model B
Raspberry Pi 1 Model B+
Raspberry Pi 1 Model A
Raspberry Pi Zero
Raspberry Pi 3 Model B
Raspberry Pi 1model A+
Raspberry Pi Zero W
Raspberry Pi 2
Page | 1
CS3691-Embedded Systems and IOT Prepared by: E U Iniyan,AP/ECE
S
No. Arduino Raspberry Pi
Control unit of the Arduino is from The control unit of Raspberry Pi is from the ARM
2.
the Atmega family. family.
Arduino is based on a
3. While Raspberry Pi is based on a microprocessor.
microcontroller.
It is designed to control the electrical While Raspberry Pi computes data and produces
4. components connected to the circuit valuable outputs, and controls components in a
board in a system. system based on the outcome of its computation.
7. It uses very little RAM, 2 kB. While Raspberry Pi requires more RAM, 1 GB.
It has a higher I/O current drive While Raspberry Pi has a lower I/O current drive
10.
strength. strength.
11. It consumes about 200 MW of power. While it consumes about 700 MW of power.
Page | 2
CS3691-Embedded Systems and IOT Prepared by: E U Iniyan,AP/ECE
S
No. Arduino Raspberry Pi
13. It does not have internet support. It has inbuilt Ethernet port and WiFi support.
14. It has higher current drive strength. It has lower current drive strength.
Some of the applications of Arduino Some of the applications of Raspberry Pi are Stop
15. are traffic light countdown timer , motion cameras , Robot Controllers , Game
Weighing machines , etc. Servers.
17. Two tiny cores Arduino with 32 Mhz Single core and 700 MHz
This program gathers information from websites, devices, customers, and partners. It then triggers
actions for period responses.
Home a
Portable webserver
manipulating the robots
Internet radio
Page | 3
CS3691-Embedded Systems and IOT Prepared by: E U Iniyan,AP/ECE
Raspbian
Open ELEC (Open Embedded Linux Entertainment center)
RISC OS
Lakka
OSMC (Open Source Media Centre)
Windows IoT Core
It uses isolated systems of devices having the It uses integrated devices, applications, and data
same standards. across varying standards.
A cellular network or wired network is used for It uses an active Internet connection for device
device connectivity. connectivity.
Machines can communicate with one machine at Many machines can communicate with each other
a time. over the Internet.
Page | 4
CS3691-Embedded Systems and IOT Prepared by: E U Iniyan,AP/ECE
i)Wearables
iv)Beacons
16)Define Wi-Fi
Wifi is the short range Wireless communication technique. It is an alternative network to a wired
network which is commonly used to connect the devices in wireless mode.
Page | 5
CS3691-Embedded Systems and IOT Prepared by: E U Iniyan,AP/ECE
PART-B
IoT Communications APIs are a set of protocols and interfaces that allow IoT devices and
platforms to communicate with one another. Internet of Things Communications APIs
standardizes how IoT devices communicate with one another and with other systems. They enable
developers to design applications and services that can access and operate IoT devices without
worrying about underlying communication protocols and interfaces.
There are multiple benefits to adopting Internet of Things Communications APIs. One of the
primary benefits is that they give a standardized method of connecting with IoT devices, making
it simpler for developers to construct apps and services that work with many types of devices. This
can save developers a lot of time and effort because they don't have to establish specific
communication protocols for each device with which they want to interact.
Another benefit of adopting Communications APIs is that they might make the development
process easier. Developers can utilize high−level APIs that abstract away the specifics of
communication protocols and interfaces instead of writing low−level code to handle
communication with IoT devices. This can assist minimize the amount of code required and make
it easier to construct reliable and scalable systems.
IoT Communications APIs can also aid in the enhancement of security. APIs may ensure that
devices communicate securely and that data is encrypted and secured from unauthorized access by
offering a standardized communication method with IoT devices. This can aid in the prevention
of data breaches and other security issues.
Internet of Things Communications APIs are also built to be extremely scalable. As more devices
are added to an IoT system, the APIs can handle the increasing traffic while also ensuring that
device communication stays reliable and consistent.
Page | 6
CS3691-Embedded Systems and IOT Prepared by: E U Iniyan,AP/ECE
Another advantage of adopting communications APIs is that they make the building of IoT
applications easier. Developers can utilize pre−built APIs to connect their apps to IoT devices and
platforms, saving time and reducing development complexity.
Generally we used Two APIs For IoT Communication. These IoT Communication APIs are:
Page | 7
CS3691-Embedded Systems and IOT Prepared by: E U Iniyan,AP/ECE
A RESTful web service is a ” Web API ” implemented using HTTP and REST principles.
REST is most popular IoT Communication APIs.
Websocket APIs allow bi-directional, full duplex communication between clients and servers.
Websocket APIs follow the exclusive pair communication model. Unlike request-response model
such as REST, the WebSocket APIs allow full duplex communication and do not require new
coonection to be setup for each message to be sent. Websocket communication begins with a
connection setup request sent by the client to the server. The request (called websocket handshake)
is sent over HTTP and the server interprets it is an upgrade request. If the server supports
websocket protocol, the server responds to the websocket handshake response. After the
connection setup client and server can send data/mesages to each other in full duplex mode.
Websocket API reduce the network traffic and letency as there is no overhead for connection setup
and termination requests for each message. Websocket suitable for IoT applications that have low
latency or high throughput requirements. So Web socket is most suitable IoT Communication APIs
for IoT System.
Page | 8
CS3691-Embedded Systems and IOT Prepared by: E U Iniyan,AP/ECE
Bluetooth
Bluetooth is a short-range wireless communication network over a radio frequency. Bluetooth is
mostly integrated into smartphones and mobile devices. The Bluetooth communication network
works within 2.4 ISM band frequencies with data rate up to 3Mbps.
What is Bluetooth In IoT
Bluetooth has become a household name in the Internet of Things (IoT) community, offering more
than just hands-free calling and wireless audio. It is a serious technology that drives IoT
applications, providing fast and seamless device-to-device connections without relying on the
Internet. Since a device-to-device connection is expected to be fast, seamless, and wireless in the
Internet of Things, Bluetooth IoT is highly deployed because of its no-internet function on the one
hand and its capability to create large-scale device networks via Bluetooth mesh, on the other hand.
Bluetooth technology in IoT opens up numerous possibilities.
Bluetooth mesh IoT is a computer mesh networking system based on Bluetooth Low Energy
(BLE) that allows for many-to-many communication among connected devices over a Bluetooth
radio. In a Bluetooth mesh IoT network, every message has a source and destination address
through which devices publish messages to their destinations, which is a single thing, group of
things, or everything.
Bluetooth mesh IoT networking is a game-changer for wireless device networks. It is no surprise
that it sets a stage for a new wave of connectivity from whole-building networks to city-wide smart
services, especially in the present era of home, building, community, and industrial automation.
Page | 9
CS3691-Embedded Systems and IOT Prepared by: E U Iniyan,AP/ECE
Bluetooth Classic
Bluetooth Low Energy
Bluetooth SmartReady
The features of Bluetooth 5.0 version is introduced as Bluetooth 5 which have been developed
entirely for the Internet of Things.
Properties of Bluetooth network:
o Standard: Bluetooth 4.2
o Frequency: 2.4GHz
o Range: 50-150m
o Data transfer rates: 3Mbps
Page | 10
CS3691-Embedded Systems and IOT Prepared by: E U Iniyan,AP/ECE
ZigBee is a low power, low data rate wireless personal area network communication protocol. It
is mostly used in home automation and industrial settings. Since ZigBee is a low power
communication protocol, the IoT power devices used with ZigBee technology. The ZigBee
communication protocol is based on the IEEE 802.15.4 standard operating at the 2.4GHz
frequency. The ZigBee protocol supports star, cluster or wireless mesh technology topology.
o Zigbee Coordinator
o Zigbee End Device
o Zigbee Router
Page | 11
CS3691-Embedded Systems and IOT Prepared by: E U Iniyan,AP/ECE
Working of Wi-Fi:
Page | 12
CS3691-Embedded Systems and IOT Prepared by: E U Iniyan,AP/ECE
Like a mobile phone, a Wi-Fi network uses Radio Waves to send data across a network. The
computer should include a wireless adaptor that converts data transferred to a radio signal. The
identical signals deliver to a router decoder through an Antenna. After decoding, the data is sent
to the Internet over a connected Ethernet connection.
Because the wireless network is bidirectional, data from the Internet will also transit via the router
and coded into a radio signal that the computer's wireless adapter will receive.
Page | 13
CS3691-Embedded Systems and IOT Prepared by: E U Iniyan,AP/ECE
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.
Page | 14
CS3691-Embedded Systems and IOT Prepared by: E U Iniyan,AP/ECE
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.
Page | 15
CS3691-Embedded Systems and IOT Prepared by: E U Iniyan,AP/ECE
The main entities in an exclusive pair model are client and server. The client and server establish
a full duplex connection for sending and receiving data. Before sending a request, the client
establishes a connection with the server and then sends the request.
The data requests can be one or more. The server receives these requests through the same
connection and sends back responses. After the data transfer is complete, the connection between
the client and server is terminated. Unlike publish-subscribe model, exclusive pair model is
stateful. So, the server can automatically identify that the request is coming from a previous client
or not.
2. HDMI port
Raspberry Pi board has an HDMI or High Definition Multimedia Interface port that allows the
device to have video options of the output from the computer displayed. An HDMI cable
Page | 16
CS3691-Embedded Systems and IOT Prepared by: E U Iniyan,AP/ECE
connects the Raspberry Pi to an HDTV. The supported versions include 1.3 and 1.3. It also comes
with an RCA port for other display options.
4. Memory (RAM)
Random Access Memory is a core part of a computer’s processing system. It is where real-time
information is stored for easy access. The initial Raspberry Pi had 256MB RAM. Over the years,
developers gradually and significantly improved the size. Different Raspberry Pi models come
with varying capacities. The model with the maximum capacity presently is the Raspberry Pi 4
with 8GB RAM space.
5. Ethernet port
The Ethernet port is a connectivity hardware feature available on B models of Raspberry Pi. The
Ethernet port enables wired internet access to the minicomputer. Without it, software updates,
web surfing, etc., would not be possible using the Raspberry Pi. The Ethernet port found on
Raspberry computers uses the RJ45 Ethernet jack. With this component, Raspberry Pi can
connect to routers and other devices.
6. SD card slot
Like most other regular computers, Raspberry Pi must have some sort of storage device.
However, unlike conventional PCs, it does not come with a hard drive, nor does it come with a
memory card. The Raspberry Pi board has a Secure Digital card or SD card slot where users
must insert SD cards for the computer to function. The SD card functions like a hard drive as it
contains the operating system necessary for turning the system on. It also serves to store data.
Page | 17
CS3691-Embedded Systems and IOT Prepared by: E U Iniyan,AP/ECE
8. LEDs
These are a group of five light-emitting diodes. They signal the user on the present status of the
Raspberry Pi unit. Their function covers:
PWR (Red): This functions solely to indicate power status. When the unit is on, it emits a red
light and only goes off when the unit is switched off, or disconnected from the power source.
ACT (Green): This flashes to indicate any form of SD card activity.
LNK (Orange): LNK LED gives off an orange light to signify that active Ethernet connectivity
has been established.
100 (Orange): This light comes on during Ethernet connection when the data speed reaches
100Mbps.
FDX (Orange): FDX light also comes during Ethernet connection. It shows that the connection
is a full-duplex.
9. USB ports
Universal service bus (USB) ports are a principal part of Raspberry Pi. They allow the computer
to connect to a keyboard, mouse, hard drives, etc. The first model of Raspberry Pi had only two
USB 2.0 ports. Subsequent models increased this number to four. Raspberry Pi 4 and Pi 400,
much newer models, come with a mix of USB 2.0 and USB 3.0 ports.
Page | 18
CS3691-Embedded Systems and IOT Prepared by: E U Iniyan,AP/ECE
This simple circuit for detecting light consists of a relay activated by exposure to sunlight.
The photoresistor LDR and the resistor R1 make up a potential divider circuit. In the absence of
light, the LDR's resistance rises into the Megaohm (M) range, and as a result, the transistor TR1
receives zero base bias, turning the relay off. The LDR's resistance drops in response to more light,
elevating the base bias voltage at V1. When the base bias voltage of transistor TR1 reaches a
certain threshold, as defined by the resistance R1 in a potential divider network, the transistor turns
"ON," activating the relay, which controls some external circuitry. With a return to darkness, the
LDR's resistance rises, reducing the transistor's base voltage and turning "OFF" the transistor and
relay at a predetermined level of illumination established by the potentiometer circuit.
Changing the relay's "ON" or "OFF" point to a custom brightness is as simple as swapping out the
fixed resistor R1 for a potentiometer VR1. The switching end of a simple circuit like the one
depicted above may need to be more consistent owing to fluctuations in temperature or supply
voltage. Using the LDR in a "Wheatstone Bridge" configuration and substituting an Operational
Amplifier for the transistor makes it simple to construct a light-activated circuit with increased
sensitivity.
Circuit Diagram of LDR with Raspberry pi:
Page | 19
CS3691-Embedded Systems and IOT Prepared by: E U Iniyan,AP/ECE
GPIO.setmode(GPIO.BCM)
ldr_threshold = 1000
LDR_PIN = 18
LIGHT_PIN = 25
def readLDR(PIN):
reading = 0
GPIO.setup(LIGHT_PIN, GPIO.OUT)
Page | 20
CS3691-Embedded Systems and IOT Prepared by: E U Iniyan,AP/ECE
GPIO.output(PIN, false)
time.sleep(0.1)
GPIO.setup(PIN, GPIO.IN)
while (GPIO.input (PIN) ==Flase):
reading=reading+1
return reading
def switchOnLight(PIN):
GPIO.setup(PIN, GPIO.OUT)
GPIO.output(PIN, True)
def switchOffLight(PIN):
GPIO.setup(PIN, GPIO.OUT)
GPIO.output(PIN, False)
while True:
ldr_reading = readLDR(LDR_PIN)
if ldr_reading < ldr_threshold:
switchOnLight (LIGHT_PIN)
else:
switchOffLight(LIGHT_PIN)
time.sleep(1)
Page | 21