You are on page 1of 23

Internet of Things

MODULE – 5

1) Introduction to Arduino
 Arduino is an open-source electronics platform based on easy-to-use hardware
and software.
 Arduino is a basic single board microcontroller designed to make applications,
interactive controls, or environments easily adaptive.

 Introduced in 2005 the Arduino platform was designed to provide a cheaper way
for students and professionals to create applications that play in the human
interface world using sensors, actuators, motors, and other rudimentary
products.

 It offers a simple integrated IDE (integrated development environment) that runs


on regular personal computers and allows users to write programs for Arduino
using C or C++.
 Arduino boards are able to read inputs-light on a sensor, a finger on a button, or a
Twitter message-and turn it into an output-activating a motor, turning on an LED,
publishing something online.

Arduino UNO:
 Arduino Uno is a microcontroller board based on the ATmega328P.
 It has 14 digital input/output pins (of which 6 can be used as PWM outputs),6
analog inputs, a 16MHz quartz crystal, a USB connection, a power jack, an ICSP
header and a reset button.

 Connect it to a computer with a USB cable or power it with a AC to DC adapter or


battery to get started

 "Uno" means one in Italian and was chosen to mark the release of Arduino
Software (IDE) 1.0. The Uno board and version 1.0 of Arduino Software (IDE) were
the reference versions of Arduino, now evolved to newer releases.

Page 1
Internet of Things

 Exploring Arduino UNO board

 Installing the Software (Arduino IDE)


 The Arduino Software (IDE) allows you to write programs and upload them
to board In the Arduino Software page you will find two options;

Page 2
Internet of Things

 Online IDE (Arduino Web Editor) It will allow to save sketches in the
cloud, having them available from any device and backed up.
 Offline should use the latest version of the desktop IDE.
 Install the Arduino Desktop IDE accordingly to operating system
• Windows
• Mac OS X
• Linux
• Portable IDE (Windows and Linux)
 Connecting Arduino UNO Learning Board
 If you want to program your Arduino Uno while offline you need to
install the Arduino Desktop IDE.
 Connect your Uno board with an A B USB cable sometimes this cable
is called a USB printer cable.
 If you used the Installer, Windows from XP up to 10 will install drivers
automatically as soon as you connect your board.

 Fundamentals of Arduino Programming


 The Arduino IDE supports the languages C and C++ using special rules
of code structuring.
 The Arduino IDE supplies a software library from the Wiring project,
which provides many common input and output procedures.

 User written code only requires two basic functions, for starting the
sketch and the main program loop, that are compiled and linked with
a program stub main() into an executable cyclic executive program
with the GNU toolchain, also included with the IDE distribution.

 Sketch

o A sketch is a program written with the Arduino IDE 57 Sketches


are saved on the development computer as text files with the
file extension ".ino" .
o A minimal Arduino C/C++ program consist of only two
functions;
Page 3
Internet of Things

 setup() - This function is called once when a sketch starts


after power up or reset. It is used to initialize variables,
input and output pin modes, and other libraries needed
in the sketch.
 loop() - After setup() function exits, the loop() function
is executed repeatedly in the main program. It controls
the board until the board is powered off or is reset.
 Variables and Data Types

 if and if ..else Statement

if (expression)
{
statement;

Page 4
Internet of Things

if (expression)
{
do_this;
}
else
{
do_that;
}
 while Loop
while (button == false)
{
button = check_status (pin4);
}
 Digital I/O
• pinMode()
• digitalRead()
• digitalWrite()
pinMode()
o Before using a pin as a digital input or output, must first
configure the pin, which is done with pinMode().
o pinMode (pin, mode)
o The pin parameter is simply the digital pin number want to
set.
o The mode parameter is one of three constants INPUT or
OUTPUT.
digitalRead()
o In order to read the state of a digital pin, you must use
digitalRead();
result = digitalRead (pin);
o The pin parameter is the pin number you want to read
from.

Page 5
Internet of Things

o This function returns either HIGH or LOW, depending on


the input.

digitalWrite()
o To write the state of a pin that was declared as an OUTPUT,
use the digitalWrite() function.
digitalWrite ( pin,value);
o The pin parameter is the pin number you want to write to,
and the value is the logical level you want to write; HIGH or
LOW.
 Time Functions
o delay() - tells the microcontroller to wait for a specified
number of milliseconds before resuming the sketch.
o millis() - returns the number of milliseconds that the sketch
has been running, returning the number as an unsigned
long.
 Mathematical Functions
o min() - returns the smaller of two numbers.
o max() - returns the higher of two values.

o random() - Arduinos are capable of generating pseudo random


numbers using the random() function.

2) Introduction to Raspberry Pi
 The Raspberry Pi is a series of credit card sized single-board computers developed
