Sending Data to Device Cloud from Your Device in Linux

You can run the iot-simple-telemetry.py application to send data from your device to Device Cloud.

The application you run to send data has its own thing definition and uses a unique application token that corresponds to the thing definition. Therefore, as part of this procedure, you need to generate a new, application-specific connection configuration file that contains the matching application token. This procedure assumes that the application and thing definition for the sample application were already defined in Device Cloud or you added them before you generated the device manager configuration file.

You need the following:

  1. Generate the connection configuration file for the sample application as follows:
    1. Log in to the Management Portal, click Developer, and then click Applications.
    2. To copy the application token to the clipboard, click the Copy icon on the right side in the hdc_simple_telemetry_app row.
    3. In a terminal window, run the program to generate the configuration file and specify the required information.

      For telemetryAppToken, paste the token you copied from the Applications page.

      For endPoint, specify the endpoint on the Developer page on the Management Portal.

      $ cd yourLocalDir/device_cloud 
      $ python generate_config.py -f iot-simple-telemetry-py-connect.cfg -c endPoint -p 8883 -t telemetryAppToken
      

    The iot-simple-telemetry-py-connect.cfg file is created in the yourLocalDir/device_cloud directory and contains the configuration information required to connect the sample application to Device Cloud.

  2. Run the sample application and specify the location and name of the configuration file generated in the previous step.
    $ cd yourLocalDir/device_cloud/demo
    ./iot-simple-telemetry.py -c yourLocalDir/device_cloud -f iot-simple-telemetry-py-connect.cfg

    The sample application starts and connects to Device Cloud.

    Because you specified the same configuration directory as the device manager (yourLocalDir/device_cloud), it uses the same device_id file to construct the thing key of the sample application.

  3. Copy the value from the device_id file to the clipboard.
  4. On the Management Portal, click Things.
  5. In the Search things text box, type key:", paste the value from the device_id file into the box, type ", and then press ENTER.

    The entry in the text box should look something like key:"4321da91-6dc2-4a8d-b087-a6186fe0c0c3".

    Note:

    You must enclose the key value in quotes.

    The Things page shows only things with thing keys that contain your device id.

  6. From the list that appears, click the View icon of the iot-simple-telemetry-py thing.

    The thing name should look something like auto:4321da91-6dc2-4a8d-b087-a6186fe0c0c3-iot-simple-telemetry-py.

  7. On the thing page, select the Method tab, and then click Toggle Telemetry.
  8. In the Toggle Telemetry window, click Execute.

    The output shows Turned on and the sample application begins sending data.

  9. Close the window and then reload the thing page.

    The Properties section shows data in graph format. You may need to wait a moment for data values to appear in the graph. If necessary, reload the page again.

    Device Cloud - Quick Start Sending Data Graphs
  10. To see more details about individual properties, including the data in table format, click the property name, for example property-1 in the example above.

    For more information about viewing property details, see Device Cloud Management Portal User's Guide: Viewing the Properties of a Thing.