Saturday, August 2, 2014

Book Review: Arduino Home Automation Projects

I have never been as interested in playing with Arduino as many of my colleagues and friends such as Jon are, but I did readily accept Packt Publishing's offer to review the recently released Arduino Home Automation Projects by Marco Schwartz. The book's subtitle is "Automate your home using the powerful Arduino platform" and it is composed of seven chapters and just under 120 substantive pages.


The Preface of Arduino Home Automation Projects describes Arduino as "the perfect platform to build home automation systems." The Preface includes short descriptions of what each of the seven chapters covers. This section makes it clear that each of the seven chapters covers a separate Arduino project with the seventh chapter culminating in covering how to build one's "own home automation system based on Arduino."

Arduino Home Automation Projects's Preface also describes the general hardware and software needed for the projects covered in the book (unique specific requirements for each project are covered in the relevant chapter). These include Arduino Uno board, Arduino IDE, and integrated web server and database (Schwartz recommends EasyPHP for Windows, Serveur Web - LAMP for Linux, and MAMP for OS X).

The Preface also discusses "who this book is for" and states that readers "don't need to know anything about the Arduino platform beforehand," but do need "basic knowledge of electronics and programming."

Chapter 1: Building Wireless XBee Motion Detectors

Chapter 1 is on "building wireless XBee motion detectors" and emphasizes using XBee ("low-power radio modules" described on Wikipedia as "form factor compatible radio modules") and the ZigBee (IEEE 802.15.4) protocol for the communication portion.

Marco Schwartz, author of Arduino Home Automation Projects, introduces his aREST library in this initial chapter of his book (though aREST is used in later chapters and associated projects as well). The main aREST project page describes aREST as "a simple library that implements a REST API for Arduino" that "is designed to be universal and currently supports REST calls via HTTP, via the Serial Port, and Bluetooth Low Energy" (portions of the specifics on each of these are removed in my quotation of the description). The aREST library consists of a single C++ header file (aREST.h) and appears to be available for use under a GPL license (described in the comments in the aREST.h source).

The motion detectors project described in this first chapter also includes construction of a graphical interface using "HTML, CSS, JavaScript, and PHP." The author describes how these are to be demonstrated and used for this project: "We are going to use HTML and CSS to design the interface itself, JavaScript to handle the different elements of the interface and make the link with PHP, and finally use PHP to communicate directly with the XBee modules." The chapter finishes with detailed coverage of using these languages to implement this functionality.

Chapter 2: Control Lights from Your Phone or Tablet

The second chapter of Arduino Home Automation Projects demonstrates use of Wifi to "control lights directly from your computer, phone, or tablet." This project includes application of relays and a CC 3300 Wifi Chip. This chapter's project constructs a software user interface with the same languages used in Chapter 1's project and demonstrates use of Arduino code to test the hardware configuration before the user interface is available.

Chapter 3: Measuring the Temperature Using Bluetooth

Arduino Home Automation Projects's third chapter brings Bluetooth and Python into the discussion for use in the temperature measuring project that is the subject of that chapter. The author uses the Bluefruit EZ-Link (a Bluetooth serial link module), a DHT (Digital Humidity and Temperature) sensor (along with C-based DHT-sensor-library), and other components with the Arduino board to measure and report the temperature. Software needed for this project includes the just-mentioned DHT library as well as Python 2.7 and pySerial (a Python Serial library to access the serial port via Python).

