Module 5 Iot
Module 5 Iot
5) Introduction to ARDUINO
• Arduino is an open-source advancement prototyping (development model) platform
which depends on simple to utilize equipment and programming.
• Instructions to the microcontroller are given by the use of Arduino programming.
• Arduino software(IDE-Integrated improvement environment)
• The Arduino is a small computer that you can program to read information from the
world around you and to send commands to the outside world.
• Arduino is a tiny computer that you can connect to electrical circuits.
• The brain of this board (Arduino Uno) is an ATmega328p chip (Micro controller) where
you can store your programs that will tell your Arduino what to do.
Why Arduino?
4) Serial Peripheral Interface (SPI) :- is an interface bus commonly used to send data
between microcontrollers and small peripherals such as sensors, and SD cards.
5) Arduino is easy to use, connected to a computer via a USB and communicates using serial
protocol .
6) Inexpensive around 500 rupees per board with free authoring software.
7) Ardunio has growing online community where lots of source code is available for use .
In the ten years since Arduino was released , hundreds of “Arduino boards” are available
in the market serving every kind of purpose.
We focus on Arduino UNO .
Some of the Boards from Arduino family are given below.
Arduino mega is a big sister to the UNO with more memory and pins with a different chip
the Atmega2560,useful when your project doesn”t fits in an UNO.
Arduino Micro is bit smaller with a chip Atmega32u4 that can act like a keyboard or
mouse which does its task with native USB.
Its slim with downward pins which can be plugged into a breadboard.
The Arduino MKR1000 is a little like an Arduino Micro but has a more powerful 32-bit
ATSAM ARM chip and built-in WiFi.
A great upgrade for when you want to do internet of Things projects.
Flora is an Arduino compatible from Adafruit which is a round wearable which can be
sewed (attach) into clothes.
• https://www.arduino.cc/en/Main/Software
• In order to keep your circuit organized you need to use a breadboard, pictured below in
Figure 5-6.
• The breadboard allows you to connect components together by plugging them into the
little holes.
Processor – The Broadcom BCM2835 SoC( System on Chip) used in the first generation
Raspberrypi is somewhat equivalent to the chip used in first generation smart phones,
Which includes a 700MHz ARM1176JZF-S Processor, Video Core IV graphics
processing unit(GPU) and RAM.
• This has a level 1 (L1) cache of 16 KB and a level 2 (L2) cache of 128 KB.
• The level 2 cache is used primarily by the GPU.
• The Raspberrypi2 uses a Broadcom BCM2836 SoC with a 900 MHz 32-bit quad-core
ARM cortex A7 processor with 256KB shared L2 cache.
• The Raspberrypi2 uses a Broadcom BCM2837 SoC with a 1.2 GHz 64-bit quad-core
ARM cortex A53 processor, with a 512 KB shared L2 cache.
Power Source:- The recommended and easiest way to power the Raspberrypi is via the
Micro USB port on the side of the unit.
• The recommended input voltage is 5V , and the recommended input current is 2A.
SD Card (Secure Digital Card): The Raspberry Pi does not have any locally available
storage accessible.
• 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.
• GPIO capabilities may include
• 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 (define) by
MIPI (Mobile Industry Processor Interface) organization together went for interfacing
cameras with a portable processor.
HDMI- High Definition Multimedia Interface to give both video and sound yield.
6) Simple interfaces includes ADCs (Analog and Digital Converter) and DACS( Digital and
Analog Converter)
Accessories
Camera: On 14 May 2013 , the establishment and the merchants RS Components and
Premier Farnell/ Element 14 propelled the Raspberry pi camera board with a firmware
redesign to bolster it.
Serial :- The serial interface on Raspberry Pi has receive(rx) and transmit(Tx) pins for
communication with serial peripherals.
SPI:- Serial Peripheral interfaces( SPI) is a synchronous serial data protocol used for
communication with one or more peripheral devices.
• MISO (Master In Slave Out): Master line for sending data to the peripherals.
• MOSI(Master out Slave In): Slave line for sending data to the master.
I2C:- The I2C interface pins on Raspberry Pi allow you to connect hardware
modules.
Recalbox
Formatting SD card:
OS installation
First Boot
Login information
The default login for Raspbian is username “pi” with the password “raspberry”.
To load the graphical user interface, type “Startx” and press Enter.
RaspberryPI Commands
• The DS18B20 also has an alarm function that can be configured to output a signal when
the temperature crosses a high or low threshold that’s set by the user
• A 64 bit ROM stores the device’s unique serial code. This 64 bit address allows a
microcontroller to receive temperature data from many sensors with identity.
• The DS18B20 temperature sensor is perfect for projects like weather stations and home
automation systems
• The size is same as a transistor and use only one wire for the data signal
• 0.5°C (9 bit); 0.25°C (10 bit); 0.125°C (11 bit); 0.0625°C (12 bit) resolution
• sudo reboot
• cd /sys/bus/w1/devices
• ls
• cd 28-xxxx
• cat w1_slave
• a3 01 4b 46 7f ff 0e 10 d8 : crc=d8 YES
• a3 01 4b 46 7f ff 0e 10 d8 t=32768
You can access the command line of a Raspberry Pi remotely from another computer or
device
The Raspberry Pi will act as a remote device: you can connect to it using a client on
another machine.
• If you are using wireless networking, this can be enabled via the desktop's user interface,
or using the command line
• You will need to note down the IP address of your Pi in order to connect to it later.
Using the ifconfig command will display information about the current network status,
including the IP address, or you can use hostname -I to display the IP addresses
associated with the device
2. Enable SSH
For headless setup, SSH can be enabled by placing a file named ssh, without any
extension, onto the boot partition of the SD card from another computer.
When the Pi boots, it looks for the ssh file. If it is found, SSH is enabled and the file is
deleted
SSH is built into Linux distributions and Mac OS. For Windows and mobile devices,
third-party SSH clients are available.
Video cameras combined with video analytics can detect vehicles, faces,
and traffic conditions for various traffic and security use cases.
An air quality sensor can detect and measure gas and particulate matter
concentrations to give a hyper-localized perspective on pollution in a given area.
Device counters give an estimate of the number of devices in the area, which
provides a rough idea of the number of vehicles moving or parked in a street or a
public parking area, of pedestrians on a sidewalk, or even of birds in public parks
or on public monuments—for cities where bird control has become an issue.
2) 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.
However, one key consideration of the city layer is that it needs to transport multiple
types of protocols, for multiple types of IoT applications.
Some applications are delay- and jitter-sensitive, and some other applications require a
deterministic approach to frame delivery.
As a result, the city layer must be built around resiliency, to ensure that a packet coming
from a sensor or a gateway will always be forwarded successfully to the headend station.
Figure 5.13 shows a common way of achieving this goal.
Figure 5.14 The Role of the Cloud for Smart City Applications
With the cloud approach shown in Figure 5.14 , smart cities can also take advantage of
operating expense–based consumption models to overcome any financial hurdles in
adopting solutions to their most critical issues.
Critical data, such as air condition (humidity, temperature, pollution) levels monitoring,
can be processed initially.
Then, as the efficiency of IoT is scaled up, richer data processing can be enabled in the
cloud applications.
For example, the humidity level can be used to regulate the color and luminosity of street
lights. In times when city budgets are strained, data processing can be scaled down to
essential services.
4) Services 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.
For example, parking data indicating which spots are and aren’t currently occupied can
drive a citizen parking app with a map of available spots, as well as an enforcement
officer’s understanding of the state (utilization and payment) of the public parking space,
while at the same time helping the city operator’s perspective on parking problem areas in
the city at any given time.
With different levels of granularity and scale, the same data performs three different
functions for three different users.
Along the same lines, traffic information can be used by individual car drivers to find
the least congested route.
A variation of the same information can be made available to public transportation users
to estimate travel times.
Public transportation systems, such as buses, can be rerouted around known congestion
points.
The number of subway trains can be increased dynamically to respond to an increase in
traffic congestion, anticipating the decisions of thousands or even millions of commuters
to take public transportation instead of cars on days when roads are very congested.
Here again, the same type of data is utilized by different types of users in different ways
based on their specific use cases.
On-Premises vs. Cloud
Different cities and regions have different data hosting requirements based on security or
legal policies. A key consideration in developing ICT connectivity solutions is whether a
city has requirements about where data should be hosted.
Data can be hosted on-premises or in the cloud. Fog architectures provide an intermediate
layer.
The data resulting from fog processing can be sent to the cloud or to a data center
operated locally (on-premises).
On-premises encompasses traditional networks, and all their limitations, whereas cloud
hosting encompasses a whole host of security risks if the proper measures are not taken to
secure citizen data.
When data is sent to the cloud, data sovereignty (supremacy) laws may restrict the
physical location where this data is actually stored.
Ideally, a smart city utilizing ICT connectivity would use the cloud in its architecture, but
if this is impossible, the city would need to invest far more in the city layer’s networking
components (for example, switches, routers) and still may not be able to drive the same
cross-domain value propositions and scalability in its design.
Network partners may also have their own compliance standards, security policies, and
governance requirements that need to be added to the local city requirements.
points to implement IoT in smart cities: connected street lighting, smart parking, smart
traffic control, and connected environment.
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.
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%.
LEDs are well suited to smart solution use cases.
For example, LED color or light intensity can be adapted to site requirements (for
example, warmer color and lower intensity in city centers, sun-like clarity on highways,
time- and weather-adaptive intensity and color).
Figure 5.16 shows how electricity prices rise, while LED prices decrease and their unit
sales rise.
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).
These features are optimized for different circumstances and conditions; no single
lighting node can support all environments ideally.
Many solutions leverage wired connectivity, either by using the existing city cable
infrastructure or by adding a cable adjacent to the power cable.
In cases where cabling is not practical, wireless technologies may bring interesting
capabilities.
For example, 802.15.4g controllers can be used to form a mesh and extend the network.
This extension is used not only to connect other light poles but also to connect smart
meters from neighboring houses.
In all cases, the built-in versatility offered by the four-layer architecture shown in Figure
5.17 ensures that all the different types of technologies optimized to fit any city topology
can be flexibly incorporated into the solution.
Smart Parking Use Cases
Added traffic congestion is one consequence of drivers looking for parking space, and it
has several consequences:
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.
Revenue loss is another consequence of drivers looking unsuccessfully for parking space,
and it also has various negative side effects:
Cities often lose revenue: As a result of inadequate parking meter enforcement and no-
parking, no-standing, and loading-zone violations, cities lose revenue.
Parking administration employee productivity suffers: Employees waste time roaming
the streets, attempting to detect parking rules offenders.
Parking availability affects income: Local shops and businesses lose customers because
of the decreased accessibility caused by parking space shortages.
For example, a driver can book a nearby parking spot, or a parking operator can remove it
from the list of available parking spaces in target locations.
This action triggers data to be sent back to the parking sensor to modify its availability
status based on the received instructions.
smart parking has three users that applications must support through aggregated data: city
operators, parking enforcement personnel, and citizens.
The true value of data normalization is that all parking data, regardless of technology or
vendor, would be visible in these applications for the different users to support their
particular experiences.
The following are some potential user experiences for these three user types.
1) City operators: These users might want a high-level map of parking in the city to
maintain perspective on the city’s ongoing parking situation.
They would also need information on historical parking data patterns to understand
congestion and pain points in order to be able to effectively influence urban planning.
2) Parking enforcement officers: These users might require real-time updates on parking
changes in a certain area to be able to take immediate action on enforcement activities,
such as issuing tickets or sending warnings to citizens whose time is nearing expiration.
Their focus is driving revenue creation for the city and minimizing wasted time by
performing parking monitoring and enforcement at scale
3) Citizens: These users might want an application with a map (such as a built-in parking app
in their car) showing available parking spots, reservation capabilities, and online payment.
Their focus would be on minimizing the time to get a parking spot and avoiding parking
tickets.
The application could warn when parking duration limits approach, allowing the driver to
move the vehicle before the timer expires or pay a parking timer extension fee without
having to go back to the vehicle.
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 shown in Figure 5.19, 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 services include traffic light coordination and also license plate identification for
toll roads.
Some sensors can also recognize abnormal patterns, such as vehicles moving in the wrong
direction or a reserved lane. In that case, the video feed itself may be uploaded to traffic
enforcement agencies.
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.
An application that measures traffic density in real time can take action by regulating the
street light cycle duration to control the number of cars added to the flow of the main
routes, thus limiting or suppressing the wave effect.
From the driver’s standpoint, there is a wait time before being able to get on the highway
or main street, and traffic on the main route is slow but steady.
The impression is that traffic is slow but moving, and the overall result is a better
commute experience, with lowered and less stressful commute time, as well as a reduced
number of accidents.
Connected Environment
As of 2017, 50% of the world’s population has settled on less than 2% of the earth’s
surface area.
Such densely populated closed spaces can see spikes in dangerous gas molecules at any
given moment.
More than 90% of the world’s urban population breathes in air with pollutant levels that
are much higher than the recommended thresholds, and one out of every eight deaths
worldwide is a result of polluted air.
The Need for a 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. To get those measurements, smart cities need to invest in the
following:
Open-data platforms that provide current air quality measurements from existing
air quality monitoring stations
Sensors that provide similar accuracy to the air quality stations but are available at
much lower prices
Actionable insights and triggers to improve air quality through cross domain
actions
Visualization of environmental data for consumers and maintenance of historical
air quality data records to track emissions over time.
Connected Environment Architecture
Figure 5.20 shows an architecture in which all connected environment elements overlay
on the generalized four-layer smart city IoT architecture.
or
Write a python code to read temperature value in centigrade (Celsius) and Fahrenheit form
from DS18B20 sensor connected to Raspberry pi microcontroller.