MediaTek LinkIt ONE

_images/linkitone-overview.png

Setup MediaTek LinkIt ONE

After you open the box, follow the step-by-step guide on MediaTek’s website to setup your new device and environment. It can be found here:

Once complete, come back to this website and continue to the next section.

IMPORTANT: Before moving on to the next step, copy your AWS IoT certificate, private key and root certificate to the root directory of your MediaTek LinkIt One device. To do this, simply change your device to mass storage mode and copy the files directly.

Assemble the Connected Maraca

What will the Connected Maraca do?

Your “Connected Maraca” is a 3-axis accelerometer connected to your MediaTek LinkIt One Device that detects shaking. When you shake the 3-axis accelerometer, data will be published to your AWS IoT device gateway.

Note

For more detailed descriptions of all of the components in the Grove Kit, check out the - Grove Starter Kit

Connect all of the components

Once you have all of the components, attach the Grove base shield to the LinkIt ONE Arduino board. You will be connecting the various Grove Kit components to the base shield. When that is complete, follow these steps:

  1. Grove 3-Axis Accelerometer to any bottom I2C port

Run the Connected Maraca

In this section, we will build the connected maraca using the Arduino IDE.

First, you will need to download the AWS/MediaTek LinkIt ONE Connected Maraca Sample Code:

Note

IMPORTANT: As a temporary workaround, you will need to replace platform.txt in the following locations with the platform.txt file included in the zip archive above:

Arduino 1.5.7: /Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/mtk/platform.txt

Arduino 1.6.5: /Users/{YOUR_USERNAME}/Library/Arduino15/packages/LinkIt/hardware/arm/1.1.17/platform.txt

Open the Connected Maraca sketch and upload it to your MediaTek LinkIt ONE.

Note

Ensure that you have selected the right Board and Port in the Tools menu before continuing. The board should be LinkIt ONE, and the port should be in the format of COMX in Windows, or cu.usbmodem.XXYY on a Mac.

Follow these steps:

  1. Unzip the Maraca Sample file above.

  2. Open Arduino IDE.

  3. There are three libraries (folders) in the unzipped folder to import into the Arduino IDE: three_axis_accel, aws_iot_library and mbedtls. To import them, click Sketch > Import Library > Add Library.

    _images/arduino-add-library.png
  4. Change your Mediatek Board to Mass Storage Mode and reconnect it to your computer. Your device will now show up as a connected storage volume. Open the volume and copy your Root Certificate, AWS IoT Certificate and AWS IoT Private Key to the root directory.

  5. Open the folder src and double click the connected-maraca-iot.ino file.

    /* change AWS IoT settings here */
    /* To find the IP address, run aws iot describe-endpoint --region YOUR_REGION, followed by ping YOUR_AWS_ENDPOINT */
    VMSTR IP_ADDRESS = "<IP_ADDRESS_OF_IOT_ENDPOINT_FROM_PING_COMMAND>"; //currently only support IP address
    VMINT PORT = 8883;
    char cafileName[] = "<ROOT_CERTIFICATE_NAME>";
    char clientCRTName[] = "<CERTIFICATE_NAME>";
    char clientKeyName[] = "<PRIVATE_KEY_NAME>";
    char topicName[] = "connected-maraca";
    char deviceId[] = "<DEVICE_ID>";
    char HostAddress[255] = "<ENDPOINT_URL>";
    
  6. In the variables cafileName, clientCRTName and clientKeyName, replace with the file names of the root certificate, your AWS IoT certificate and your AWS IoT private key. This is a relative path to the MediaTek LinkIt One root directory, so you can just type in the filename. Ex: “root-ca.pem.crt”.

    Note

    Ensure that you have uploaded your keys to the LinkIt ONE root directory. To do this, change your LinkIt One to Mass Storage mode and copy using Windows Explorer or Finder.

  7. In the variable deviceId, type in the device ID you defined in your cloudformation template. This will be the name of the MQTT client that is created.

  8. Run a ping <YOUR_ENDPOINT> in the command line of your computer (Terminal in a mac, Command Prompt on Windows) and get the IP address. Change the variable VMSTR IP_ADDRESS to map to this IP address.

  9. Press Verify, and then Upload. They are icons in the top left corner of the IDE window.

    _images/arduino-verify.png _images/arduino-upload.png
  10. This will upload and start the application on your MediaTek LinkIt ONE.

View the output on the Serial Monitor

You can monitor the output in real-time by clicking Tools > Serial Monitor.

Congratulations! You are now sending data to the cloud from MediaTek LinkIt ONE using Arduino.