Wednesday, August 29, 2018

Internet Of Things



Explain Configuring Raspberry pi ?


            Software’s needed
ü  SD Card Formatter-----to Format SD Card  
ü  Etcher--------------------to Flash  2018-06-27-raspbian-stretch  
                                                                              Disc Image with SD Card 
ü  Raspbian  Stretch with Desktop
Hardware Devices needed
o   SD Card
o   Raspberry pi3 Model B
o   USB Cable for Power Supply to  Raspberry pi3 Model B
o   HDMI Cable to Connect with Desktop/LCD /Laptop
o   Power Supply Cable to Desktop/ LCD

Steps to Download SD Card Formatter
1.                 ·        Launch Any Browser {Chrome ,IE,FF}
2.                 ·        Navigate to   https://www.download3k.com/Install-SDFormatter.html
3.                 ·        Now click on Developer Link1 to Download
4.                 ·        Finally you will be able to get  SD_CardFormatter0500SetupEN.exe File
5.                 ·        Double Click on  SD_CardFormatter0500SetupEN.exe File
6.                 ·        Click Next and Accept License Agreement\
7.                 ·        Click Next Until Installation get Completed 


How to Format SD using SD Card Formatter
·        Take new SD card with minimum Capacity of 16 GB
·        Insert it into Card Reader 
·        Plug-in the Card Reader into USB Port of your Computer
·        Even though it is new Memory Card
·        Format the Memory Card using SD Card Formatter Software
·        Double Click on  SD_CardFormatter  Icon Available on your Desktop
·        Select the Location where  your  Card Reader is Plugged in  your System {Removable Disk D/E/F…}
·        Then Enable Quick Format  Radio Button
·        Click on Format Button
·        It takes microseconds to complete Formatting
·        Now Close the  SD_CardFormatter   window
 Steps to Download  Raspbian  Stretch
1.                 ·        Launch Any Browser {Chrome,IE,FF}
2.                 ·        Navigate to https://www.raspberrypi.org/downloads/raspbian/
3.                 ·        Go to  Raspbian  Stretch with Desktop     Image with desktop based on Debian Stretch
4.                 ·        Click on Download ZIP
5.                 ·        It  takes min 50 minuts for Completion of Download
6.                 ·        Finally you will get Zip File
7.                 ·        Place it in your  Personal Folder
8.                 ·        Extract the Zip  and you will be able to see Image File 


How to Download  Etcher-Setup-1.4.4-x86
·        Launch Any Browser {Chrome,IE,FF}
·        Navigate to https://etcher.io/  
·        Check your System Operating System Bit Size
ü Suppose if  it is 32bit Windows OS
ü Then Choose Etcher  for Windows x86 (32-bit) (Portable)  from the Dropdown  Download  for Windows
ü Suppose if  it is 64bit Windows OS
ü Then Choose Etcher  for Windows x64  (64-bit) (Portable)  from the Dropdown  Download  for Windows
·        Now Click on  Download  for Windows
·        Finally you will be able to see  Etcher-Setup-1.4.4-x86.exe File
·        Move  the  Etcher-Setup-1.4.4-x86.exe File into  your Personal Folder
·        Double Click  on  Etcher-Setup-1.4.4-x86.exe File
·        Click Run Button
·        Accept the License Agreement
·        Wait Until  Installation gets Completed



How to Flash SD card with Image with desktop based on Rabian Stretch
·        After Formatting SD Card
·        Open  Etcher Icon which is available on Desktop after Successful Installation of  Etcher
·        Etcher window will be opened  after Double click on Etcher Icon
·        Click on    Select Image
·        Navigate to Location where you placed  Image
·        After Selecting  Image  Click  on  MXT –USB S…SB Device
·        Select your SD Card as Location {Removable Disk E/D/F…}
·        After Selecting SD Card now Click on Flash
·        It takes 15Minutes of time to Complete Flash

Raspberry pi  setup
·                  After Completion of Formatting  SD Card and Flashing SD card with Image 
·                  Place the SD card into the SD card  port of  Raspberry pi   Device
·                  Connect Power Supply Cable to Raspberry pi
·                  Now Connect the Raspberry pi Device to Desktop/Laptop/LCD using HDMI Cable

