Explore 1.5M+ audiobooks & ebooks free for days

Only $12.99 CAD/month after trial. Cancel anytime.

The Internet of Things: Do-It-Yourself at Home Projects for Arduino, Raspberry Pi and BeagleBone Black
The Internet of Things: Do-It-Yourself at Home Projects for Arduino, Raspberry Pi and BeagleBone Black
The Internet of Things: Do-It-Yourself at Home Projects for Arduino, Raspberry Pi and BeagleBone Black
Ebook643 pages12 hours

The Internet of Things: Do-It-Yourself at Home Projects for Arduino, Raspberry Pi and BeagleBone Black

Rating: 0 out of 5 stars

()

Read preview

About this ebook

Build and program projects that tap into the Internet of Things (IoT) using Arduino, Raspberry Pi, and BeagleBone Black!

This innovative guide gets you started right away working with the most popular processing platforms, wireless communication technologies, the Cloud, and a variety of sensors. You’ll learn how to take advantage of the utility and versatility of the IoT and connect devices and systems to the Internet using sensors. Each project features a list of the tools and components, how-to explanations with photos and illustrations, and complete programming code. All projects can be modified and expanded, so you can build on your skills.

The Internet of Things: DIY Projects with Arduino, Raspberry Pi, and BeagleBone Black

  • Covers the basics of Java, C#, Python, JavaScript, and other programming languages used in the projects
  • Shows you how to use IBM’s Net Beans IDE and the Eclipse IDE
  • Explains how to set up small-scale networks to connect the projects to the Internet
  • Includes essential tips for setting up and using a MySQL database.

The fun, DIY projects in the book include:

  • Raspberry Pi home temperature measurements
  • Raspberry Pi surveillance webcams
  • Raspberry Pi home weather station
  • Arduino garage door controller
  • Arduino irrigation controller
  • Arduino outdoor lighting controller
  • Beaglebone message panel
  • Beaglebone remote control SDR
  • Machine-to-machine demonstration project
LanguageEnglish
PublisherMcGraw-Hill Education
Release dateJan 30, 2015
ISBN9780071835213
The Internet of Things: Do-It-Yourself at Home Projects for Arduino, Raspberry Pi and BeagleBone Black

Read more from Donald Norris

Related to The Internet of Things

Related ebooks

Electrical Engineering & Electronics For You

View More

Reviews for The Internet of Things

Rating: 0 out of 5 stars
0 ratings

0 ratings0 reviews

What did you think?

Tap to rate