in the United Kingdom by the Raspberry Pi foundation to promote the teaching of
basic computer science in schools and developing countries.
 The Raspberry Pi was launched in the year 2012, and there have been several
iterations and variations released since then.

 The original Pi had a single-core 700 MHz CPU and just 256MB RAM and the latest
model has a quad-core 1.4 GHz CPU with 1GB RAM.

Page 6
Internet of Things

 The main price point for Raspberry Pi has always been $35 or less, including Pi
Zero which costs just $5.

 Secure Digital(SD) cards are used to store the operating system and program
memory in either in SDHC or MicroSDHC sizes.

 Most boards have between one and four USB slots, HDMI and composite video
output and a 3.5 mm phone jack for audio.

 Exploring The Raspberry Pi Learning Board

 Processor
The Broadcom BCM2835 SoC used in the first generation Raspberry Pi is
somewhat similar to the chip used in first generation smart phones, which
includes a 700 MHz ARM processor, Video Core IV graphics processing
unit(GPU) and RAM.
 Power Source
 The recommended and easiest way to power the Raspberry Pi is via
the MicroUSB port on the side of the unit.
 The recommended input voltage is 5V, and the recommended input
current is 2A.
 SD Card
The Raspberry Pi does not have any locally available storage accessible.

Page 7
Internet of Things

The working framework is stacked on a SD card which is embedded on the


SD card space on the Raspberry Pi.

 GPIO(General Purpose Input Output)


General-purpose input/output(GPIO) is a non-specific pins on a coordinated
circuit to know is an input or output pin which can be controlled by the
client at run time.
 DSI Display X
The Raspberry Pi connector S2 is a display serial interface(DSI) for
connecting a liquid crystal display(LCD) panel using a 15-pin ribbon cable.

 Audio Jack
A standard 3.5 mm TRS connector is accessible on the Rpi for stereo sound
yield.
 Status LEDs
There are 5 status LEDs on the Rpi that demonstrate the status of different
exercises as takes after:
 OK – SD card access(by means of GPIO16)
 POWER-3.3 V Power-named as “PWR” on all boards
 FDX – Full Duplex(LAN) - marked as “FDX” on all boards
 LNK – Link/Activity(LAN) – marked as “LNK” on all boards
 10M/100 – 10/100Mbit(LAN) – named(errorneously) as “10M” on
Model B Rev 1.0 boards and “100” on Model B Rev 2.0 and Model A
boards USB Ports.

 Ethernet Port
It can be associated with a system or web utilizing a standard LAN link on
the Ethernet port.
 CSI Connector(CSI)
Camera Serial Interface is a serial interface outlined by MIPI(Mobile
Industry Processor Interface) organization which can be used for interfacing
the computerized cameras with a portable processor.
 JTAG headers

Page 8
Internet of Things

JTAG is a standardised interface for debugging integrated circuits which can


be used to debug the Raspberry Pi.
 HDMI
High Definition Multimedia Interface to give both video and sound yield.
 Hardware Layout

 raspi-config
•The Raspberry Pi configuration tool in Raspbian, allowing you to easily
enable features such as the camera, and to change your specific settings
such as keyboard layout.

 config.txt
•The Raspberry Pi configuration file

 Wireless networking
•Configuring your Pi to connect to a wireless network using the Raspberry
Pi 3's or Pi Zero W's inbuilt wireless connectivity, or a USB wireless dongle

 Wireless access point


