Send Data to SmartWorks IoT

You need to create a connection between SmartWorks IoT and the object to send the data. This connection can be created from an API. The platform offers access through a REST API to all the resources. It's protected by Oauth protocol allowing you to define fine grained access control according to your use case.

Data must be sent via HTTP or MQTT to SmartWorks IoT. For this project we are using MQTT connection.

MQTT Is the standard for IoT messaging. It allows for messaging between device to cloud and cloud to device. More information on MQTT can be found here:

Client connections are always handled by a MQTT broker, which is responsible for receiving and filtering the messages, determining who is subscribed to each message and sending them. To configure the MQTT broker connection, the Host, Username and Password are the required parameters.

Follow the steps below to connect your device via MQTT.

  1. Open the connect_your_first_device_guide file in your existing code editor. If you need a code editor, you can download one here. If you don't want to install a code editor and/or Python, you can access access Jupyter online. Follow the steps here. See Connect Your First Device for more information.
  2. Follow the first step in the file to import the libraries. Click the arrow icon next to the line import modules.smartworks_sdk as swx to execute the code to import the files.
    Note: If you are using Jupyter online, you will need to restart Kernell.


    Figure 1.
  3. Complete the steps under Computer Metrics.
  4. Connect your device via HTTP:
    1. In SWX Computer Training.ipynb, locate and follow the steps for an HTTP connection.
    2. Execute the code and add the required information as instructed.


      Figure 2.
    3. Required: In AnythingDB, click your Thing and get the Thing ID and Secret ID to authenticate and authorize your entity.


      Figure 3.
    4. Check the data received in the Raw History panel as shown below.


      Figure 4.
  5. Connect a Device via MQTT:
    MQTT Is the standard for IoT messaging. It allows for messaging between device to cloud and cloud to device. Read More information on MQTT: https://mqtt.org/

    Client connections are always handled by a MQTT broker, which is responsible for receiving and filtering the messages, determining who is subscribed to each message and sending them. To configure the MQTT broker connection; Host, Username and Password are the required parameters.

    1. In SWX Computer Training.ipynb, locate and follow the steps for a MQTT broker connection.
    2. Get your username and password by turning ON the autogenerate feature for the platform to autogenerate the username and password .
      Note: You can also create your own username and password, if desired.
    3. Click Save.
    4. Execute the code as instructed in the SWX Computer Training.ipynb file
    5. Check the data received in the Raw History panel as shown below.


      Figure 5.