36,59 €
Design, secure, and protect the privacy of edge analytics applications using platforms and tools such as Microsoft's Azure IoT Edge, MicroPython, and Open Source Computer Vision (OpenCV)
Key Features
Book Description
Edge analytics has gained attention as the IoT model for connected devices rises in popularity. This guide will give you insights into edge analytics as a data analysis model, and help you understand why it's gaining momentum.
You'll begin with the key concepts and components used in an edge analytics app. Moving ahead, you'll delve into communication protocols to understand how sensors send their data to computers or microcontrollers. Next, the book will demonstrate how to design modern edge analytics apps that take advantage of the processing power of modern single-board computers and microcontrollers. Later, you'll explore Microsoft Azure IoT Edge, MicroPython, and the OpenCV visual recognition library. As you progress, you'll cover techniques for processing AI functionalities from the server side to the sensory side of IoT. You'll even get hands-on with designing a smart doorbell system using the technologies you've learned. To remove vulnerabilities in the overall edge analytics architecture, you'll discover ways to overcome security and privacy challenges. Finally, you'll use tools to audit and perform real-time monitoring of incoming data and generate alerts for the infrastructure.
By the end of this book, you'll have learned how to use edge analytics programming techniques and be able to implement automated analytical computations.
What you will learn
Who this book is for
If you are a data analyst, data architect, or data scientist who is interested in learning and practicing advanced automated analytical computations, then this book is for you. You will also find this book useful if you're looking to learn edge analytics from scratch. Basic knowledge of data analytics concepts is assumed to get the most out of this book.
Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:
Seitenzahl: 228
Veröffentlichungsjahr: 2020
Copyright © 2020 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author(s), nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Commissioning Editor: Sunith ShettyAcquisition Editor:Devika BattikeContent Development Editor:Athikho Sapuni RishanaSenior Editor: Roshan KumarTechnical Editor: Manikandan KurupCopy Editor: Safis EditingProject Coordinator:Aishwarya MohanProofreader: Safis EditingIndexer:Tejal Daruwale SoniProduction Designer: Aparna Bhagat
First published: May 2020
Production reference: 1200520
Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK.
ISBN 978-1-83882-990-2
www.packt.com
Packt.com
Subscribe to our online digital library for full access to over 7,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website.
Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals
Improve your learning with Skill Plans built especially for you
Get a free eBook or video every month
Fully searchable for easy access to vital information
Copy and paste, print, and bookmark content
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.packt.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details.
At www.packt.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks.
Colin Dow is the author of the Packt book Internet of Things Programming Projects. He is also the owner and chief engineer of Sigma Rockets and Aerospace Inc, a model aerospace business. He has enjoyed working with numerous educational facilities and hobbyists in delivering product sales, presentations, and aerospace workshops over the years. He has extensive experience in creating website content, educational documentation, and instructional videos. He has been a programmer since early home computers first caught his eye. He has worked as a software developer for some of Canada's largest companies using technologies such as Python, Java, J2EE, PHP, Pearl, Ruby on Rails, Apache, SOAP web services, and many more.
Parkash Karki is a principal architect, product development manager, DevOps and cloud practice head, and hardcore IoT enthusiast with years of experience in the IT field. His past experience is mainly in various Microsoft and open source technologies with a current primary focus on DevOps, automation, and the cloud. He has been working on these technologies since they were at quite an early stage. He has contributed to a few other books on IoT as a technical reviewer. He is very passionate about IoT, automation, and AI technologies and keeps on reading, blogging, and trying out different things in these areas.
Yatish Patil works with Saviant Consulting as a program manager. He has delivered enterprise IoT and analytics applications using Microsoft Azure. He has diverse industry experience in IT and has worked in a variety of domains, such as utilities, manufacturing, and engineering. He has completed the Microsoft Azure IoT certification and is the author of Azure IoT Development Cookbook, which focuses on the end-to-end Microsoft Azure IoT platform and pre-configured solutions. He was also the technical reviewer for the book Microsoft Azure IaaS Essentials and Enterprise Internet of Things Handbook. Yatish was among the industry speakers at India IoT Symposium 2016 and delivered a session on remote asset monitoring with Azure IoT Suite.
If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea.
Title Page
Copyright and Credits
Hands-On Edge Analytics with Azure IoT
Dedication
About Packt
Why subscribe?
Contributors
About the author
About the reviewers
Packt is searching for authors like you
Preface
Who this book is for
What this book covers
To get the most out of this book
Download the example code files
Download the color images
Conventions used
Get in touch
Reviews
Section 1: Getting Started with Edge Analytics
Introduction to Edge Analytics
What is edge analytics?
Early computers
The rise of the personal computer
Peer-to-peer networks
Cloud computing
Edge computing
Early IoT applications
Edge analytics
Applying and comparing architectures
The standard IoT solution
Edge analytics-based IoT solution
Key benefits of edge analytics
Privacy
Latency
Reliability
Edge analytics architectures
Basic edge analytics architecture
Azure IoT Edge-based edge analytics architecture
Understanding Microsoft Azure IoT
Understanding Microsoft Azure IoT Edge
Using edge analytics in the real world
Summary
Questions
How Does IoT Edge Analytics Work?
What are the components used in an edge analytics application?
Basic edge analytics components
Sensors
DHT11 temperature and humidity sensor
Soil moisture sensor
Laser sensor
Microcontrollers and computers
The ESP8266
Arduino
PyCom boards
The Raspberry Pi
Personal computers
Microsoft Azure IoT Edge components
Devices
Azure IoT Edge
IoT Edge modules
Azure IoT Edge runtime
Cloud-based interface
How do the components fit together?
Connecting a sensor to the ESP-12F microcontroller
More examples of real-world edge analytics applications
KOM-MICS smart factory platform
Summary
Questions
Further reading
Communications Protocols Used in Edge Analytics
Wi-Fi communication for edge analytics
Understanding the RF spectrum
VLF and LF
Medium frequency
High frequency
Very high frequency
Ultra high frequency
Super high frequency
Extremely high frequency
What is bandwidth?
Using Wi-Fi for our edge analytics applications
Bluetooth for edge analytics communication
What is Bluetooth?
Enhancing our smart heater application with Bluetooth
Cellular technologies for edge analytics communication
The generations of cellular network technology
What is 5G?
How would 5G enhance our edge analytics applications?
Long-distance communication using LoRa and Sigfox for edge analytics
The Friis transmission equation
Sigfox
LoRa and LoRaWAN
Summary
Questions
Further reading
Section 2: Understanding Edge Analytics Technologies
Working with Microsoft Azure IoT Hub
What is Microsoft Azure?
Cloud service providers
Storage
Processing
Virtual machines
Containers
Serverless computing
A look at Microsoft Azure
Infrastructure as a service
Platform as a Service
Software as a Service
Functions as a Service
Setting up a Microsoft Azure account
Exploring the Azure portal
What is Azure IoT Hub?
A quick tutorial on Azure IoT Hub
Creating an Azure IoT Hub
Connecting to Azure IoT Hub with the Device Explorer tool
Creating simulated sensor data using Python
Viewing usage from the Azure portal
Summary
Questions
Further reading
Using the Raspberry Pi with Azure IoT Edge
Installing Azure IoT Edge on the Raspberry Pi
Installing the Raspbian Stretch operating system
Downloading and flashing Stretch
Installing Stretch on the Raspberry Pi
Installing libraries needed for Azure IoT Edge
Installing the repository configuration
Installing the Moby container runtime
What is Moby?
Installing Moby onto our Raspberry Pi
Installing the Azure IoT Edge security daemon
Connecting our Raspberry Pi edge device
Creating an Azure IoT Edge resource
Creating an IoT Hub
Creating an Azure IoT Edge resource
Connecting the Raspberry Pi
Adding a simulated temperature sensor to our edge device
Adding a module to our edge device
Viewing telemetry data from our edge device
Summary
Questions
Further reading
Using MicroPython for Edge Analytics
Understanding MicroPython
Developing with Arduino C
Developing with MicroPython
MicroPython's REPL
Installing MicroPython on an ESP32
Using REPL with our ESP32
Exploring the hardware that runs MicroPython
Pyboard
ESP8266
ESP32
Pycom WiPy
Pycom LoPy
Using MicroPython for an edge analytics application
Connecting our edge device
Writing the edge code
Creating the edge device files
Understanding the edge device code
Creating the MQTT broker
Creating our gateway (ESP32 LoRa)
Creating the gateway files
Understanding the gateway code
LoRaMessage
HeaterStatus
Creating the dashboard
Putting it all together
Summary
Questions
Further reading
Machine Learning and Edge Analytics
Understanding machine learning and how it works with edge analytics
Machine learning libraries and tools
An example using OpenCV and the Raspberry Pi
Running the code
Explaining the code
Using edge intelligence with microcontrollers
Exploring the various models of camera-based microcontrollers
Using machine vision to read a QR code
Running the code
Explaining the code
Other offerings of machine learning and Azure IoT Edge
Azure Machine Learning designer
Azure IoT Edge custom vision
Summary
Questions
Further reading
Designing a Smart Doorbell with Visual Recognition
Setting up the environment
Understanding the application
Setting up the development environment
Creating a Python virtual environment
Installing the required libraries
OpenCV for Python
face_recognition
paho-mqtt
Writing the edge code
Creating the Face class
Creating the Message class
The Camera script
Creating the Node-RED dashboard
Adding the components
The mqtt in component
The function component
The text dashboard component
The audio out component
Running the application
Summary
Questions
Further reading
Section 3: The Road Ahead
Security and Privacy in an Edge Analytics World
An overview of the Internet-of-Things security
Types of attacks against our edge analytics applications
Vulnerability issues
Sniffing
Spoofing
Protecting our edge analytics applications
Passwords and updates
Cross-site scripting and phishing attack prevention
Physical security
Using SSL certificates
Azure Security Center for IoT
Monitoring and auditing our edge analytics applications
Monitoring our edge analytics applications
Taking an audit of our edge analytics devices
Summary
Questions
Further reading
What Next?
Recapping what we have learned about edge analytics
Chapter 1
Chapter 2
Chapter 3
Chapter 4
Chapter 5
Chapter 6
Chapter 7
Chapter 8
Chapter 9
Looking at the future of edge analytics
A day in the life of Oliver
What will your future be like?
Other Books You May Enjoy
Leave a review - let other readers know what you think
Edge analytics has gained attention as the IoT model for connected devices and is rising in popularity. This guide will give you insights into edge analytics as a data analysis model, and why it's gaining momentum.
You'll begin with the key concepts and components used in an edge analytics app. You'll then delve into communication protocols to understand how sensors send their data to computers or microcontrollers. Next, the book will demonstrate how to design modern edge analytics apps that take advantage of the processing power of modern single-board computers and microcontrollers. Later, you'll explore Microsoft Azure IoT Edge, MicroPython, and the OpenCV visual recognition library. As you progress, you'll cover techniques for processing and AI functionality from the server side to the sensory side of IoT. You'll even explore how to design a smart doorbell system using the technologies you will have learned about. To remove vulnerabilities in the overall edge analytics architecture, you'll discover ways to overcome security and privacy challenges. Finally, you'll use tools to audit and perform real-time monitoring of incoming data and generate alerts for the infrastructure.
By the end of this book, you'll have learned how to use edge analytics programming techniques and implement automated analytical computations.
If you are a data analyst, data architect, or data scientist who is interested in learning and practicing advanced automated analytical computations, then this book is for you. You will also find this book useful if you're looking to learn edge analytics from scratch. Basic knowledge of data analytics concepts is assumed and required to get the most out of this book.
Chapter 1, Introduction to Edge Analytics, outlines how everything old is new again! The rise of the personal computer in the 1980s and 1990s led to a revolution in computing. Instead of so-called dumb terminals connected to a large computer, many computers were connected in a network spreading the processing power around. Edge analytics is like the personal computer revolution but for Internet-of-Things (IoT) devices. We will start this chapter by comparing edge analytics to the computer revolution before we discuss the advantages of using edge analytics in an IoT application. We will both look at the basic edge analytics architecture and introduce the Microsoft Azure IoT Edge platform.
Chapter 2,How Does IoT Edge Analytics Work?, discusses the components used in an edge analytics application and how they fit together. Now that we understand what edge analytics is, let's turn our attention to how it works. In this chapter, we will conclude by looking at real-world edge analytics applications.
Chapter 3,Communications Protocols Used in Edge Analytics, outlines how one part of an IoT or edge analytics application is the connection to the internet. The other part is the connection from our edge device to the sensors. In this chapter, we will explore ways by which we can connect our edge device to the internet. We will look at some of the long-distance technologies, as well as the familiar Wi-Fi protocol. In our exploration of Wi-Fi, we will gain an understanding as to the radio frequency spectrum and where different communication protocols fit into this spectrum. We will also take a look at Bluetooth and consider how we may use it in our applications.
Chapter 4,Working with Microsoft Azure IoT Hub, is the beginning of our work with Azure IoT services using Microsoft Azure, after Chapter 1, Introduction to Edge Analytics, where we touched on Azure IoT Edge and Azure IoT. The lessons learned from this will provide a good basis for using the Raspberry Pi with Azure IoT Edge.
Chapter 5,Using the Raspberry Pi with Azure IoT Edge, builds on what we covered in Chapter 4, Working with Microsoft Azure IoT Hub, where we learned a bit about Microsoft Azure and the IoT Hub in Azure. This background is essential to understanding Azure IoT Edge. In this chapter, we will learn how to install Azure IoT Edge on the Raspberry Pi and read data from it using the Microsoft Device Explorer.
Chapter 6,Using MicroPython for Edge Analytics, covers MicroPython as a subset of Python 3. MicroPython was developed as a programming language for microcontrollers. With microcontrollers getting more and more powerful, learning MicroPython is becoming more essential. Imagine having the ability to take your Python knowledge and apply it to the physical world. Imagine building lightweight, energy-efficient, and powerful edge analytics applications with all the advantages of using the Python programming language. With MicroPython, you can.
Chapter 7,Machine Learning and Edge Analytics, considers one of the most exciting fields in the realm of technology today—machine learning. As this technology matures and gets into the hands of more and more people, exciting new applications are created, such as a tool for detecting respiratory diseases based on audio analysis of breathing patterns.
By combining edge analytics with machine learning, the capabilities on the sensory side are vast. This, combined with the ever-increasing power of microcontrollers and single-board computers such as the Raspberry Pi, means that the future looks very bright indeed for edge analytics and machine learning.
In this chapter, we will explore the advantages of machine learning at the edge with a Raspberry Pi as we write a program to distinguish between the face of a person and the face of a dog. We will then jump into the exciting new world of Artificial Intelligence of Things (AIoT) as we take a small microcontroller and turn it into a QR code decoder tool.
Chapter 8,Designing a Smart Doorbell with Visual Recognition, remembers how years ago, the only way to recognize who was knocking at your door without being too obvious was to peer through a little peephole near the top of the door. Observant visitors would notice the light disappear from the peephole once a face was pressed up against it on the other side. So, in other words, we really weren't fooling anyone into thinking we weren’t home if we decided that the visitor was not worthy of us opening the door. Times have certainly changed. We have the technology now to filter unwanted visitors for us without being detected. Using a camera and vision recognition algorithms on the sensory side, we will design an edge analytics application that alerts us to who is at the door.
Chapter 9,Security and Privacy in an Edge Analytics World, covers how, when deploying an application to the internet, the risks posed by cybercriminals should be taken very seriously. Internet-enabled devices including edge computers are prone to cyber-attacks where they may be used to shut down websites or cause havoc on the internet, not to mention the destruction of our networked applications. In this chapter, we will cover security and in turn, privacy, when it comes to our edge analytics applications.
Chapter 10,What Next?, examines where we are at the end of our edge analytics journey. I hope you enjoyed the ride. Tell them what you are going to tell them, tell them, and then tell them what you just told them—those are the great words of wisdom given to me by the more seasoned speakers at my Toastmasters club. In this chapter, we will recap what we have learned and then look ahead to the future of edge analytics.
To get the most out of this book, having the following will be beneficial:
In
Chapter 2
,
How Does IoT Edge Analytics
Work?
,
we will use an ESP8266 with an RGB LED to create a weather forecasting application.
In
Chapter 5
,
Using the Raspberry Pi with Azure IoT Edge
, we will install Azure IoT Edge onto a Raspberry Pi 3B+. Although there is a newer version of the Raspberry Pi (the Raspberry Pi 4), the Raspberry Pi 3B+ will be needed in order to install an older version of the Raspbian operating system.
A computer with Windows installed will be needed to run the Microsoft Device Explorer tool that we will use in
Chapter 4
,
Working with Microsoft Azure IoT Hub
, and
Chapter 5
,
Using the Raspberry Pi with Azure IoT Edge.
The purchase of an ESP32 with LoRa and the Pycom LoPy/LoPy 4 will assist in
Chapter 6
,
Using MicroPython for Edge Analytics
, as we cover MicroPython and microcontrollers.
A webcam will be used in
Chapter 8
,
Designing a Smart Doorbell with Visual Recognition
,
as we build our smart doorbell application.
Software/hardware covered in the book
OS requirements
Raspberry Pi 3B+
Raspbian Stretch
Pycom LoPy / LoPy 4
Latest MicroPython firmware from Pycom
ESP32 with LoRa
Latest version of MicroPython
ESP8266
Default firmware
RGB LED
DHT11 temperature sensor
PC
Windows 10 and Node-RED
If you are using the digital version of this book, we advise you to type the code yourself or access the code via the GitHub repository (link available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.
You can download the example code files for this book from your account at www.packt.com. If you purchased this book elsewhere, you can visit www.packtpub.com/support and register to have the files emailed directly to you.
You can download the code files by following these steps:
Log in or register at
www.packt.com
.
Select the
Support
tab.
Click on
Code Downloads
.
Enter the name of the book in the
Search
box and follow the onscreen instructions.
Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:
WinRAR/7-Zip for Windows
Zipeg/iZip/UnRarX for Mac
7-Zip/PeaZip for Linux
The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Hands-On-Edge-Analytics-with-Azure-IoT. In case there's an update to the code, it will be updated on the existing GitHub repository.
We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://static.packt-cdn.com/downloads/9781838829902_ColorImages.pdf.
There are a number of text conventions used throughout this book.
CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "The LoRaMessage class is used to send LoRa messages to the gateway device."
A block of code is set as follows:
import pycomimport timepycom.heartbeat(False)while True: pycom.rgbled(0xFF0000) # Red time.sleep(1) pycom.rgbled(0x00FF00) # Green time.sleep(1) pycom.rgbled(0x0000FF) # Blue time.sle
Any command-line input or output is written as follows:
$ sudo apt-get update
$ sudo apt-get install moby-engine
Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "Review your instance before clicking on the green+ Create New Instance button."
Feedback from our readers is always welcome.
General feedback: If you have questions about any aspect of this book, mention the book title in the subject of your message and email us at [email protected].
Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/support/errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.
Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.
If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.
Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!
For more information about Packt, please visit packt.com.
What is edge analytics? How does understanding edge analytics help me as a developer? If such questions come to mind for you, then the following chapters will assist you in understanding this exciting new technology.
This section comprises the following chapters:
Chapter 1
,
Introduction to Edge Analytics
Chapter 2
,
How Does IoT Edge Analytics Work?
Chapter 3
,
Communication Protocols Used in Edge Analytics
Everything old is new again! The rise of the personal computer (PC) in the 1980s and 1990s led to a revolution in computing. Instead of so-called dumb terminals connected to a large computer, many computers were connected in a network, spreading the processing power around. Edge analytics is like the personal computer revolution, but for IoT (Internet of Things) devices. We will start this chapter by comparing edge analytics to the computer revolution before we discuss the advantages of using edge analytics in an IoT application. We will look at the basic edge analytics architecture, as well as introduce the Microsoft Azure IoT Edge platform.
This chapter will cover the following topics:
What is edge analytics?
Applying and comparing architectures
Key benefits of edge analytics
Edge analytics architectures
Using edge analytics in the real world
In order to build on the statement that edge analytics is