Book Image

Internet of Things Programming with JavaScript

Book Image

Internet of Things Programming with JavaScript

Overview of this book

The Internet of Things is taking the tech world by storm, and JavaScript is at its helm. This book will get you to grips with this exciting new technology. Where do Node.js, HTML5 and Windows 10 IoT Core come in with JavaScript and IoT? Why Raspberry Pi Zero rather than Arduino? How do you configure and build an IoT network from scratch? All your IoT JavaScript questions are answered in this book.
Table of Contents (15 chapters)
Internet of Things Programming with JavaScript
Credits
About the Author
www.packtpub.com
Customer Feedback
Preface

Preface

The Raspberry Pi Zero is a powerful, low-cost, credit-card sized computer, which lends itself perfectly to begin the controller of sophisticated home automation devices. Using the available on-board interfaces, the Raspberry Pi Zero can be expanded to allow the connection of a virtually infinite number of security sensors and devices.

Since the Arduino platform is more versatile and useful for making projects, including the networking applications of the Internet of Things, this is what we will see in this book: the integration of devices connected to the nodes using the amazing and important Arduino board, and how to integrate the Raspberry Pi Zero to control and monitor the devices from a central interface working as a hub. With software programming you will create an Internet of Things system based in developing technologies such as JavaScript, HTML5, and Node.js.

This is exactly what I will teach you to do in this book. You will learn how to use the Raspberry Pi Zero board in several home domotics projects in order for you to build your own.

The books guides you, making the projects in each chapter from preparing the field, the hardware, the sensors, the communication, and the software programming-control in order to have a complete control and monitoring system.

What this book covers

Chapter 1, Getting Started with Raspberry Pi Zero, describes the procedure to set up the Raspberry Pi and the Arduino board, and how to communicate among the devices. We will install and set up the operating system, connect our Pi to the network, and access it remotely. We'll also secure our Pi and make sure it can keep the right time.

Chapter 2, Connecting Things to the Raspberry Pi Zero, shows how to connect signals to the Raspberry Pi Zero and Arduino. It explores the GPIO port and the various interfaces it features. We'll look at the various things we can connect to the Raspberry Pi using the GPIO.

Chapter 3, Connecting sensors - Measure the Real Things, shows how to implement the sensors for detecting different kinds of signal, for security systems, flow current for energy consumption, detecting some risk in the home, implementing  a gas sensor, flow water sensor to measure water volume, and will also show how to make a security system that will control entrance to the home with a fingerprint sensor.

Chapter 4, Control-connected devices, shows how to control your Arduino board, using modules of communication in a networking area from the Raspberry Pi Zero in a central interface dashboard.

Chapter 5, Adding a Webcam to Monitor Your Security System, shows how to configure a webcam connected to your board to monitor your security system for the Internet of Things.

Chapter 6, Building a Web Monitor and Controlling Devices from a Dashboard, shows how to set up a system to monitor your security system using web services. Integrating the Raspberry Pi Zero with Arduino to build a complete system connected-devices and monitor.

Chapter 7, Building a Spy Police with the Internet of Things dashboard, shows how to make different mini home domotics projects and how to connect web services and monitor your security system using the Internet of Things.

Chapter 8, Monitor and Control your devices from a Smart Phone, explains how to develop an app for Smart Phone using Android Studio and APP inventor, and control your Arduino board and the Raspberry Pi Zero.

Chapter 9, Putting It All Together, shows how to put everything together, all the parts of the project, the electronics field, software configurations, and power supplies.

What you need for this book

You’ll need the following software:

  • Win32 Disk Imager 0.9.5 PuTTY

  • i2C-tools

  • WiringPi2 for Python

  • Node.js 4.5 or later

  • Node.js for Windows V7.3.0 or later

  • Python 2.7.x or Python 3.x

  • PHP MyAdmin Database

  • MySQL module

  • Create and account in Gmail so that you can get in APP Inventor

  • Android Studio and SDK modules

  • Arduino software

In the first chapters, we explain all the basics so you will have everything configured and will be able to use the Raspberry Pi Zero without any problems, so you can use it for the projects in this book. We will use some basic components, such as sensors, and move to more complex components in the rest of the book.

On the software side, it is good if you actually have some existing programming skills, especially in JavaScript and in the Node.js framework. However, I will explain all the parts of each software piece of this book, so even if you don't have good programming skills in JavaScript you will be able to follow along.

Who this book is for

This book is for all the people who want to automate their homes and make them smarter, while at the same time having complete control of what they are doing. If that's your case, you will learn everything there is to learn in this book about how to use the amazing Raspberry Pi Zero board to control your projects.

This book is also for makers who have played in the past with other development boards, such as Arduino. If that's the case, you will learn how to use the power of the Raspberry Pi platform to build smart homes. You will also learn how to create projects that can easily be done with other platforms, such as creating a wireless security camera with the Pi Zero.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "Extract 2015-09-24-raspbian-jessie.img to your Home folder." 

A block of code is set as follows:

# passwd
root@raspberrypi:/home/pi# passwd
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
        root@raspberrypi:/home/pi#

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

[default]
exten => s,1,Dial(Zap/1|30)
exten => s,2,Voicemail(u100)
exten => s,102,Voicemail(b100)
exten => i,1,Voicemail(s0)

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

        sudo npm install express request

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this:

"You can now just click on Stream to access the live stream from the camera."

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book-what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail [email protected], and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

You can download the code files by following these steps:

  1. Log in or register to our website using your e-mail address and password.

  2. Hover the mouse pointer on the SUPPORT tab at the top.

  3. Click on Code Downloads & Errata.

  4. Enter the name of the book in the Search box.

  5. Select the book for which you're looking to download the code files.

  6. Choose from the drop-down menu where you purchased this book from.

  7. Click on Code Download.

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/Internet-of-Things-Programming-with-Javascript. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/downloads/InternetofThingsProgrammingwithJavascript_ColorImages.pdf.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books-maybe a mistake in the text or the code-we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at [email protected] with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at [email protected], and we will do our best to address the problem.