This Instructable provides information on how to how to set up an Intel Analytics Dashboard account, connect a device to the cloud, control a device through the cloud, and run Arduino programs that communicate with the cloud.
Most of the steps provided in this Instructable are based on Intel's IoT documentation found here. I am simply documenting my personal experience with it. Note that I use a Mac and Intel's Edison board. I have tried to include as many images as possible to supplement my documentation.
Step 1: IoT and Intel
The Internet of Things (or IoT) is a web of "smart" devices that use wireless technology to talk to themselves and us. As Intel puts it, the "The Internet of Things (IoT) is expected to be a multi-trillion dollar market with an install base of 50 billion connected things by the end of 2020." To address the growing pains of this new industry, Intel is offering a foundation of building blocks for IoT. The Intel IoT Developer Kit is part of a larger Intel IoT developer program target at hobbyists, students, and entrepreneurs. The Developer Kit consists of:
- Hardware components
- Software images and packages
- IDE support
- Cloud services
- Additional tools
As noted in third point, Intel operates a cloud service called IoT Analytics for users of the Developer Kit. Intel Galileo and Edison device developers can collect, store, and analyze data without having to invest in large-scale storage and processing capacity.
Step 2: IoT Analytics Login and Account Creation
Begin connecting devices to the cloud by going the the IoT Analytics Dashboard site here to create an account. You will be directed to the Sign In screen. Click "Sign Up Here" to create a new account.
You have the option of using your Facbook, Google+, or GitHub accounts to register, or you can create a local account with an email address and password. If you click "Sign Up Here", the Create User screen appears. You must provide a valid email address and password. Review the Terms and Conditions, click the check box "I agree to the Terms and Conditions of Use", and hit "Create". Go to your email to confirm your account. You are prompted to create an account name the first time you sign into the Dashboard. Once you have authenticated, the My Dashboard page appears.
My Dashboard provides access to all the information you need to manage your devices. The main screen displays the number of devices in communication with the IoT cloud, messages communicated between IoT devices and the cloud in the past hour, and the percent of "healthy" devices. Notice that there are no devices registered yet. The next few steps will show you how to link a device to your IoT Analytics Dashboard.
Step 3: Setting Up the Edison Board
Assemble your Edison board. I connected my Edison to the Arduino breakout board. Check out the Getting Started Guide to set up and establish communication with Window, Mac, or Linux operating systems.
Here are extra documents I found useful:
You have successfully set up the board once you downloaded the Edison IDE and can run the "Blink" program.
Step 4: SSH Into the Edison
Make sure the Edison board is connected to your computer through both micro USB ports (labeled J16 and J3 on the Arduino breakout board). Open the terminal and issue the command
sudo screen /dev/cu.usbserial
press the TAB key to auto-complete the name of your device, press the SPACE key, and type "115200" (the baude rate), as shown below
sudo screen /dev/cu.usbserial-A502LRKU 115200
Then press ENTER to begin communication with the Edison. You should see the login prompt from the board saying "edison login". I renamed by board "Tesla" (read this lovely Oatmeal comic to learn why). For the login, type "root"
edison login: root
And hit ENTER twice. That's it! You are now connected and can use the command line to navigate around your Edison. I configured mine to also have a password by typing
Step 5: Set Up WiFi
The Edison board rocks because it makes connecting to WiFi super simple. Once you have ssh-ed into the Edison, type
as shown in the last line of the image included here. The board takes 10 seconds looking for local networks, and returns a list of those available. In the line
Enter a number between 2 to 10 to choose one of the listed network SSIDs:
type the number corresponding to the network you want to link to. If correct, type "y" in the next line and enter the network's password. That's it! The Edison will link wirelessly to the network.
Step 6: Test the Edison's Connection to the Cloud
The Edison links to the cloud via the IoT Gateway Agent, which abstracts away the complexities of cloud connectivity. It implements the necessary message formatting and security during data transmission. My Edison board came preinstalled with the necessary software. Check to see if your device is also preinstalled with the Agent by entering the command:
If it is installed, the Agent will give a healthy report (as shown in the provided image). Also, for more information about iotkit-admin commands see Section 5 'Notes About "Admin" Commands' in the iotkit-agent readme file.
cd iotkit-agent npm install
Then "cd" to the directory where you installed it and run it from the local directory (note the leading ./ and the trailing .js):
Step 7: Add a Device to the IoT Dashboard
By this point you know your Edison can connect to the cloud, but it still needs to be registered on Intel's Analytics Dashboard. Registering the device opens a channel of communication between it and your cloud account. The following steps involve a lot of going back-and-forth between the Edison's command line and the IoT Analytics dashboard. To make these instructions clearer, I am labeling each step as 'CL' (Command Line) or 'AD' (Analytics Dashboard).
Steps 1 & 2: Registering the device
1. (CL) Display the device's ID with the following command
Select and copy the device ID. You will need it for the next step.
2. (AD) Navigate to the homepage of your online Analytics Dashboard. Click on the gray "Devices" box to register a new device. Paste the device ID into the "ID" and "Gateway" text boxes. The device Name and Tags are optional. Click "Save" to add the device. Navigate back to the home screen and click the "Devices" box again to go to the My Devices page. Your new device will be listed. After registration, devices remain in the status "created". Next, the device must be activated from the device itself.
Steps 3 & 4: Activating the device
3. (AD) In your Analytics Dashboard, click on the small box with three horizontal lines in the upper lefthand corner of the toolbar. This opens the Navigation Pane. Click on "Account" to navigate to the My Account Page. Click the refresh icon on the right side of the Activation Code text box. Then click the eye icon to view the new activation code. Highlight and copy this code.
4. (CL) Go back to the Edison command line and activate the device by typing
iotkit-admin activate *ACTIVATION CODE*
Paste the activation code where *ACTIVATION CODE* is written. The activation process creates a device record in the cloud, associates your device with your account (where the activation code came from), and provides security credentials. The device should now be active system-wide. You can verify this on your IoT Dashboard in the "Devices" box.
Step 5: Starting the agent
5. (CL) Once the device is activated, start the iotkit-agent by typing the startup script:
systemctl start iotkit-agent
After activating the device, the IoT Dashboard home screen should look like the image included here, where the "Device" box reads, "1 Active, 1 in Total". If you register multiple devices, these numbers will increase.
In the future, to stop the agent (e.g. to configure additional devices) type the command
systemctl stop iotkit-agent
Step 8: Component Creation
Intel IoT devices like the Edison board have both digital and analog GPIO pins that can be connected to a variety of sensors. Once the device is registered, sensor data from that device is sent to the IoT dashboard. However, to obtain data from a sensor you must first create a catalog item for it. The IoT Dashboard calls catalog items "components", and there is a component for each sensor connected to your IoT device. This enables your Dashboard to grab real-time data from your device.
Access the Component Catalog by clicking on the tab labeled "Catalog" on the Account page. Remember, the Account page is located in the Navigation Pane. Your account comes with three default components: humidity, power, and temperature. A component can be either a sensor or an actuator. To add a new component, select "Add a New Catalog Item" at the bottom of the screen. A Component Definition box appears. Add and save relevant information about your sensor in the Definition Box.
For example, I built a seismometer that is connected to an analog input pin on my Edison board. To collect data from my seismometer, I created a component called "seismograph". (Seismometers and seismographs are somewhat interchangeable terms. They are both devices that detect ground shaking during an earthquake.)
Step 9: Component Registration
After creating a component in the Dashboard, register it on your device. In your device's terminal environment enter the command
iotkit-admin register *Component Name* *ID*
The "Component Name" can be found by clicking on the component icon on your Dashboard's Catalog Page (see the image included). The "ID" can be found by going into your device's terminal environment and entering the command.
This command generates a list of all your catalog components, including their ID, whether they are a sensor or actuator, and what they measure or do. Make note of the ID and use this when registering the component.
For example, you can see my new sensor "seismograph" listed in the components table in the included image. I registered the sensor by typing
iotkit-admin register seismograph seismograph.v1.0
Step 10: Testing That Registration Works
When the sensor has been registered to an appropriate component, you can transmit observation data to the IoT Analytics site. To verify that the sensor has been properly registered, run the observation command to send individual data elements to the IoT Analytics site. For example, I tested my seismometer by entering my Edison's terminal environment and typing
iotkit-admin observation seismograph 15 iotkit-admin observation seismograph 40 iotkit-admin observation seismograph 70 iotkit-admin observation seismograph 25
where 15, 40, 70, and 25 are fake data. If all goes well in this example, the terminal should print
TIMESTAMP - info: Sending attributes... TIMESTAMP - info: Submitting: n= COMPONENT NAME, v=DATAPOINT TIMESTAMP - info: Response received: response = none detail, status=0 TIMESTAMP - info: Observation Sent response=none detail, status=0
For this example, COMPONENT NAME is "seismograph", DATAPOINT is 15, 40, 70, or 25, and TIMESTAMP is an assortment of text indicating the current date and time. If the submission fails, you will receive the response
TIMESTAMP - error: Data Submission Error code=ETIMEDOUT
The submission can fail if the Edison losses its WiFi connection. Refer back to Step 5 of this Instructable for how to connect to WiFi.
Switch back to the Analytics Dashboard and select Charts from the navigation pane. Next, check the boxes beside the desired device and component to see the newly sent data.
Step 11: The Edison Arduino IDE
At this point, we can collect analog or digital sensor data with the Edison board and send it to the Intel IoT Analytics Dashboard. However, what if you wanted to collect data every 5 seconds, filter it, and then send it to the cloud? What if you want to collect data every 5 seconds, save it in an array, and send an array of data to the cloud every minute? Luckily, the Edison board can be programed through the Arduino environment and send data to the cloud with the IoT Kit Arduino Library.
If you haven't already, download the Arduino-like IDE for your Edison board here. Give the download a name that has no spaces and isn't easily confused with other Arduino software.
Next, connect the Edison to your computer with two micro USB cables.
Open the new IDE:
- Under "Tools" -> "Board" select "Intel Edison"
- Under "Tools" -> "Serial Port" select "/dev/cu.usbmodem" plus the ending that matches your device's serial port
Note: The Arduino sketch will not upload if you use any port besides /cu.usbmodem. Any /tty port won't work, and any /cu.serial port won't work either.
Step 12: IoT Kit Arduino Library
Intel has provided example to code help you transfer data from their hardware to the Analytics Dashboard. Their arduino library "IoTkit.h" depends on the library "ajson.h" to send a receive data. aJson is a library to receive, understand, create or modify JSON strings directly in the Arduino environment.
To transfer data from the Edison to the cloud:
- Go to the IoT Kit here and download the zip file to your computer.
- From the Arduino IDE, select Sketch -> Import Library -> Add Library
- Select the IoT zip file recently downloaded. It should be called iokit-samples-master. Double click to open.
- Select Arduino -> IoTkit
- Open another Finder window. Navigate to the Edison IDE libraries folder. If there is no libraries folder, create one with that name.
- Select the IoTkit folder and manually drag it into the Edison IDE libraries folder.
- Restart the Edison IDE to invoke the change. You should see IoTKit under File -> Examples.
Step 13: Now Make!
Now you can use your Intel Edison board to communicate with the Internet of Things in your next project. Have fun!