•Configuring your Pi as a wireless access point using the Raspberry Pi 3
and Pi Zero W's inbuilt wireless connectivity, or a USB wireless dongle

 Using a proxy
•Setting up your Pi to access the internet via a proxy server

 HDMI Config
•Guide to setting up your HDMI device, including custom settings

 Audio config
•Switch your audio output between HDMI and the 3.5mm jack

 Camera config
•Installing and setting up the Raspberry Pi camera board

 External storage config


•Mounting and setting up external storage on a Raspberry Pi

Page 9
Internet of Things

 Localisation
•Setting up your Pi to work in your local language/time zone

 Default pin configuration


•Changing the default pin states.

 Device Trees config


•Device Trees, overlays, and parameters

 Kernel command line


•How to set options in the kernel command line

 UART configuration
•How to set up the on-board UARTS.

 Firmware warning icons


•Description of warning icons displayed if the firmware detects issues

 LED warning flash codes


•Description of the meaning of LED warning flashes that are shown if a Pi
fails to boot or has to shut down

 Securing your Raspberry Pi


•Some basic advice for making your Raspberry Pi more secure

 Screensaver
•How to configure screen blanking/screen saver

 The boot folder


•What it's for and what's in it

 Operating Systems on Raspberry Pi:


 Various operating systems can be installed on Raspberry Pi through SD
cards.

Page 10
Internet of Things

 Most use a MicroSD slot located on the bottom of the board. The Raspberry
Pi primarily uses Raspbian, a Debian-based Linux operating system.

 Other third party operating systems available via the official website
include Ubuntu MATE, Snappy Ubuntu Core, Windows 10 IoT Core, RISC OS
and other specialized distributions.

 You have a few options when it comes to interacting with the Raspberry Pi.
The first and most common is to use it like you would a full desktop
computer (just smaller). This involves connecting a keyboard, mouse, and
monitor. With this setup, you are likely best served by installing Raspbian
with Desktop, which gives you a full graphical user interface(GUI) to work
with. This is the best option if you want an experience similar to working
with other operating systems (OS), such as Windows, macOS, or other
popular Linux flavors, like Ubuntu.

 Programming Raspberry Pi with Python:

 Raspberry Pi runs Linux and supports python out of the box. Hence any
python program can be run that normally runs on a computer.

 The Raspberry Pi is an amazing single board computer (SBC) capable of


running Linux and a whole host of applications. Python is a beginner-
friendly programming language that is used in schools, web development,
scientific research, and in many other industries.

 Wireless Temperature Monitoring System Using Pi

 Raspberry Pi has an inbuilt Wi-Fi module, which makes it suitable for IoT
applications.
 Temperature monitoring system works by measuring the temperature in
real-time by using LM35 as a temperature sensor.

 The temperature values are pushed into the backend cloud server. The
most preferred backend cloud server is the ThingsSpeak.

Page 11
Internet of Things

 ThingsSpeak cloud is suitable to view the sensor logs in the form of graph
plots and in this monitoring system one field to monitor the temperature
value is created.

 This can be reconfigured to monitor a number of sensor values in various


fields.

 DS18B20 Temperature Sensor


 The DS18B20 is a 1-wire programmable temperature sensor from maxim
integrated.
 It is widely used to measure temperature in hard environments like in
chemical solutions, mines or soil etc.

 The constriction of the sensor is rugged and also can be purchased with a
waterproof option making the mounting process easy.

 It can measure a wide range of temperature from-55°C to +125°with a


decent accuracy of±5°C.

 Each sensor has a unique address and requires only one pin of the MCU to
transfer data so it a very good choice for measuring temperature at
multiple points without compromising much of your digital pins on the
microcontroller.

 Connecting Raspberry Pi via SSH

 The SSH(Secure Shell) can be used to access the command line of a


Raspberry Pi remotely from another computer or device on the same
network.

 The Raspberry Pi will act as a remote device – one can connect to it using a
client on another machine.

 The steps to connect Raspberry Pi via SSH are as follows;

1. Set up your local network and wireless connectivity


2. Enable SSH

