I was one of the proud winners to receive the Intel IoT development kit. This kit included an Intel Edison and a Grove Starter Kit Plus.
In this instructables, I will build a simple ambient sensor which will upload the data to the cloud. The Ambient sensor consists of three sensors: sound, temperature and light. The sensors send updates of their value to the cloud. The system can be powered off and back on without the need to reconfigure the cloud settings (device-id problem). It automatically sets the device-id to the your default one and restarts the service which is required to upload data.
If there are errors in this instructable or if you have suggestions, please contact me asap. If I made spelling/grammatical errors, please excuse me for this.
Step 1: Step 1: What You'll Need
- Grove Starter Kit: Temperature sensor v1.1.
- Grove Starter Kit: Sound sensor v1.4.
- Grove Starter Kit: Light sensor v1.0.
- Grove Starter Kit: Button v1.0.
- Grove Starter Kit: LCD RGB Backlight v2.0.
This instructable assumes you've installed every other necessary software and flashed your Intel Edison. If this is not the case, please follow this link. The link leads to the Intel website were they explain it very well.
Step 2: Step 2: Configuring the Intel Edison
Use your favorite terminal, I use putty like almost everyone else. Select "Serial". In the "Serial Line" text box enter the correct COM port which you can find using your device manager. Look for "Intel Edison Virtual Com Port (COMX)" the COMX is the COM port which you'll need to enter in the text box, for me it's COM4. In the "Speed" textbox enter "115200" this is the bit rate, 115200 bits/s.
Let's configure it, you don't need to reconfigure your device! Only do this if you want to be sure your device is configured the same as my device in this instructable:
- Hit the enter-key 2 times.
- Type root.
- Optional: enter your password if prompted.
- We'll start with a fresh config. Type reboot ota
- Type root.
- Type configure_edison --setup
- Optional: change the DeviceName of your device.
- Optional: set a Device Password for your device.
- Type Y, to configure your wifi
- The Intel Edison is scanning all the local wifi spots. This takes a few seconds.
- Type the number corresponding to your wifi network. Confirm by typing y.
- Enter the network password if prompted.
- The device will try to connect with your wifi network, if it's connected successful you'll get such a message: "Done. Please connect your laptop or PC to the same network as this device and go to http://192.168.0.186 or http://192.168.0.186 in your browser."
- Open your browser and type in the address bar the given address, in my example: 192.168.0.189 and check if it opens a webpage.
Above is the basic configuration which you already did when receiving your device. We'll continue with configuring the cloud part.
- First let's verify we can actually communicate with the cloud: type iotkit-admin test. This should give positive feedback. To which it's connected, the environment and build number.
- Now we need to know the Device ID. Type iotkit-admin device-id. This should give an ID that looks a bit like this XX-XX-XX-XX-XX-XX. One of the things I noticed is the device ID changes when the device is restarted. We'll fix this later on.
- Now let's go to to the IoT Analytics Dashboard. Login and add a new device. Type the Device ID in the "ID" box and also in the "gateway" box. Type the Device Name in the "name" box.
- Go to the "Account" tab, generate a new Activation Code if needed. Copy this code.
- Now go back to your terminal and type iotkit-admin activate Code. Replace Code with your personal Activation Code.
Your device is registered and activated to your account. Let's continue...
Step 3: Step 3: Register the Sensors
Now it's time to register our sensors to our Intel Edison. I will not register them using a terminal. I'm going to register them in my Arduino code. I assume you have correctly installed the iotkit library, you should be able to view the examples. I'm using code lines from the IoTkitRegisterExample sketch.
First of all you can find all the possible components in your Catalog which you can find on your IoT Analytics Dashboard. There are standard three sensors already registered:
- humidity humidity.v1.0
- powerswitch powerswitch.v1.0
- temperature temperature.v1.0
We're going to make two additional sensors: the sound and light sensor.
- Click on Add a New Catalog Item
- Give your sensor a name and type this in the Component Name box.
- Select a Type: Sensor or Actuator, in our case Sensor.
- Select a Data type, we can pick Number.
- Select a Format, pick Integer or Double if you want decimals (for example the temperature sensor).
- Select a Display, there's only one option so pick Timer Series.
- Type a Unit of measure, for examples Celcius.
- Optional: set min and max values.
You can review the sensors on the Catalog tabs. Or you can use the terminal and type iotkit-admin catalog this should bring up a table of all the sensors. Bellow you can find the IoTkitRegisterExample sketch. It's very well commented so read carefully and apply the changes. You'll have to replace YOUR_DEVICE_ID with your Device ID. Also, you'll have to replace the XXXXXXXX with your generated Activation code. Edit the register sensor part to meet your used sensors. Upload this modified sketch to your Arduino.
Step 4: Step 4: Final Code
Attach the Grove Starter Kit Base Shield to your Intel Edison. Attach the sensors, display, button using the cables to the Base Shield:
- A0: Grove Starter Kit: Sound sensor v1.4.
- A1: Grove Starter Kit: Temperature sensor v1.1.
- A2: Grove Starter Kit: Light sensor v1.0.
- D3: Grove Starter Kit: Button v1.0.
- I2C: Grove Starter Kit: LCD RGB Backlight v2.0.
Bellow you can download the code. The code is actually composed of different examples which were shipped with Grove Starter Kit and the IoTkit library. Don't forget to replace YOUR_DEVICE_ID with your device ID.
The data is updated every 2 seconds. The button is used to switch between the different information on your LCD screen. I used a little "hack" to make sure my device ID doesn't change from the original by setting it to the original value used to register and activate my device.
If you've got any questions, PM me or comment bellow.