Learn how to use AWS IoT SDK with LinkIt Smart 7688 and Duo development boards. AWS IoT is a managed cloud service on AWS cloud.
You can use AWS IoT SDK to write programs running on LinkIt Smart 7688 and Duo development boards connected to the AWS IoT. It provides 3 different SDKs and their platform compatibility is shown below:
|SDK binding||Compatible with|
|Arduino Yun SDK||LinkIt Smart 7688 Duo only|
|Embedded C||LinkIt Smart 7688, LinkIt Smart 7688 Duo. Requires a computer running OS X and Linux for cross compilation.|
To run the SDK examples you'll need an AWS account and optionally AWS CLI (Command Line Interface).
- Use an SD card for an additional storage space, see Mounting the root FS on an SD card. AWS CLI and SDK consume considerable amount of disk space.
- Sign up for an AWS account.
- Install AWS CLI. You can install the CLI on LinkIt Smart 7688 development board directly with pip install awscli or use your PC to install it.
- Copy the certificates, private key and root-CA files to LinkIt Smart 7688 development board under ~/certs directory. Follow the instructions here to copy the files.
Simply follow the NPM installation steps:
npm install aws-iot-device-sdk
Note that there will be two missing optional dependencies email@example.com and firstname.lastname@example.org that can be ignored.
Make sure you have copied proper certification files to ~/certs directory before running the examples.
Then you should be able to run the examples from the SDK:
node examples/thing-example.js -f ~/certs --test-mode=1 node examples/thing-example.js -f ~/certs --test-mode=2
AWS IoT Arduino Yun SDK
AWS IoT Arduino Yun SDK is not compatible with LinkIt Smart 7688 development board. You'll need LinkIt Smart 7688 Duo development board to run this SDK.
- Enable the Yun bridge so that the LinkIt Smart 7688 Duo development board will act as a Yun device.
- Connect the board to the same network as your computer. Make sure it has access to the internet.
- Use your AWS IoT Console, click Connect a device to generate certification files, as shown below. Download and store the certification files to your computer.
- Copy the resulting configuration text, as shown below.
- Download the root CA file and rename it to root-CA.crt.
- Follow the SDK instructions to extract the SDK files to your computer and install the libraries and examples in the Arduino IDE.
- You need to place the certification files from Step 3 according to the instructions.
- The instructions will ask you to fill [your_boards_ip], you can use mylinkit.local as the board address.
- Before you run the examples, you'll need to paste the code from Step 4 to the aws_iot_config.h in each example project.
AWS IoT Embedded-C SDK
You'll need a computer running OS X or Ubuntu Linux. The setup requires cross compilation toolchain to use the AWS IoT embedded-C SDK.
Build and run an example application
To build an example application.
- Download and setup the cross-compilation tools (OpenWrt SDK) from 下載. Make sure you can successfully build and deploy a helloworld example application.
- Locate the path to the cross compilation toolchain. If you extract the OpenWrt SDK in path WRT_SDK, the toolchain is in
- Download the AWS IoT Embedded-C SDK from source. There are two versions; in this example the mbedTLS from ARM version is used.
- Extract the downloaded AWS IoT SDK, under the path, such as AWS_SDK.
- Use your AWS IoT Console, click Connect a device to generate certification files. Download and store the certification files under AWS_SDK/certs directory.
- Navigate the the subscribe_publish_sample sample application directory:
Copy the resulting configuration text to aws_iot_config.h, it will look similar to this:
// Get from console // ================================================= #define AWS_IOT_MQTT_HOST "A1XY4MZO1406ZZ.iot.us-west-2.amazonaws.com" #define AWS_IOT_MQTT_PORT 8883 #define AWS_IOT_MQTT_CLIENT_ID "linkit_device" #define AWS_IOT_MY_THING_NAME "linkit_device" #define AWS_IOT_ROOT_CA_FILENAME "root-CA.crt" #define AWS_IOT_CERTIFICATE_FILENAME "b77f46f13c-certificate.pem.crt" #define AWS_IOT_PRIVATE_KEY_FILENAME "b77f46f13c-private.pem.key" // =================================================
Modify the Makefile of the sample application. Open the Makefile and find the following line at the beginning of the file:
CC = gcc
remove the line and modify it to use the cross compilation toolchain:
export STAGING_DIR = WRT_SDK/staging_dir/ CROSS_COMPILE = WRT_SDK/staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mipsel-openwrt-linux-uclibc- export CC = $(CROSS_COMPILE)gcc export AR = $(CROSS_COMPILE)ar export LD = $(CROSS_COMPILE)ld export RANLIB = $(CROSS_COMPILE)ranlib
- Type make to start building the sample application. It'll build an executable file subscribe_publish_sample.
Make sure the board is connected to the internet and is in the same network as your computer. Copy the certification files and the sample application to the board:
ssh email@example.com 'mkdir -p ~/aws_sdk/certs' ssh firstname.lastname@example.org 'mkdir -p ~/aws_sdk/sample_apps/subscribe_publish_sample' scp -r AWS_SDK/certs/* email@example.com:~/aws_sdk/certs scp -r AWS_SDK/sample_apps/subscribe_publish_sample/subscribe_publish_sample firstname.lastname@example.org:~/aws_sdk/sample_apps/subscribe_publish_sample
Execute the sample application on the board. Sign into the console:
Run the example:
cd ~/aws_sdk/sample_apps/subscribe_publish_sample ./subscribe_publish_sample
You should see the following log printed continuously:
Subscribing... -->sleep -->sleep Subscribe callback sdkTest/sub hello from SDK : 0 -->sleep Subscribe callback sdkTest/sub hello from SDK : 1 -->sleep Subscribe callback sdkTest/sub hello from SDK : 2 -->sleep Subscribe callback sdkTest/sub hello from SDK : 3 -->sleep Subscribe callback sdkTest/sub hello from SDK : 4 -->sleep
Type ctrl-c to stop the execution.
You can build other examples or your own applications a similar way. You need to modify the Makefile and aws_iot_config.h for each application as described in Step 7 and 8.