Book Image

Internet of Things with Arduino Blueprints

By : Pradeeka Seneviratne
Book Image

Internet of Things with Arduino Blueprints

By: Pradeeka Seneviratne

Overview of this book

Table of Contents (15 chapters)
Internet of Things with Arduino Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Preface

Arduino is a small single-chip computer board that can be used for a wide variety of creative hardware projects. The hardware consists of a simple microcontroller, board, and chipset. It comes with a Java-based IDE that allows creators to program the board. Arduino is the ideal open hardware platform to experiment with the world of Internet of Things. The credit card-sized Arduino board can be used via the Internet to make useful and interactive Internet of Things (IoT) projects.

Internet of Things with Arduino Blueprints is a project-based book that begins with projects based on IoT and cloud computing concepts. This book covers up to eight projects that will allow devices to communicate with each other, access information over the Internet, store and retrieve data, and interact with users—creating smart, pervasive, and always connected environments. It explains how wired and wireless Internet connections can be used with projects and explains the use of various sensors and actuators. The main aim of this book is to teach you how Arduino can be used for Internet-related projects so that users are able to control actuators, gather data from various kinds of sensors, and send and receive data wirelessly across HTTP and TCP protocols.

Finally, you can use these projects as blueprints for many other IoT projects and put them to good use. By the end of the book, you will be an expert in the use of IoT with Arduino to develop a set of projects that can relate very well to IoT applications in the real world.

What this book covers

Chapter 1, Internet-Controlled PowerSwitch, briefly introduces Arduino UNO and Arduino Ethernet shield basics while focusing on building an Internet-controlled PowerSwitch using Arduino UNO, the Arduino Ethernet shield, and PowerSwitch Tail to turn electrical appliances on/off through the Internet via a web-based user interface. Also, you will learn how to increase the complexity of PowerSwitch by adding a circuit to track the mains electricity.

Chapter 2, Wi-Fi Signal Strength Reader and Haptic Feedback, briefly introduces Arduino Wi-Fi shield basics, vibration motors, and haptic feedback. You will learn how to make advanced vibration patterns using vibration motors with a haptic motor controller and the Adafruit haptic library according to the Wi-Fi signal strength received by the Arduino Wi-Fi shield.

Chapter 3, Internet-Connected Smart Water Meter, focuses on building a flow sensor-based water meter in conjunction with the Arduino Ethernet shield to measure water flow rate and volume, and then display them on an LCD screen. In addition, you will learn how to convert this water meter to a web server and request readings through the Internet of Ethernet.

Chapter 4, Arduino Security Camera with Motion Detection, explains how to incrementally develop a Arduino Ethernet shield-based security camera with the Adafruit TTL Serial JPEG camera and the VC0706 camera library. In addition, you will learn how to add motion detection functionality and upload the captured images to Flickr.

Chapter 5, Solar Panel Voltage Logging with NearBus Cloud Connector and Xively, briefly introduces the NearBus cloud connector and Xively, while focusing on building a solar panel voltage logger with the Arduino Ethernet shield with a few electronic components. Also, you will learn how to log the output voltage of a solar panel in combination with NearBus and Xively, and then display real-time data that can be viewed through a web browser.

Chapter 6, GPS Location Tracker with Temboo, Twilio, and Google Maps, briefly introduces the GPS shield and how to use the TinyGPSPlus library and the Google JavaScript API library to build a real-time location tracker to display the current location of the GPS shield on Google Maps. You will also learn the basics of Temboo and Twilio cloud services.

Chapter 7, Tweet-a-Light – Twitter-Enabled Electric Light, introduces Python, a more powerful programming language that can be used to read Twitter tweets and write data to a computer's serial port accordingly. Finally, you will learn to build an electric light switch that can be controlled using Twitter tweets to turn the switch on and off.