ü  Click on Icon Raspberry{Start Option}
ü  To set Date and Time
o   Go to Preferences---we do all setup (Keyboard, Time...ie)
ü  To change Language
o   By default UK Keyboard
o   To change language
o   Preferences
o   Raspberry Pi Configuration
o   Localization
o   US
o   English
o   Click Ok for Reboot





 Explain various Linux Commands to implement on Raspberry Pi?


The File Manager
 If you prefer not to move files around using the command line (more on that in a moment), select the File Manager from the Accessories menu. You’ll be able to browse the filesystem using icons and folders the way you’re probably used to doing.
The Web Browser
The default web browser is Midori, designed to work well with limited resources. It’s easy to forget how much work web browsers do these days. Because Raspbian is designed to be a very lightweight OS distribution, there are a number of features you may expect in a web browser that are not available. For example Flash and the Java plugin is not installed (so no YouTube), and Midori does not support HTML5 video. Later we’ll look at how to install new software (like Java). Look for tools and menu items in the pulldown menu in the upper right corner of the window There are a couple of other browser options, notably NetSurf and Dillo.
 Video and Audio
 Multimedia playback is handled by omxplayer, which is a bit experimental as of this writing. It is only available as a command line utility. Omxplayer is specially designed to work with the Graphics Processing Unit (GPU) on the processor; other free software like VLC and mPlayer won’t work well with the GPU
Text Editor
 Leafpad is the default text editor, which is available under the main menu. You’ve also got Nano, which is an easy-to-learn bare bones text editor. Traditional Unix text editors like vim or emacs are not installed by default, but can be easily added (see “Installing New Software” (page 30)).
 Copy and Paste
Copy and paste functions work between applications pretty well, although you may find some oddball programs that aren’t consistent. If you have a middle button on your mouse you can select text by highlighting it as you normally would (click and drag with the left mouse button) and paste it by pressing the middle button while you have the mouse cursor over the destination window.
The Shell
 A lot of tasks are going to require you to get to the command line and run commands there. The LXTerminal program provides access to thecommand line or shell. The default shell on Raspbian is the Bourne Again Shell (bash), which is very common on Linux systems. There’s also an alternative called dash. You can change shells via the program menu, or with the chsh command.
Using the Command Line
 If it helps, you can think of using the command line as playing a text adventure game, but with the files and the filesystem in place of Grues and mazes of twisty passages. If that metaphor doesn’t help you, don’t worry; all the commands and concepts in this section are standard Linux and are valuable to learn. Before you start, open up the LXTerminal program (Figure 2-3). There are two tricks that make life much easier in the shell: autocomplete and command history. Often you will only need to type the first few characters of a command or filename, then hit tab. The shell will attempt to autocomplete the string based on the files in the current directory or programs in commonly used directories (the shell will search for executable programs in places like /bin or /usr/bin/). If you hit the up arrow on the command line you’ll be able to step back through your command history, which is useful if you mistyped a character in a long string of commands.


Use the cd (change directory) command to move around the filesystem.
The following two commands have the same effect (changing to the home directory) for the pi user:
 cd /home/pi/ cd ~
If the directory path starts with a forward slash it will be interpreted as an absolute path to the directory. Otherwise the directory will be considered relative to the current working directory. You can also use . and .. to refer to the current directory and the current directory’s parent.
 For example, to move up to the top of the filesystem:
 pi@raspberrypi ~ $ cd ..
pi@raspberrypi /home $ cd ..
 You could also get there with the absolute path /: pi@raspberrypi ~ $ cd /
 Once you’ve changed to a directory, use the ls command to list the files there. pi@raspberrypi / $ ls
bin dev home lost+found mnt proc run selinux sys usr boot etc lib media opt root sbin srv tmp var Most commands have additional parameters or switches that can be used to turn on different behaviors.
 For example, the -l switch will produce a more detailed listing, showing file sizes, dates and permissions: pi@raspberrypi ~ $ ls -l
total 8 drwxr-xr-x 2 pi pi 4096 Oct 12 14:26
 Desktop drwxrwxr-x 2 pi pi 4096 Jul 20 14:07 python_games
Use the mv command to rename a file.
 The touch command can be used to create an empty dummy file: pi@raspberrypi ~ $ touch foo
 pi@raspberrypi ~ $ ls foo Desktop python_games
 pi@raspberrypi ~ $ mv foo baz