Page 12
Internet of Things

3. Enable SSH on a headless Raspberry Pi (add file to SD card on another


machine)
4. Set up your client

 Accessing Temperature from DS18B20 sensors


 The DS18B20 is a digital thermometer that allows to get 9-bit to 12-bit
Celsius temperature measurements (programmable resolution).
 The temperature conversion time depends on the resolution used. For a 9-
bit resolution it takes at most 93.75 ms and for a 12-bit resolution it takes
at most 750 ms.

 The device is able to measure temperatures from -55°C to +125°C and has a
±0.5°C accuracy in the range from -10°C to +85°C.

 Additionally, it has an alarm functionality with programmable upper and


lower temperature trigger points.

 These thresholds are stored internally in non-volatile memory, which


means they are kept even if the device is powered off .

 The sensor communicates using the OneWire protocol, which means it only
requires a pin from a microcontroller to be connected to it.

 Furthermore, each sensor has a unique 64-bit serial code, allowing multiple
DS18B20 devices to function on the same OneWire bus.

 In terms of power supply, the device can operate with a voltage between
3.0 V and 5.5 V, which means it can operate with the same voltage of the
ESP32 without the need for level conversion.

3) Smart & Connected Cities – An IoT Strategy for Smarter Cities


 As the need for efficiency increases, new tools help increase operational
efficiency.
 For cities, just as for businesses, digitization transforms the perspective on
operations.
Page 13
Internet of Things

 Scalable solutions utilizing information and communications technology (ICT) can


alleviate many issues urban centers face today by increasing efficiency, which
reduces costs and enhances quality of life.

 Cities that take this approach are commonly referred to as smart cities.
Vertical IoT Needs for Smarter Cities

 There are many differing approaches and solutions for city management. All these
solutions typically start at the street level, with sensors that capture data on
everything from parking space availability to water purity.
 Citizens can use tools to leverage their smart mobile devices, such as to report
problems and make recommendations for improving urban life or locate available
parking spaces.

 Information and communications technology connects people, data, things, and


processes together in networks of billions or even trillions of connections.

 IoT expects to have the following economic impact over a 10-year period;

1) Smart buildings
2) Gas monitoring
3) Smart parking
4) Water management
5) Road pricing

Global vs. Siloed Strategies


 The main obstacle in implementing smart solutions in today’s traditional
infrastructure is the complexity of how cities are operated, financed, regulated,
and planned.
 Cities attempting to upgrade their infrastructure to match the growing needs of
the citizen population often invest in one problem at a time, and they do it
independently.

 Even cities using IoT technology break up city assets and service management into
silos that are typically unable to communicate or rely on each other.

Page 14
Internet of Things

 Cities need to begin with a solution that can extend systems across vendors,
technologies, and data types, and they should approach their infrastructure
investment with a horizontal solution that addresses their issues cohesively.

 City issues are typically large-scale. They require collection of large amounts of
diverse data sets in real time.

4) Smart City IOT Architecture


 A smart city IoT infrastructure is a four-layered architecture, as shown in
Figure;

 Data flows from devices at the street layer to the city network layer and
connect to the data center layer, where the data is aggregated, normalized,
and virtualized.
 The data center layer provides information to the services layer, which
consists of the applications that provide services to the city.

 In smart cities, multiple services may use IoTsolutions for many different
purposes. These services may use different IoTsolutions, with different
protocols and different application languages

Street Layer:

Page 15
Internet of Things

 The street layer is composed of devices and sensors that collect data and take
action based on instructions from the overall solution, as well as the
networking components needed to aggregate and collect data.
 A sensor is a data source that generates data required to understand the
physical world. Sensor devices are able to detect and measure events in the
physical world.

 ICT connectivity solutions rely on sensors to collect the data from the world
around them so that it can be analyzed and used to operationalize use cases
for cities.

City Layer:
 At the city layer, which is above the street layer, network routers and switches
must be deployed to match the size of city data that needs to be transported.
 This layer aggregates all data collected by sensors and the end-node network
into a single transport network.

 The city layer may appear to be a simple transport layer between the edge