Chapter 3 describes in detail the code needed to create an Arduino "sketch" to "test our sensor via Bluetooth." The chapter first demonstrates compiling and running the code from the Arduino IDE and then moves onto use of TkInter (described on its Wiki page as "a thin object-oriented layer on top of Tcl/Tk that is "Python's de-facto standard GUI package") to build an independent standalone executable user interface. This part of the chapter demonstrates how building of this Python-based interface code is similar to building the same interface testing code in Arduino. By the way, in case you're wondering, an Arduino "sketch" is defined as, "name that Arduino uses for a program" and "the unit of code that is uploaded to and run on an Arduino board" (Arduino Getting Started Guide).

Chapter 4: Weather Station in the Cloud with Xively

The fourth chapter of Arduino Home Automation Projects transitions from local monitor projects to a project that sends measurements from the Arduino board to the cloud. In this case, Xively is the destination in the clouds and the author describes Xively as "an online platform where you can send data from various devices such as Arduino." Schwartz points out that this is the first project in the book "linking home automation to the 'Internet of Things'" and describes "Internet of Things" as the "idea of having every device connected on the Web" that is "a major trend at the moment."

Chapter 4 uses hardware and software used in projects associated with the first three chapters and also introduces use of a photo cell. The chapter's introduction to Xively includes text description and screen snapshots demonstrating how to set up an Xively account.

Chapter 4 includes detailed coverage of the Arduino sketch for this weather station project and demonstrates testing of the project's connectivity to Xively. The chapter then illustrates with text and screen snapshots the rendering of the device's measurements on the device's dashboard presented on the Xively cloud via web page.

Chapter 5: Monitor Your Energy Consumption in the Cloud

Chapter 5 of Arduino Home Automation Projects builds directly on the preceding chapter to create a project that "sends energy consumption data" for a connected appliance "to the cloud." This chapter's project applies some of the hardware and software from previous chapters' projects and adds new hardware (AC712 current sensor).

Like Chapter 4's project, the Chapter 5 project uses Xively. Although this chapter references that chapter for Xively configuration instructions, most of the necessary instructions and screen snapshots are repeated again in Chapter 4. The chapter demonstrates writing and applying the Arduino sketch and seeing the results in the web as accessed from the Xively cloud.

Chapter 6: Hack a Commercial Home Automation Device

Arduino Home Automation Projects's sixth chapter represents another major transition. The prior five chapters focused on building home automation projects from scratch with Arduino while Chapter 6 instead focuses on "hacking" an existing automation device with Arduino. Early in this chapter, the author calls out a warning about this project being for informational purposes only and that the described hack should "not be used as such in your home for safety reasons."

Schwartz describes the characteristics of the device to be hacked that the readers should look for. The author also explains that he uses a TinyCircuits Arduino board in this project so that it is small enough to fit in the device chosen for the hacking and that Arduino Micro would have been another satisfactory option. The chapter details how to write the Arduino sketch to test this from the serial port and then how to develop a web-based interface with HTML and JavaScript to control it from a web browser.

Chapter 7: Build Your Own Home Automation System

The final chapter of Arduino Home Automation Projects starts with its stated goal: "to give you a step-by-step method to build your own home automation systems." The author points out that the nature and specifics of the example project associated with this Chapter 7 are less important than the general steps and principles covered.

Because Chapter 7 builds its example project from even more basic components than the first six chapters, the list of required hardware is longer than in most of those chapters. Specific resistors and capacitors are specified along with an "ATmega328 microcontroller with Arduino bootloader," a crystal clock, and a few other things. Software required for this chapter's example project includes JeeLib for Arduino IDE ("to enable low-power operation of your system"), EAGLE (to design the printed circuit board), and OpenSCAD (to design a 3D printed case).

With the needed software and hardware introduced, the final chapter looks at designing an Arduino system from scratch, designing a printed circuit board and ordering fabrication of that printed circuit board, and designing and order a 3D printed case. The "Summary" for Chapter 7 summarizes that chapter as previous chapters' summaries did for their respective chapters, but his final chapter's "Summary" also includes several paragraphs summarizing the entire book.

General Observations
  • The photographs in Arduino Home Automation Projects are sharp and clear, making it easier to visualize what is described in the book.
  • Hardware and software needed for each chapter's project is typically called out early in the respective chapter, but is sometimes not called out until a few pages into the chapter.
    • The author tends to describe the hardware and software in higher level and more general terms first and then to list out the specifics of what he used for each chapter's project
    • The author provides links to online sources of the same components or software he used when building each chapter's associated project.
    • Readers not comfortable with electronics or programming should probably get exactly the hardware Schwartz used for each project to give them the best chance of the hardware and provided code working together without any need to debug or change code or hardware configuration. Readers who are more comfortable with electronics and programming or are willing to take some time to debug potential conflicts between different hardware and the provided code might choose to use some of the alternate hardware Schwartz mentions in several of the book's projects.
  • The chapters in Arduino Home Automation Projects represent relatively independent projects, though there are some dependencies between chapters. For example, aREST is described in Chapter 1 but is used in several chapters and their associated projects. Commonly used hardware and software is often sufficiently covered in each chapter in which it is use with reference to its first introduction if even more detail is desired.
    • Several different libraries are installed in Arduino in the course of the seven chapters. In each case, the author explains in essentially the same sentence how to install libraries in Arduino: "To install an Arduino library, simply place the library folder in the /libraries folder of the main Arduino folder." This is an example of how the chapters are largely independent of one another because necessary background details are often mentioned again when needed.
  • The projects covered in Arduino Home Automation Projects are electronics projects and, in some cases, do carry risks of personal injury if the reader is not cautious. The author does a nice job of calling out and highlighting several of these situations.
  • The code examples are provided for download and the author details in text what the code's doing for the most important aspects. The reader of Arduino Home Automation Projects is reminded that this type of low-level programming is often at least a bit device-specific. The author carefully describes the exact devices he uses that the code examples are written for and tested against.
  • Anyone interested in the overall style of Arduino Home Automation Projects and whether they would like Schwartz's approach to writing can get a good taste of that style in Schwartz's online post Wireless Security Camera with the Arduino Yun that has a similar style and similar content to the chapters in this book.
  • The contents of Arduino Home Automation Projects made me feel that author Marco Schwartz is writing about something he knows about and is well prepared to write about. This is backed up by his online presence which includes his Google+ posts, his Open Home Automation blog, his YouTube videos, and his Twitter handle. He has authored Home Automation with Arduino (self-published with CreateSpace) and Internet of Things with the Arduino Yún (also Packt Publishing) in addition to Arduino Home Automation Projects.

Author Marco Schwartz combines high-definition photographs, clear diagrams, and sufficiently sharp screen snapshots with easy-to-follow text to describe seven projects in seven chapters of Arduino Home Automation Projects that apply Arduino to build home automation projects. Although a background in electronics and basic programming will certainly make it easier to read and understand this book, the full code is made available and the detailed instructions and helpful visual aids lead me to be believe that most teenagers and adults could follow along with the book and get the described projects working. I'm happy that I accepted Packt Publishing's offer to review this book as I found Schwartz's writing style to be engaging and easy to follow and thought that the visual aids were outstanding.

No comments: