Book Image

Mastering IOT

By : Colin Dow, Perry Lea
Book Image

Mastering IOT

By: Colin Dow, Perry Lea

Overview of this book

The Internet of Things (IoT) is the fastest growing technology market. Industries are embracing IoT technologies to improve operational expenses, product life, and people's well-being. We’ll begin our journey with an introduction to Raspberry Pi and quickly jump right into Python programming. We’ll learn all concepts through multiple projects, and then reinforce our learnings by creating an IoT robot car. We’ll examine modern sensor systems and focus on what their power and functionality can bring to our system. We’ll also gain insight into cloud and fog architectures, including the OpenFog standards. The Learning Path will conclude by discussing three forms of prevalent attacks and ways to improve the security of our IoT infrastructure. By the end of this Learning Path, we will have traversed the entire spectrum of technologies needed to build a successful IoT system, and will have the confidence to build, secure, and monitor our IoT infrastructure. This Learning Path includes content from the following Packt products: Internet of Things Programming Projects by Colin Dow Internet of Things for Architects by Perry Lea
Table of Contents (34 chapters)
Title Page
Copyright
About Packt
Contributors
Preface
Free Chapter
1
The IoT Story
Index

Preface

The Internet of Things (IoT) is the fastest growing technology market. Industries are embracing IoT technologies to improve operational expenses, product life, and people's well-being.

We’ll begin our journey with an introduction to Raspberry Pi and quickly jump right into Python programming. We’ll learn all concepts through multiple projects, and then reinforce our learnings by creating an IoT robot car. We’ll examine modern sensor systems and focus on what their power and functionality can bring to our system. We’ll also gain insight into cloud and fog architectures, including the OpenFog standards. The Learning Path will conclude by discussing three forms of prevalent attacks and ways to improve the security of our IoT infrastructure.

By the end of this Learning Path, we will have traversed the entire spectrum of technologies needed to build a successful IoT system, and will have the confidence to build, secure, and monitor our IoT infrastructure.

 

 

This Learning Path includes content from the following Packt products:

  • Internet of Things Programming Projects by Colin Dow
  • Internet of Things for Architects by Perry Lea

Who this book is for

This Learning Path is designed for developers, architects, and system designers who are interested in building exciting projects with Python by understanding the IoT ecosphere, various technologies, and tradeoffs. Technologists and technology managers who want to develop a broad view of IoT architecture, will also find this Learning Path useful. Prior programming knowledge of Python is a must.

What this book covers

Chapter 1, The IoT Story, introduces us to the growth, the importance, and the impact of the IoT from a narrative and historical perspective. We will also learn of use cases in various areas including industrial IoT, smart cities, transportation, and healthcare.

Chapter 2, IoT Architecture and Core IoT Modules, presents the overall picture of the combination of technologies covered in this book. Each segment has a purpose and can unknowingly affect each other. This is an important chapter for an architect to under the “big picture” of inter-related technologies. This chapter also explores the ways to place a value on IoT.

Chapter 3, Sensors, Endpoints, and Power Systems, explores billions of edge endpoints and sensor technologies that will be placed on the internet. Fundamentals of sensor designs, architectures, and power systems are taught.

Chapter 4, Communications and Information Theory, will review important material on the dynamics and mathematical models that define communication systems important to IoT. We will understand the theory behind architectural decisions in selecting the proper forms of telecommunication.

Chapter 5, Non-IP-Based WPAN, discusses all the major non-IP-based protocols and technologies at the IoT Edge. This chapter includes a deep review of the new Bluetooth 5 architecture, Zigbee, Z-Wave, and mesh topologies for sensor networks.

Chapter 6, IP-Based WPAN and WLAN, will complete the near-range communication with a treatment of IP-based communication, including 6LoWPAN, Thread, and IEEE 802.11 standards. This chapter also details new 802.11 protocols such as 802.11p for vehicular communication and 802.11ah for IoT.

Chapter 7, Long-Range Communication Systems and Protocols (WAN), covers wide area network and long-range communication transport data from things to the cloud. This chapter covers in detail all the cellular LTE standards, LoRaWAN, Sigfox, as well as new LTE narrowband and 5G architectures.

Chapter 8, Routers and Gateways, discusses the importance of edge routing and gateway functions. This chapter explores routing systems, gateway functions, VPNs, VLANs, and traffic shaping, and it covers software-defined networking.

Chapter 9, IoT Security, covers security from a holistic view for every IoT component covered in this book. We will understand the theory and architecture of protocol, hardware, software-defined perimeter, and block-chain security.

Chapter 10, Installing Raspbian on the Raspberry Pi, sets us off on our Raspberry Pi IoT journey by installing the Raspbian OS on our Raspberry Pi. We will then take a look at some of the programs that come pre-installed with Raspbian.

Chapter 11, Writing Python Programs Using Raspberry Pi, covers how Windows, macOS, and Linux are operating systems that are familiar to developers. Many a book on developing the Raspberry Pi involves using one of these operating systems and accessing the Raspberry Pi remotely. We will take a different approach in this book. We will use our Raspberry Pi as a development machine. In this chapter, we will get our feet wet with using the Raspberry Pi as a development machine.