devices and the data center or the Internet.

Data Center Layer:


 Ultimately, data collected from the sensors is sent to a data center, where it
can be processed and correlated.
 Based on this processing of data, meaningful information and trends can be
derived, and information can be provided back.

Service Layer:
 Ultimately, the true value of ICT connectivity comes from the services that the
measured data can provide to different users operating within a city.
 Smart city applications can provide value to and visibility for a variety of user
types, including city operators, citizens, and law enforcement.

 The collected data should be visualized according to the specific needs of each
consumer of that data and the particular user experience requirements and
individual use cases.

Page 16
Internet of Things

5) Smart City Security Architecture


 A serious concern of most smart cities and their citizens is data security.
 Vast quantities of sensitive information are being shared at all times in a
layered, real-time architecture, and cities have a duty to protect their citizens’
data from unauthorized access, collection, and tampering.

 In general, citizens feel better about data security when the city itself, and not
a private entity, owns public or city-relevant data.

 It is up to the city and the officials who run it to determine how to utilize this
data.

 A security architecture for smart cities must utilize security protocols to fortify
each layer of the architecture and protect city data.

 Security protocols should authenticate the various components and protect


data transport throughout.

 Starting from the street level, sensors should have their own security
protocols.

 Sensor identification and authorization typically requires a pre-installed


factory X.509 certificate and public key infrastructure (PKI) at the organization
level, where a new certificate is installed through a zero-touch deployment
process.

 Another consideration may be the type of data that the sensor is able to
collect and process.

6) Smart City Use-Case Examples


A) Connected Street Lighting
 Of all urban utilities, street lighting comprises one of the largest expenses in
a municipality’s utility bill, accounting for up to 40% of the total, according
to the New York State Department of Environmental Conservation.
 Maintenance of street lights is an operational challenge, given the large
number of lights and their vast geographic distribution.

Page 17
Internet of Things

Connected Street Lighting Solution


 Cities commonly look for solutions to help reduce lighting expenses and at
the same time improve operating efficiencies while minimizing upfront
investment.
 The installation of a smart street lighting solution can provide significant
energy savings and can also be leveraged to provide additional services.
 In this regard, light-emitting diode (LED) technology leads the transition
from traditional street lighting to smart street lighting.

 LEDs require less energy to produce more light than legacy lights, and they
have a much longer life span and a longer maintenance cycle.

 A leading lighting company estimates that a complete switch to LED


technology can reduce individual light bills by up to 70%.

Street Lighting Architecture


 Connected lighting uses a light management application to manage street
lights remotely by connecting to the smart city’s infrastructure.
 This application attaches to LED lights, monitors their management and
maintenance, and allows you to view the operational status of each light.

 In most cases, a sensor gateway acts as an intermediate system between


the application and the lights (light control nodes).

 The gateway relays instructions from the application to the lights and stores
the local lights’ events for the application’s consumption.

 The controller and LED lights use the cloud to connect to the smart city’s
infrastructure, as shown below;

Page 18
Internet of Things

 A human or automated operator can use a cloud application to perform


automated scheduling for lights and even get light sensors to perform
automated dimming or brightening, as needed.

 Lighting nodes vary widely in the industry, especially with respect to


elements such as what communication protocol they use (for example, Wi-
Fi, cellular, ZigBee, 802.15.4g [Wi-SUN], LoRaWAN), level of ruggedization,
and on-board sensor capabilities.

 Lighting, as an ICT connectivity solution, utilizes an existing city asset with


an existing power source.

 Enabling that asset with ICT connectivity technologies not only drives
revenue on its own but can also drive an ICT connectivity solution by being
the asset that different technology pieces use to operate.
B) Smart Parking
 Parking is a universal challenge for cities around the globe.
 Ineffective parking access and administration make parking in urban areas
a constant struggle and affect cities in many ways.

Smart Parking Use Cases


 Added traffic congestion is one consequence of drivers looking for parking
space, and it has several consequences:

Page 19
Internet of Things

 Contributes to pollution: Tons of extra carbon emissions are