Chapter 8, Controlling Infrared Devices Using IR Remote, focuses on building an infrared remote control with the Arduino Ethernet shield and a few electronic components that can be controlled through the Ethernet or Internet to control IR-enabled devices remotely. You will learn how to record and reproduce IR commands using the Arduino IR remote library. In addition, you will learn how to add IR functionality to non-IR enabled devices.

What you need for this book

This book has been written and tested on the Windows environment and uses various software components with Arduino. It would be great if you could prepare your development environment before proceeding with the sample code provided along with each chapter. The following list briefly gives you the details about the software requirements that you should have to set up your PC for each chapter:

  • The Arduino software: This is the main development environment that you will use to write, verify, and run your sketches in every chapter of this book. The latest Arduino installer for Windows can be downloaded from https://www.arduino.cc/en/Main/Software. Throughout this book, we will write and test Arduino sketches in the Windows environment.

  • A web browser: Normally, every PC has a default web browser, such as Microsoft Internet Explorer (or Microsoft Edge in Windows 10), Google Chrome, or Mozilla Firefox.

  • The Adafruit DRV2605 library: You need this library to control vibrators (that is, vibration motors) with the Adafruit DRV2605 haptic controller in Chapter 2, Wi-Fi Signal Strength Reader and Haptic Feedback. You can download this library from https://github.com/adafruit/Adafruit_DRV2605_Library.

  • The Adafruit VC0706 camera library: You will need this library to interface the Adafruit VC0706 Serial JPEG camera with Arduino in Chapter 4, Arduino Security Camera with Motion Detection. You can download this library from https://github.com/adafruit/Adafruit-VC0706-Serial-Camera-Library.

  • NearBus Agent (An Arduino library for Ethernet): You will need this library to connect the Arduino Ethernet shield with the NearBus cloud connector for Arduino memory mapping with NearBus in Chapter 5, Solar Panel Voltage Logging with NearBus Cloud Connector and Xively. You can download this library from http://www.nearbus.net/downloads/NearBusEther_v16.zip.

  • FlexiTimer2: This will make sure that Arduino correctly functions with the NearBus Agent library in Chapter 5, Solar Panel Voltage Logging with NearBus Cloud Connector and Xively. You can download it from http://github.com/wimleers/flexitimer2/zipball/v1.1.

  • The TinyGPSPlus library: This will be required to work with the SparkFun GPS shield in Chapter 6, GPS Location Tracker with Temboo, Twilio, and Google Maps and can be downloaded from https://github.com/mikalhart/TinyGPSPlus/archive/master.zip.

  • Python: You can download Python from https://www.python.org/, and the instructions about the download and installation can be found in Chapter 7, Tweet-a-Light – Twitter-Enabled Electric Light.

  • The Arduino IR remote library: You will need this library to send and receive and extract IR commands in Chapter 8, Controlling Infrared Devices Using IR Remote. You can download it from https://github.com/z3t0/Arduino-IRremote.

Who this book is for

This book is intended for those who want to learn more about Arduino and make Internet-based interactive projects with Arduino. If you are an experienced software developer who understands the basics of electronics, then you can quickly learn how to build the Arduino projects explained in this book.

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: "Copy the following index.html file from the code folder of Chapter 5 to your computer's hard drive."

A block of code is set as follows:

// Set the picture size - you can choose one of 640x480, 320x240 or 160x120 
 // Remember that bigger pictures take longer to transmit!
 cam.setImageSize(VC0706_640x480);  // biggest
 //cam.setImageSize(VC0706_320x240);  // medium
 //cam.setImageSize(VC0706_160x120);   // small

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

int32_t WiFiDrv::getCurrentRSSI()
{
  startScanNetworks();
  WAIT_FOR_SLAVE_SELECT();
  // Send Command
  SpiDrv::sendCmd(GET_CURR_RSSI_CMD, PARAM_NUMS_1);

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

>python your_python_script.py

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: "Click on the Create an App link if it is not selected by default."

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 , 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 from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. 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.

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/5486OS_ColoredImages.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 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 , and we will do our best to address the problem.