pi@raspberrypi ~ $ ls baz Desktop python_games
If you want to find out all the parameters for a particular command, use the man command (or you can often use the --help option):
 pi@raspberrypi ~ $ man curl
 pi@raspberrypi ~ $ rm --help
 To create a new directory, use mkdir. To bundle all of the files in a directory into a single file, use the tar command, originally created for tape archives. You’ll find a lot of bundles of files or source code are distributed as tar files, and they’re usually also compressed using the gzip command.
 Try this: pi@raspberrypi ~ $ mkdir myDir
pi@raspberrypi ~ $ cd myDir

More Linux Commands
One of the reasons that Linux (and Unix) are so successful is that the main design goal was to build a very complicated system out of small, simple modular parts that can be chained together. You’ll need to know a little bit about two pieces of this puzzle: pipes and redirection. Pipes are simply a way of chaining two programs together, so the output of one can serve as the input to another. All Linux programs can read data from standard input (often referred to as stdin), write data to standard output (stdout), and throw error messages to standard error(stderr). A pipe lets you hook up stdout from one program to stdin of another (Figure 2-4). Use the | operator, as in this example:
 pi@raspberrypi ~ $ ls -la | less
You may want to turn the volume down a bit first; this command reads the kernel image and spits all of the 1s and 0s at the audio player. That’s what your kernel sounds like! In some of the examples later in the book we’ll also be using redirection, where a command is executed and the stdout output can be sent to a file. As you’ll see later, many things in Linux are treated as ordinary files (such as the Pi’s general purpose input and output pins), so redirection can be quite handy. To redirect output from a program use the > operator:
 pi@raspberrypi ~ $ ls > directoryListing.txt






 Explain Installation and Testing GPIO in Python?


General Purpose Input/Output (GPIO) is a generic pin on a chip whose behavior can be controlled by the user at run time

A powerful feature of the Raspberry Pi is the row of GPIO (general-purpose input/output) pins along the top edge of the board. 

A 40-pin GPIO header is found on all current Raspberry Pi boards (unpopulated on Pi Zero and Pi Zero W). 

Prior to the Pi 1 Model B+ (2014), boards comprised a shorter 26-pin header.


GPIO setup on Raspberry Pi 

• Install Python 2 library Rpi.GPIO. – A library that will let us control the GPIO pins. 
• https://pypi.python.org/pypi/RPi.GPIO 
• Install commands:

sudo apt‐get update

sudo apt‐get install python‐dev

sudo apt‐get install python‐rpi.gpio

Theory or Diagram 


Code Snippet:-
Program to control the led using button?

import RPi.GPIO as r

led=12

button=11

r.setmode(r.BOARD) #Board Mode Following

r.setup(led,r,OUT)

r.setup(button,r.IN)

while 1:

val=r.input(button)

if val==1:

r.output(led,1)

print("led on")

else:

r.output(led,0)

print("led off")


Write a Python Program to read a Key from a 4x4 keypad for Rapberry Pi?


from pad4pi import rpi_gpio
import time

# Setup Keypad
KEYPAD = [
        ["1","2","3","A"],
        ["4","5","6","B"],
        ["7","8","9","C"],
        ["*","0","#","D"]
]

# same as calling: factory.create_4_by_4_keypad, still we put here fyi:
ROW_PINS = [4, 14, 15, 17] # BCM numbering
COL_PINS = [18, 27, 22, 23] # BCM numbering

factory = rpi_gpio.KeypadFactory()

# Try factory.create_4_by_3_keypad
# and factory.create_4_by_4_keypad for reasonable defaults
keypad = factory.create_keypad(keypad=KEYPAD, row_pins=ROW_PINS, col_pins=COL_PINS)

#keypad.cleanup()

def printKey(key):
  print(key)
  if (key=="1"):
    print("number")
  elif (key=="A"):
    print("letter")

# printKey will be called each time a keypad button is pressed
keypad.registerKeyPressHandler(printKey)

try:
  while(True):
    time.sleep(0.2)
except:
 keypad.cleanup()





