Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / IoT

IoT Path-to-product: How To Build The Smart Home Prototype

5.00/5 (2 votes)
19 Jul 2016CPOL12 min read 13.7K  
The exercise described in this article demonstrates how to recreate the prototype from the path-to-product project.

This article is for our sponsors at CodeProject. These articles are intended to provide you with information on products and services that we consider useful and of value to developers

Get access to the new Intel® IoT Developer Kit, a complete hardware and software solution that allows developers to create exciting new solutions with the Intel® Galileo and Intel® Edison boards. Visit the Intel® Developer Zone for IoT.

The Internet of Things (IoT) path-to-product project is part of a series that portrays how to develop a commercial IoT solution from the initial idea stage through prototyping and refinement to create a viable product. It uses the Intel® IoT Commercial Developer Kit, with the prototype built on an Intel® NUC Kit DE3815TYKHE small-form-factor PC and an Arduino* 101 board.

The exercise described in this article demonstrates how to recreate the prototype from the path-to-product project. It does not require special equipment or deep expertise. It is intended to be instructive toward developing prototyping phases of IoT projects in general. To see the project overview, see IoT Path-to-Product: Smart Home Overview.

Visit GitHub for this project's latest code samples and documentation.

Introduction

From this exercise, developers will learn how to do the following:

  • Connect to the Intel® NUC Kit DE3815TYKHE.
  • Interface with the I/O and sensor repository for the Intel® NUC using MRAA and UPM from the Intel® IoT Developer Kit, a complete hardware and software solution to help developers explore IoT and implement innovative projects.
  • Run the code sample in Intel® XDK IoT Edition, an IDE for creating applications that interact with sensors and actuators, enabling a quick start for developing software for Intel® IoT Platforms.
  • Set up and connect to cloud services using the IBM Bluemix* platform, which provides a data store, cloud analytics, and communications hub for various parts of the solution.
  • Visit GitHub for the latest code samples and documentation.

What it Does

This project simulates the following parts of a smart home:

  • Front door. When the status of the front door is changed (that is, it is opened, closed, locked, or unlocked), that status will be displayed by the administration application.
  • Doorbell. When the doorbell button is pushed on the model, a notification will be displayed by the administration application.
  • Garage door. Users can send commands from the mobile application to raise and lower the garage door. The mobile application will also display the door’s progress as it opens or closes and indicates whether the door is blocked from closing.

How it Works

This smart home application operates based on the following sensor data:

  • Open/closed status of the garage door
  • Blocked/unblocked status of the garage door
  • Events: doorbell ring, lock/unlock front door, open/close front door, open/close garage door, block garage door

All data flows occur through the cloud as an intermediary. For example, if a customer opens the garage door, that command is passed to the cloud and then to the garage door itself. This approach enables status information to be maintained in the cloud, for access and analytics from multiple end points. For example, it is possible to check the status of the garage door remotely and for a user who inadvertently left the door open to close it remotely.

This demo was designed so that other capabilities not included as part of this demo can be implemented (particularly with the involvement of cloud resources).

Set up the Intel® NUC Kit DE3815TYKHE

This section gives instructions for installing the Intel® IoT Gateway Software Suite on the Intel NUC.

Note: Due to the limited size of the local storage drive, we recommend against setting a recovery partition. You can return to the factory image by using the USB drive again.

You can now use your gateway remotely from your development machine if you are on the same network as the gateway. If you would like to use the Intel® IoT Gateway Developer Hub instead of the command line, enter the IP address into your browser and go through the first-time setup.