released into the city’s environment due to cars driving around
searching for parking spots when they could be parked.
 Causes motorist frustration: In most cities, parking spot scarcity
causes drivers to lose patience and waste time, leading to road rage,
inattention, and other stress factors.

 Increases traffic incidents: Drivers searching for parking spots cause


increased congestion in the streets and that, in turn, causes
increased accidents and other traffic incidents.
 As we look at ways to apply technology to tackle some of the most pressing
issues facing cities today, parking is an area where improvement is clearly
needed and can be easily quantified.
 One option for solving urban center traffic issues is to repurpose dense
urban space to create additional parking infrastructure.

 However, such an option is often challenging, primarily because of the


costs, financial and otherwise.

 Instead of resorting to utilizing valuable city real estate to create more


parking spaces, cities often have the option of optimizing the usage
efficiency of existing parking assets to better manage citizen needs.

 Instead of resorting to utilizing valuable city real estate to create more


parking spaces, cities often have the option of optimizing the usage
efficiency of existing parking assets to better manage citizen needs.

Smart Parking Architecture


 A variety of parking sensors are available on the market, and they take
different approaches to sensing occupancy for parking spots.
 Most sensors installed in the ground must rely on battery power, since
running a power line is typically too expensive.

 These sensors commonly react to changes, such as a change in the


magnetic field, triggering a sensor to awaken and send an event report.

Page 20
Internet of Things

 Technology innovations are happening all the time, making the holistic ICT
connectivity architecture even more important.

 Combining the technologies in innovative ways also expands the


possibilities of the services IoT systems can deliver; this certainly holds true
for smart parking.

 An application can be used for drivers to register their disability and then
locate these spots more easily.

 Smart parking has three users that applications must support through
aggregated data: city operators, parking enforcement personnel, and
citizens.
C) Smart Traffic Control
 Traffic is one the most well-understood pain points for any city. It is the
leading cause of accidental death globally, causes immense frustration, and
heavily contributes to pollution around the globe.

 A smart city traffic solution would combine crowd counts, transit


information, vehicle counts, and so on and send events regarding incidents
on the road so that other controllers on the street could take action.

Smart Traffic Control Architecture


 In the architecture, a video analytics sensor computes traffic events based
on a video feed and only pushes events (the car count, or metadata, not
the individual images) through the network.
 These events go through the architectural layers and reach the applications
that can drive traffic services.

 These events go through the architectural layers and reach the applications
that can drive traffic services.

 Some sensors can also recognize abnormal patterns, such as vehicles


moving in the wrong direction or a reserved lane.

Smart Traffic Applications


 Traffic applications can be enabled to take immediate action with other
sensors to manage traffic and to reduce pain points.
Page 21
Internet of Things

 A common traffic pain point is stop-and-go, where traffic flow suddenly


comes to a halt and then flows again.

 A well-known remedy for stop-and-go traffic is to regulate the standard


flow speed based on car density.

 As density increases, car speed is forced down to avoid the wave effect.
D) Connected Environment
 Most large cities monitor their air quality.
 Data is often derived from enormous air quality monitoring stations that
are expensive and have been around for decades.

 These stations are highly accurate in their measurements but also highly
limited in their range, and a city is likely to have many blind spots in
coverage.

 Given the price and size of air quality monitoring stations, cities cannot
afford to purchase the number of stations required to give accurate reports
on a localized level and follow the pollution flows as they move through
the city over time.

 To fully address the air quality issues in the short term and the long term, a
smart city would need to understand air quality on a hyper-localized, real-
time, distributed basis at any given moment.

 Connected environment sensors might measure different gases, depending


on a city’s particular air quality issues, and may include weather and noise
sensors.

 These sensors may be located in a variety of urban fixtures, such as in


street lights, as explained earlier.

 Even mobile sources of information can be included through connected


wearables that citizens might choose to purchase and carry with them to
understand the air quality around them at any given moment.

Page 22
Internet of Things

 From the pollution and environmental data and the analytics applied to it,
the city can track problem areas and take action in long-term urban
planning to reduce the effects of air quality disturbances.

Page 23

You might also like