Explain Cloud Storage Models in IOT?


  • Infrastructure as a Service (IaaS): IaaS deals with the delivery of storage and computing resources towards supporting custom business solutions. Enterprises opt for an IaaS cloud computing model in order to benefit from lower prices, the ability to aggregate resources, accelerated deployment, as well as increased and customized security. The most prominent example of IaaS service Amazon’s Elastic Compute Cloud (EC2), which uses the Xen open-source hypervisor to create and manage virtual machines.
  • Platform as a Service (PaaS): PaaS provides development environments for creating cloud-ready business applications. It provides a deeper set of capabilities comparing to IaaS, including development, middleware, and deployment capabilities. PaaS services create and encourage deep ecosystem of partners who commit to this environment. Typical examples of PaaS services are Google’s App Engine and Microsoft’s Azure cloud environment, which both provide a workflow engine, development tools, a testing environment, database integration functionalities, as well as third-party tools and services.
  • Software as a Service (SaaS): SaaS services enable access to purpose-built business applications in the cloud. Such services provide the pay-go-go, reduced CAPEX and elastic properties of cloud computing infrastructures.
Cloud services can be offered through infrastructures (clouds) that are publicly accessible (i.e. public cloud services), but also by privately owned infrastructures (i.e. private cloud services). Furthermore, it is possible to offer services supporting by both public and private clouds, which are characterized as hybrid cloud services.

Internet-of-Things can benefit from the scalability, performance and pay-as-you-go nature of cloud computing infrastructures. Indeed, as IoT applications produce large volumes of data and comprise multiple computational components (e.g., data processing and analytics algorithms), their integration with cloud computing infrastructures could provide them with opportunities for cost-effective on-demand scaling. As prominent examples consider the following settings:

  • Although cloud computing has emerged mainly from the appearance of public
  • computing utilities, other deployment models, with variations in physical
  • location and distribution, have been adopted. In this sense, regardless of its
  • service class, a cloud can be classified as public, private, community, or hybrid [6]
  • based on model of deployment as shown in Figure 1.4.
  • Armbrust et al. [5] propose definitions for public cloud as a “cloud made
  • available in a pay-as-you-go manner to the general public” and private cloud as
  • “internal data center of a business or other organization, not made available to
  • the general public.”
  • In most cases, establishing a private cloud means restructuring an existing
  • infrastructure by adding virtualization and cloud-like interfaces. This allows
  • users to interact with the local data center while experiencing the same
  • advantages of public clouds, most notably self-service interface, privileged
  • access to virtual servers, and per-usage metering and billing.
  • A community cloud is “shared by several organizations and supports a
  • specific community that has shared concerns (e.g., mission, security requirements,
  • policy, and compliance considerations) [6].”
  • A hybrid cloud takes shape when a private cloud is supplemented with
  • computing capacity from public clouds [7]. The approach of temporarily
  • renting capacity to handle spikes in load is known as “cloud-bursting”

  • A Small Medium Enterprise (SME) developing an energy management IoT product, targeting smart homes and smart buildings. By streaming the data of the product (e.g., sensors and WSN data) into the cloud it can accommodate its growth needs in a scalable and cost effective fashion. As the SMEs acquires more customers and performs more deployments of its product, it is able to collect and manage growing volumes of data in a scalable way, thus taking advantage of a “pay-as-you-grow” model. Moreover, cloud integration allows the SME to store and process massive datasets collected from multiple (rather than a single) deployments.
  • A smart city can benefit from the cloud-based deployment of its IoT systems and applications. A city is likely to deploy many IoT applications, such as applications for smart energy management, smart water management, smart transport management, urban mobility of the citizens and more. These applications comprise multiple sensors and devices, along with computational components. Furthermore, they are likely to produce very large data volumes. Cloud integration enables the city to host these data and applications in a cost-effective way. Furthermore, the elasticity of the cloud can directly support expansions to these applications, but also the rapid deployment of new ones without major concerns about the provisioning of the required cloud computing resources.
  • A cloud computing provider offering pubic cloud services can extend them to the IoT area, through enabling third-parties to access its infrastructure in order to integrate IoT data and/or computational components operating over IoT devices. The provider can offer IoT data access and services in a pay-as-you-fashion, through enabling third-parties to access resources of its infrastructure and accordingly to charge them in a utility-based fashion.
     






No comments:

Post a Comment

Internet Of Things

Explain Configuring Raspberry pi ?             Software’s needed ü    SD Card Formatter-----to Format SD Card   ü    Etcher--...