We are part of a generation where people have already started adapting to IoT products. There is a lot of hype about IoT. This book will focus on building IoT-based applications that will help you to achieve a higher level of understanding when it comes to IoT. It will follow a project-based approach that will teach you to build standalone exciting, applications and will also teach you to extend your project to another level. We are going to use JavaScript as our programming language and Raspberry Pi 3 as our hardware to build interesting IoT solutions.
Chapter 1, The World of IoT, introduces you to the world of IoT. We will be looking at the history of IoT, identifying a few use cases, and getting a technical overview of what were are going to cover in this book.
Chapter 2, IoTFW.js - I, walks you through how to build a reference framework for developing IoT solutions using JavaScript. In this chapter, we cover the high-level architecture and get started with installing the required software. We will start with downloading the base application and stitching the Raspberry Pi together with the MQTTS broker and API engine.
Chapter 3, IoTFW.js - II, continues from where we left off in the previous chapter and completes the implementation of the API engine, web app, desktop app, and mobile app. At the end of this chapter, we implement a simple example with an LED and a temperature sensor, where instructions from the apps will turn the LED on/off and the value of the temperature sensor updates in real time.
Chapter 4, Smart Agriculture, talks about building a simple weather station using the reference architecture we have built. The weather station consists of four sensors, and using these we can monitor farm conditions. We will be making the required changes to the API engine, web app, desktop app, and mobile app.
Chapter 5, Smart Agriculture and Voice AI, shows how we can leverage the power of voice AI technology to build interesting IoT solutions. We are going to work with the smart weather station and add a one-channel mechanical relay to this setup. Then, using voice commands and Amazon Alexa, we are going to manage the weather station.
Chapter 6, Smart Wearable, talks about an interesting use case in the healthcare sector, postoperation patient care. Using a smart wearable device equipped with a simple accelerometer, one can easily detect whether a patient has fallen down. In this chapter, we build the required setup comment to gather the accelerometer values from the sensor.
Chapter 7, Smart Wearable and IFTTT, explains how the data collected from the accelerometer can be used to detect falls and at the same time notify the API engine. Using a popular concept named If This Then That (IFTTT)—we will be building our own rules engine, which will process predefined rules and take action accordingly. In our example, we are going to send an email to the patient's carer if a fall is detected.
Chapter 8, Raspberry Pi Image Streaming, shows how to take advantage of the Raspberry Pi camera module to build a real-time image streaming (MJPEG technology) solution to monitor your surroundings from anywhere in the world. We will also implement motion-based video capture to capture video when motion is detected.
Chapter 9, Smart Surveillance, walks you through the process of image recognition using Amazon's Rekognition platform. We will be capturing an image when motion is detected using the Raspberry Pi 3 camera module. Then, we will send this image to Amazon Rekognition platform to detect whether the image we have taken is of an intruder or of someone we know.
To start building IoT solutions using JavaScript, you need to have the following:
- Medium to advanced knowledge of JavaScript – ES5 and ES6
- Medium to advanced knowledge of MEAN stack application development
- Medium to advanced knowledge of Angular 4
- Medium to advanced knowledge of Electron Framework
- Medium to advanced knowledge of Ionic Framework 3
- Novice to medium knowledge of digital electronic circuits
- Novice to medium knowledge of Raspberry Pi
- Novice to medium knowledge on sensors and actuators
It is for readers who are already well versed with JavaScript and want to extend their JavaScript knowledge to building hardware solutions in the field of IoT. IoT enthusiasts interested in creating exciting projects will also find this book useful. This book is also useful for readers who are good at developing standalone solutions using Raspberry Pi; this book will help them add IoT capabilities to their existing projects using the world's most misunderstood programming language.
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: "Now, inside the broker
folder, create another folder named certs
and cd
into that folder." A block of code is set as follows:
// MongoDB connection options mongo: { uri: 'mongodb://admin:[email protected]:41055/iotfwjs' }, mqtt: { host: process.env.EMQTT_HOST || '127.0.0.1', clientId: 'API_Server_Dev', port: 8883 } };
Any command-line input or output is written as follows:
openssl req -newkey rsa:2048 -nodes -keyout key.pem -x509 -days 365 -out certificate.pem
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: "Once logged in, click on the Create New
button to create a new DB."
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 email [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.
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.
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 emailed directly to you. You can download the code files by following these steps:
- Log in or register to our website using your email address and password.
- Hover the mouse pointer on the
SUPPORT
tab at the top. - Click on
Code Downloads & Errata
. - Enter the name of the book in the
Search
box. - Select the book for which you're looking to download the code files.
- Choose from the drop-down menu where you purchased this book from.
- 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/Practical-Internet-of-Things-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!
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/PracticalInternetofThingswithJavaScript_ColorImages.pdf.
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 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.
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.