Chapter 12, Using the GPIO to Connect to the Outside World, explains how, if the Raspberry Pi was just a $35 computer, that would be enough for many of us. However, the real power behind the Raspberry Pi is the ability of the developer to access the outside world through the use of the General Purpose Input Output (GPIO) pins. In this chapter, we will delve into the GPIO and start to connect the Raspberry Pi to the real world. We will create a Morse code generator for our project using an outside LED and then use this generator to blink out simulated weather information.

Chapter 13, Subscribing to Web Services, explores a few web services offered by some of the biggest companies in the world. Our project will use the virtual version of the Raspberry Pi Sense HAT as a ticker to display current weather information from the Yahoo! Weather web service.

Chapter 14, Controlling a Servo with Python, introduces the concept of creating an analog meter needle using a servo motor connected to the Raspberry Pi.

Chapter 15, Working with the Servo Control Code to Control an Analog Device, continues the theme of working with servo motors as we build our first real IoT device, a weather dashboard. Not only will this weather dashboard feature an analog needle; it will use the needle to point to a picture of a suggested wardrobe based on the weather conditions.

Chapter 16, Setting Up a Raspberry Pi Web Server, goes into how to install and configure the web framework CherryPy. We will conclude the chapter by building a local website that displays weather information.

Chapter 17, Reading Raspberry Pi GPIO Sensor Data Using Python, covers how to read the state of a button before moving on to a PIR sensor and distance sensor. We will conclude the chapter by building simple alarm systems.

Chapter 18, Building a Home Security Dashboard, explains how to build a home security dashboard using the Raspberry Pi as a web server serving up HTML content containing sensory data collected from the GPIO.

Chapter 19, Publishing to Web Services, goes into how to measure room temperature and humidity and publish these values to the web through the use of an IoT dashboard. We will also set up and run a text messaging alert using the service Twilio.

Chapter 20, Creating a Doorbell Button Using Bluetooth, turns our focus to using Bluetooth in this chapter. Bluetooth is a wireless technology that allows for transmission of data over short distances. For our project we will explore the BlueDot app from the Android Play Store. We will use this app to build a simple Bluetooth connected doorbell.

Chapter 21, Enhancing Our IoT Doorbell, will take the simple doorbell we created in Chapter 20, Creating a Doorbell Button Using Bluetooth, and turn it into an IoT doorbell using the knowledge we learned in Chapter 19, Publishing to Web Services.

Chapter 22, Introducing the Raspberry Pi Robot Car, starts us off on our journey into the IoT robot car by introducing This Amazing Raspberry-Pi Automated Security Agent (T.A.R.A.S). This chapter will begin by outlining the components we need to build T.A.R.A.S and then we will proceed to putting it all together.

Chapter 23, Controlling the Robot Car Using Python, goes into how to write Python code for our robot car. We will utilize the GPIO Zero library to make the car wheels move forward, move the servo motors holding the camera, and light up the LEDs at the back of the robot car.

Chapter 24, Connecting Sensory Inputs from the Robot Car to the Web, helps us understand that in order to turn our robot car into a true IoT device we have to connect it to the internet. In this chapter, we will connect the distance sensor from our robot car to the internet.

Chapter 25, Controlling the Robot Car with Web Service Calls, continues to turn our robot car into an Internet of Things device by taking a deeper look at the internet dashboard we created for the robot car.

Chapter 26, Building the JavaScript Client, moves our attention away from Python, switching our focus to JavaScript instead. We will use JavaScript to build a web-based client that communicates over the internet using the MQTT protocol.

Chapter 27, Putting It All Together, covers how we will connect our robot car, T.A.R.A.S, to a JavaScript client, and control it over the internet using the MQTT protocol.

To get the most out of this book

There are several examples of hardware design and coding examples in this book. Most of the coding examples are pseudo-code based on Python syntax. Having familiarity with some foundational calculus, information theory, electrical properties, and computer science can only help us gain a deeper insight into IoT from an architectural perspective. To get the most out of this book, you should have a Raspberry Pi Computer, preferably a 2015 model or newer and basic electronic components. You have a basic familiarity with electronic components and how to use a breadboard.

Download the example code files

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.packt.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at www.packt.com.
  2. Select the SUPPORT tab.
  3. Click on Code Downloads & Errata.
  4. 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/Mastering-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!

Download the color images

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://www.packtpub.com/sites/default/files/downloads/9781838645434_ColorImages.pdf.

Conventions used

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: "It's a good idea to run both of these commands right after installing Raspbian using the sudo command."

A block of code is set as follows:

from time import sleep
import Adafruit_DHT
import paho.mqtt.client as mqtt
import json

Any command-line input or output is written as follows:

pip3 install weather-api

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: "In the previous screenshot, we clicked on the Language option."

 

Note

Warnings or important notes appear like this.

Note

Tips and tricks appear like this.

Get in touch

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.packt.com/submit-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.

Reviews

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.