Note: If you are on an Intel network, you need to set up a proxy server.

  1. Create an account on the Intel® IoT Platform Marketplace if you do not already have one.
  2. Order the Intel® IoT Gateway Software Suite, and then follow the instructions you will receive by email to download the image file.
  3. Unzip the archive, and then write the .img file to a 4 GB USB drive:
  4. Unplug the USB drive from your system, and then plug it into the Intel NUC along with a monitor, keyboard, and power cable.
  5. Turn on the Intel NUC, and then enter the BIOS by pressing F2 at boot time.
  6. Boot from the USB drive:
    1. From the Advanced menu, select Boot.
    2. From Boot Configuration, under OS Selection, select Linux.
    3. Under Boot Devices, make sure the USB check box is selected.
    4. Save the changes, and then reboot the system.
    5. Press F10 to enter the boot selection menu, and then select the USB drive.
  7. Log in to the system with root:root.
  8. Install Wind River Linux on local storage:
    ~# deploytool -d /dev/mmcblk0 --lvm 0 --reset-media –F
  9. Use the poweroff command to shut down your gateway, unplug the USB drive, and then turn your gateway back on to boot from the local storage device.
  10. Plug in an Ethernet cable, and then use the ifconfig eth0 command to find the IP address assigned to your gateway (assuming you have a proper network setup).
  11. Use the Intel IoT Gateway Developer Hub to update the MRAA and UPM repositories to the latest versions from the official repository (https://01.org). You can achieve the same result by entering the following commands:
    ~# smart update<br />
    	~# smart upgrade<br />
    	~# smart install upm
  12. Plug in an Arduino 101 board, and then reboot the Intel® NUC. The Firmata* sketch is flashed onto Arduino 101, and you are now ready to use MRAA and UPM with it.

Set up the Arduino 101 Board

Setup instructions for the Arduino 101 board are available at https://www.arduino.cc/en/Guide/Arduino101.

Connect other Components

This section covers making the connections from the Intel® NUC to the rest of the hardware components. The bill of materials for the prototype is summarized in Table 1, and the assembly of those components is illustrated in Figure 1.

Table 1. Smart home prototype components

  Component Details

 

Base System

 

Intel® NUC Kit DE3815TYKHE

http://www.intel.com/content/www/us/en/support/boards-and-kits/intel-nuc-kits/intel-nuc-kit-de3815tykhe.html

Arduino* 101 Board

https://www.arduino.cc/en/Main/ArduinoBoard101

USB Type A to Type B Cable

For connecting Arduino 101 board to NUC

 

 

 

Components from Grove* Starter Kit Plus IoT Edition

Base Shield V2

http://www.seeedstudio.com/depot/Base-Shield-V2-p-1378.html

Gear Stepper Motor with Driver

http://www.seeedstudio.com/depot/Gear-Stepper-Motor-with-Driver-p-1685.html

Button Module

http://www.seeedstudio.com/depot/Grove-Button-p-766.html

Touch Sensor Module

http://www.seeedstudio.com/depot/Grove-Touch-Sensor-p-747.html

Light Sensor Module

http://www.seeedstudio.com/depot/Grove-Light-Sensor-p-746.html

Rotary Sensor Module

http://www.seeedstudio.com/depot/Grove-Rotary-Angle-Sensor-p-770.html

Red LED

http://www.seeedstudio.com/depot/Grove-Red-LED-p-1142.html

LCD with RGB Backlight Module

http://www.seeedstudio.com/depot/Grove-LCD-RGB-Backlight-p-1643.html

Buzzer Module

http://www.seeedstudio.com/depot/Grove-Buzzer-p-768.html

Image 1

Figure 1. Smart home proof-of-concept prototype.

Install Intel® XDK IoT Edition

The Intel® XDK IoT Edition supports JavaScript* and Node.js programming for IoT.

Note: If you are a Windows user, we recommend that you install Bonjour Print Services on your host, which allows the Intel® XDK IoT Edition to automatically detect IoT devices installed on your network. Installing Bonjour isn’t mandatory, but it makes connecting to your board easier. You can still connect to your board by manually entering your board’s IP address and any necessary login information. If you’re using a corporate host machine, your firewall may block Bonjour.

  1. Visit the IDE download page at https://software.intel.com/en-us/ iot/software/ide to download a copy of the Intel® XDK IoT Edition installer for your host system. Ensure that your OS platform is selected in the drop-down list, and then click the Download button.
  2. Run the installer by doing one of the following:
    • For Windows: Right-click the installer you just downloaded, and then select Run as Administrator. If a confirmation message is displayed, click Yes to continue.
    • For Mac OS*: Double-click the .dmg file you just downloaded to extract the installer. Double-click the .pkg file to start installation.
  3. For Linux:
    1. Open Terminal.
    2. Navigate to the folder where the installer is stored. For example, if the installer is stored in the Desktop folder, enter cd ~/Desktop/
    3. To extract the install files, enter tar zxvf installername
    4. Navigate to the folder containing the extracted files.
    5. To run the installer, enter ./install.sh
  4. Follow the instructions in the installation wizard to install the Intel XDK IoT Edition.
  5. Install Bonjour* Print Services (recommended; Windows OS only):
    1. Download Bonjour at http:// support.apple.com/kb/DL999.
    2. Click Download.
    3. Right-click BonjourPSSetup. exe, and then select Run as Administrator. If you see a confirmation message, click Yes to continue.
    4. Follow the instructions in the installation wizard to install Bonjour.
  6. In order for Intel XDK IoT Edition to detect the Intel NUC, you need to first install the xdk-daemon package, which is available from the official package repository (https://01.org). If you already have it, make sure it is updated to version 0.0.35 or higher. To perform these tasks, use the following commands:
    ~# smart update<br />
    	~# smart install xdk-daemon
  7. After installing or updating the package, reboot the Intel NUC to allow the service to start. You can now add the gateway from Intel XDK IoT Edition as a manual connection and start running your projects remotely.

IBM Bluemix Setup

This section covers creating a Bluemix application, adding a MongoDB* connection, and storing/retrieving data.

Create a Bluemix Application with a MongoLab Service

Image 2

Figure 2. Bluemix user interface
  1. Log in to the Bluemix console. Visit console.ng.bluemix.net and select LOG IN.
  2. After logging in, you will be in the DASHBOARD view.
  3. Click CREATE APP.
  4. Select WEB.
  5. Select the SDK for Node.js option, and then click CONTINUE.
  6. Name your application, and then click FINISH.
  7. Once your application has been created by IBM Cloud, click ADD A SERVICE OR API.
  8. In the Data & Analytics section, select MongoLab.
  9. Click BI to confirm the creation of the service.
  10. After the service has been created, a popup window requesting you to restage your application will appear. Click RESTAGE.
  11. Wait for your application to finish staging. A message indicating that Your app is running will be displayed when done.

Deploy your IBM Bluemix application with Cloud Foundry*

Log in to your Bluemix account to install the cf command-line interface.

Restriction: The Cloud Foundry command-line interface is not supported by Cygwin. Use the Cloud Foundry command-line interface in a command- line window other than the Cygwin command-line window.

After the cf command-line interface is installed, follow the listed steps to download the starter code and learn how to push the application for IBM Bluemix to the cloud.

Connect and Run Application on the Intel® IoT Gateway

  1. In the Develop window within the Intel® XDK IoT Edition, click the Serial Terminal.
  2. Select your board in the dropdown menu associated to the Port label.
  3. Click the Connect button to establish a connection:
    • User Name: root
    • Password: <your_unique_password>
  4. Type the following command to view the IP address of the board: ifconfig
  5. Select the Add Manual Connection option:
    • Enter the IP Address
    • Enter the password
  6. After the connection is established, click the down arrow to download the project onto the board.
  7. Click the Run button.

The application should be running on the board at this point.

Application Details

Cloud Application for IBM Bluemix

This Node.js app for Bluemix leverages MongoDB for data storage and reveals REST API routes for inserting and getting data related to sensors and usage conditions. Web Sockets are also leveraged for real-time updates to client and mobile applications.

Prototype Application for Intel NUC Connected to an Arduino 101

This Node.js app runs on your Intel® NUC (gateway) connected to an Arduino 101 to enable interactions with sensors and peripherals. It also sends data to the IBM Bluemix cloud application for storing sensor data. Web Sockets are the primary communication protocol that allows the client (Intel NUC and Arduino 101) to communicate with the IBM Bluemix cloud application. In Offline mode, the application leverages SQLite* for data storage and sends the data to the cloud when a connection is established again. Also, the application communicates with the mobile apps when offline.

This application allows a user to interact with a touch sensor and buzzer for simulating a doorbell, a light sensor for capturing the presence of objects, a servo motor for simulating the movement of a garage door, and a rotary sensor for simulating door open or close actions.

Administration and Mobile Applications

The administration and mobile apps are embedded within and invoked by the application running on the Intel NUC. Rather than providing multiple versions of a rich-client application for different platforms (or taking on the added complexity of cross-platform, rich- client development), the team decided to implement these applications in HTML5 and JavaScript using the Intel® XDK IoT Edition. This approach allows for a single version of each application to be consumed by multiple hardware platforms in use by administrators and end users.

  • The administration application displays the sensors being interacted with in near-real time and also displays a log of the information via REST API calls. It operates on a PC or tablet and allows for a detailed view into the operation of the smart home, including events, status, and logs, as well as access to the cloud data and analytics.
  • The mobile application allows the user to open or close the garage door using web sockets. It operates on a smartphone or other mobile device, enabling a customer to open and close the garage door as well as monitor the progress of the door as it opens and closes or is blocked.

Conclusion

This exercise demonstrates the ability of mainstream organizations to create viable prototypes for the IoT that incorporate software to operate on an Intel® NUC (gateway), as well as administrative and mobile apps and cloud functionality.

Using the Intel® IoT Commercial Developer Kit, an Intel® NUC, and an Arduino 101 board, project teams can build prototypes for IoT projects at a relatively low cost and without specialized skill sets. The Grove Starter Kit Plus IoT Edition provides sensors and other components that further streamline rapid prototyping.

Visit GitHub for this project's latest code samples and documentation.

Additional Information

The exercise described in this article demonstrates how to recreate the prototype from the path-to-product project. To see the project overview, see IoT Path-to-Product: Smart Home

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)