Review must be at least 10 words

    Book preview

    The Internet of Things - Donald Norris

    Introduction

    Isuppose the genesis of this book was from long-term interest in connecting computers to the Internet. Back in the early 1990s, I experimented with a variety of single-board computers that would connect, in a fashion, to the Internet and serve up relatively simple web pages. They didn’t have the sophistication or capabilities of today’s single-board systems exemplified by the Raspberry Pi or the BeagleBone Black boards. But they worked and provided useful platforms to experiment using simple computing devices in lieu of full-scale PC-based servers or desktop clients. Roll forward almost twenty years and there are now quite a few highly capable and functional systems, which can easily fulfill the promise of the Internet of Things, or IoT for short. I describe the IoT in the first chapter in yet another attempt at defining a somewhat nebulous phrase, which truly means different things to different people. I also took a somewhat different approach with this IoT book in that I used three separate platforms to implement the various demonstration projects. My initial thought was to demonstrate how one platform could have strengths in one area while another would be better suited to another area. However, what I found was that the platforms had much more in common than they were different. In fact, the Raspberry Pi and the BeagleBone Black boards are just about identical from a software prospective. Let me now present a glimpse into what awaits you in this book.

    In Chapter 1, I present a high-level view of what constitutes the IoT. I also introduce the Raspberry Pi (Pi) board, which is the first one of the three development platforms used in the book’s projects. The LAMP framework is also introduced, which allows you to create a comprehensive data acquisition system that can not only take sensor measurements, but allows them to be stored in a relational database and later makes that data available via a web interface.

    I show you how to build and remotely access a home temperature measurement system in Chapter 2. This system uses the LAMP framework, which was introduced in Chapter 1, as its basis. Analog-to-digital conversion appropriate for the Pi is also discussed and demonstrated. A program written with Python controls the system to help simplify this project. Again, all the temperature system data is available via a web page.

    As a computer science/information technology instructor, I have found that many of my beginning students really do not have a good understanding of the nature of OO and why they should even have to learn it. Chapter 3 contains an introduction to object-oriented (OO) programming using the Java language, which should help you understand the program presented in Chapter 4. This chapter’s content will also help you gain more insight into what makes up OO and how to properly use it.

    Chapter 4 explores the principles and concepts discussed in the previous chapter, and applies them in the construction and operation of a home weather station, which uses the Pi as a controller. The Pi also is programmed using the Java language, which was just recently ported over to the Pi by the software developers at Oracle. The latest software Linux Wheezy distributions, which run on the Pi, all contain a fully functional Java runtime. I also discuss how to program the general-purpose input/output (GPIO) pins to implement the weather station interface. Programming this interface is only made possible by the use of a very clever Java library named Pi4J.

    Chapter 5 covers three projects involving a webcam and the Pi camera. The purpose of these projects is to demonstrate how to implement remote video viewing using the Pi as a controller. The first project uses a generic USB webcam along with a comprehensive Linux software suite named Motion. The Motion software package provides for literally a plug-and-play situation where the webcam video can be viewed in real time via a standard web browser in a matter of a few minutes; no soldering or construction required. The second chapter project uses the Raspberry Pi camera accessory with its standard driver software to again implement a remote video viewer. The last project in this series again uses the Pi camera, but this time I use the Motion software in lieu of the standard driver software. This demonstrates Motion’s flexibility and capability to interface to a variety of video devices.

    The next chapter introduces the Arduino board, which is the next development platform used in this book. I briefly discuss the Arduino board features, as I realize that most of my readers are already very familiar with its operation and probably have one or two in their workshop. This chapter’s demonstration project is a garage door opener, which may be actuated via a web browser. I also show you how to use a smartphone to control the garage door. In addition, some security in the form of a password is added to this project as you probably don’t want strangers operating your garage door.

    Chapter 7 covers an Arduino-controlled home irrigation system. This system builds on some of the concepts discussed in Chapter 6 for the garage door opener and also shows you how to incorporate a wireless sensor into the overall control scheme. This system allows a homeowner to remotely activate a specific irrigation zone using only a web browser. It also further expands the homeowner’s options by reporting the current soil moisture content via a web page so that the user can make a decision on whether or not to turn on an irrigation zone.

    Chapter 8 focuses on both remote activation of lights or other similar devices and the capability of locating these controlled devices anywhere in the home without using wires. Arduino boards are used in multiple locations for this project. Some boards control wireless XBee nodes, which allow for the flexible placement of lights within the home. Another Arduino board implements the main controller, which connects to the Internet to enable remote light activation via a web page. There is also a four-channel key fob RF device used in this system that allows a homeowner to quickly and directly activate up to four lights without the need to use the Internet.

    I next introduce the BeagleBone Black (BBB) boards in Chapter 9. This is the third and last development platform used in the book projects. This chapter’s project is a simple demonstration that displays only a line of text on an LCD, which has been sent from a web browser. The chapter focus is to discuss the BBB and compare it to the Raspberry Pi, which seems to be its principal competitor. The BBB used in this project used the same Debian, Wheezy, Linux distribution as was used in earlier Pi projects. This demonstrates that at least these two boards are more similar than different. The BBB does incorporate some features such as analog-to-digital conversion (ADC), which are not present in the Pi and must be externally added if needed. In addition, the BBB’s standard clock rate is 1 GHz while the Pi’s normal clock is set at 700 MHz. The Pi may be overclocked to approximately 1 GHz, if desired, but that does increase power consumption and heat generation. The Pi does run cooler and consumes less power than the BBB, which are important considerations for portable, battery-operated applications.

    Connecting the BBB to a cloud service is the chief topic in Chapter 10. I used the same temperature monitoring system, which was shown with the Pi in Chapter 2. However, in this project, the data is streamed real-time to a cloud-based service named Xively. In the Pi project, the data was stored in a local MySQL database. The BBB sensor data is streamed to Xively for storage and later retrieval as desired. Xively also provides several web interfaces that make it easy for users to both examine and manipulate sensor data as needed. The Xively developer version is free with unlimited data storage, which should suffice for most experimenters and hobbyists.

    The final chapter deals with machine-to-machine (M2M) communications, which happens when two or more fully automated computer systems interchange data without any human involvement. This chapter’s project uses the same temperature measurement system used in previous projects. Transferring data also requires a protocol to be used, which will ensure that data is successfully sent and received. This project uses the open-source MQTT protocol, which is an excellent, lightweight data protocol currently used by Facebook and several national wireless carriers for sending alert messages. This demonstration project uses a single channel BBB temperature measurement system to indirectly send data to a Pi system. The Pi system accesses the data from any one of a number of MQTT broker websites, which are freely available to handle MQTT message traffic.

    I hope these ten chapters open your desire to experiment and further explore this exciting and ever-expanding area.

    Don Norris

    1

    CHAPTER

    Introduction to the Internet of Things

    This book offers useful projects that you can build and then experiment with, using the Internet to both receive data from and/or provide control commands to devices. The Internet of Things (IoT) is a phrase that was first used in 1999 by Kevin Ashton while he was working at MIT’s Media Center. He meant it to represent the concept of computers and machines with sensors, which connect to the Internet to report status and accept control commands. The IoT, in reality, has been around for a long time, but it didn’t have a name. Machine-to-machine (M2M) communications has been in existence for many decades, often using dedicated networks that eventually converged over to the Internet. IoT is also referred to with different names, such as Ubiquitous Computing and the Internet of Everything. No matter what the name, IoT is here to stay and is progressively affecting more people in their everyday activities as time progresses.

    Many books are in print and in digital media that discuss the overall ramifications of IoT upon society and where it is leading all of us. There are also books published that claim to guide you on how to make a fortune by monetizing your clever IOT project. This is not one of those books, as I mentioned in the foreword. My focus is on creating useful projects that take advantage of the tremendous communication capabilities provided by an Internet connection. My approach also differs from other IoT authors by using three separate hardware platforms, which provide project control. I should note that the Arduino platform uses three slightly different implementations for Internet connectivity, which I classified as one platform. Using different platforms was a deliberate and purposeful decision on my part to show you what is involved in creating projects using different development infrastructures yet still establishing a working Internet connection. You will likely appreciate one approach over the others. These three hardware and software development platforms are listed in Table 1-1.

    TABLE 1-1. IoT Project Hardware and Software Development Choices

    Creating a project that is equipped with sensors and is capable of both sending and receiving data via the Internet is a bit challenging, especially to those readers who are attempting to do so for the first time. Let’s start this journey with a discussion of hardware as that seems easiest for most folks to handle and is absolutely required for these projects.

    Raspberry Pi Platform

    The Raspberry Pi has been in existence for almost two years at the time of this writing. Over two million Pi platforms have been produced since it was introduced, which is not too shabby considering that the creator, Dr. Eben Upton, originally thought about 10,000 would be sold. I won’t go into extensive detail about the origins, history, and structure of the Pi, as I have already covered that subject in extensive detail in my recent book Raspberry Pi Projects for the Evil Genius. However, I will reiterate some key Pi concepts that are critical to your success in building the Pi projects, and it is always convenient to have the data immediately available and in one place. The Model B Raspberry Pi is the platform I strongly suggest for the Pi projects in this book (see Figure 1-1).

    FIGURE 1-1 Model B, Raspberry Pi board

    A cheaper model, A, is available but it does not have an onboard Ethernet port and only half the memory of the B model. Interestingly, neither one of these two constraints would prevent you from using the A model; however, you would need to provide a wireless USB adapter for Internet connectivity, and the diminished memory would certainly slow down the Pi applications while they were running.

    All the projects in this book, except for the first one, involve using some type of digital input and/or output to interface with sensors and actuators. All the different platforms used in the projects refer to these input/outputs as general purpose input output (GPIO). Each platform’s GPIO has somewhat different specifications as to the maximum voltage and current that can be handled, and I will strive to keep that very clear so as to avoid any possible damage to the project boards. Unfortunately, irreversible damage happens if you exceed the maximum voltage or current GPIO rating to a particular board, which will render it useless or non-operative.

    Raspberry Pi GPIO

    The Model B, rev 2 Raspberry Pi uses a multi-pin connector designated as P1 for its GPIO. This connector is shown in Figure 1-2 with the first two beginning and ending pin numbers annotated for orientation and reference.

    FIGURE 1-2 GPIO P1

    This multi-pin connector will be the gateway through which the Pi will interface with real-world devices. As you are probably aware, there must be software drivers loaded that provide the logical interface between the control program, operating system (OS), and the GPIO pins. The particular type of driver depends primarily upon the programming language used to develop the control program. I will be using both Python and Java to develop control programs so there will be a separate set of drivers loaded to accommodate each development environment. However, many GPIO pins in the P1 connector have multiple functions that extend beyond simple digital input and/or output. Figure 1-3 shows the functions associated with each of the P1 pins for the Model B, rev 2 Pi.

    FIGURE 1-3 P1 pin functions

    I will not review these pin functions at this time but will discuss them as they become relevant to a project. Incidentally, none of the projects connect directly with the P1 pins but instead rely on the use of a Pi Cobbler, which is plugged into a solderless breadboard. Figure 1-4 shows the Pi Cobbler adapter plugged into a solderless breadboard with the 26-conductor ribbon cable plugged into the Pi’s P1 connector.

    FIGURE 1-4 Pi Cobbler

    The Pi Cobbler is available from a variety of suppliers such as Adafruit Industries and MCM Electronics. You will have to assemble it by soldering a connector to the printed circuit board (PCB), which is not too difficult, and this task allows you to practice your soldering skills. Just don’t add too much solder to the connector pins as they are close together and it is easy to form a solder bridge, which might be disastrous to the Pi when you connect the Pi Cobbler to it.

    Although there are jumper wires shown connecting components on the solderless breadboard, I prefer to use manufactured jumper wires, as shown in Figure 1-5. These jumpers are very sturdy and can easily be inserted into the breadboard without the bending or crinkling that affect ordinary precut wires. Inexpensive jumper wire kits are also typically available from the same Pi Cobbler suppliers.

    FIGURE 1-5 Manufactured jumper wires

    Establishing a Raspberry Pi Development Station

    There are several ways to set up a Raspberry Pi development station, each with its own pros and cons. I will cover two approaches that will likely fulfill most users’ needs.

    Standalone Setup

    The first approach is what I call a standalone setup where you connect a keyboard, monitor, and mouse to the Pi. You will also need a powered USB hub and either a wireless Wi-Fi adapter or Ethernet patch cable that you can plug directly into your router. Figure 1-6 is a block diagram showing all the components needed for a standalone workstation.

    FIGURE 1-6 Raspberry Pi standalone workstation block diagram

    The Pi has both composite and HDMI video outputs. Most readers will elect to use the HDMI output as that provides a much superior video display as compared to the analog composite video output. You will need a HDMI to VGA converter module in case your monitor does not have an HDMI input. These converters are relatively inexpensive with a typical one available from Adafruit shown in Figure 1-7.

    FIGURE 1-7 HDMI to VGA converter module

    The Pi power supply is also worth discussing. I used a wall wart 5V 1A supply, which is more than adequate for providing sufficient current to the Pi as long as you do not attempt to power any external USB devices from either one of the two onboard USB ports. From my experience in using the Pi now for two years, I have found the board to be a bit sensitive to the quality and level of the 5V supply. Strange and frustrating events happen if the power supply droops to 4.75V or less, which is only a 5 percent drop. Often, simply swapping the power supply clears up mysterious and intermittent operational issues, which can lead to unproductive and hair-tearing development sessions. In Figure 1-7, I have included a note that mentions you can also power the Pi directly from the hub using a micro-USB/USB cable as long as the hub power supply is rated for a minimum of 2.5A. I have used the Pluggable series of powered hubs to do this in the past, one of which is shown in Figure 1-8.

    FIGURE 1-8 Plugable powered USB hub

    Any USB keyboard and mouse combination will suffice for user input. However, I did find the wireless Logitech K400 keyboard/mouse device to be a very handy and flexible combination. There were no issues with the Pi detecting this device and installing the proper driver. The K400 is inexpensive and is shown in Figure 1-9. I highly recommend this keyboard/mouse unit.

    FIGURE 1-9 Logitech K400 wireless keyboard/mouse unit

    I would like to mention the wireless Wi-Fi adapter that I have successfully used for a number of projects. It is the EDIMAX EW-7811Un and is shown in Figure 1-10. It is very inexpensive and seems to perform quite well for the relatively low-bandwidth projects I have used it in.

    FIGURE 1-10 EDIMAX model EW-7811Un USB Wi-Fi adapter

    You should note that it is rated at a maximum of 150 MBps, which is somewhat lower than other more expensive brands. However, none of the book projects require a very high bandwidth so why spend the money for performance you will not require?

    Headless Setup

    The second approach is not a gruesome Pi decapitation as the name suggests but a network-centric configuration to remotely control a Pi. For this approach you will need only a networked Pi and another computer. It doesn’t matter if the Pi is connected wired or wirelessly to your network. All you really need is the Internet protocol (IP) address that your router assigns to the Pi when it discovers it upon initial startup. Note that no keyboard, mouse, monitor, or powered hub is required for this setup. Just a Pi, a power supply, and either an Ethernet cable or a wireless Wi-Fi adapter are needed. Figure 1-11 is a block diagram showing all the headless components and their interconnections.

    FIGURE 1-11 Raspberry Pi headless workstation block diagram

    The secret to the simplicity of the headless setup is the software running both on the Pi and the computer used to communicate with the Pi. This software will be one of the items discussed in the following software section.

    The last hardware item to be discussed is the SD card that stores the software that the Pi needs to function. A standard 4GB SD card is the minimum required for Pi operations, but I feel strongly that you should use at least an 8 or 16GB card to have space for all of the book projects without having to delete any of them. It is fairly easy to add software whose memory requirements can quickly add up to the point where Pi operations could be adversely affected. However, don’t be deterred if you purchased a Raspberry Pi starter kit that came with a pre-built image 4GB SD card. It will be sufficient for all the book projects, but you might have to delete some early project files to ensure there is space for the later projects.

    SD cards are also rated for speed with a Class number. Table 1-2 shows the various classes and associated minimum data transfer speeds.

    TABLE 1-2 SD Card Class Designations

    Using a higher Class number of SD card in the Pi allows for much better performance. Just be mindful that SD cards with high Class numbers are more expensive than ones with lower numbers. However, the cost differential diminishes as time progresses. I strongly suggest you purchase at least a Class 4 or higher; anything less and you will be disappointed in how slow your Pi responds.

    Finally, don’t be worried about how to create an operational Pi SD card. I will show you in the software section how to download and store the latest software image onto a blank SD card. It really is quite easy and you will feel like an expert after a few downloads and stores.

    Setting Up the Raspberry Pi Software

    I will begin this section by assuming that you are starting out using a standalone workstation with a blank SD card. Your first step is to set up the SD card with a

    Enjoying the preview?
    Page 1 of 1