Demonstration: Ingest Data for a Directly Connected Device

We demonstrate creating a machine and ingesting IoT data for the machine sensor attributes using HTTPS.

  1. Create the machine type.


    Machine Type Editor with Sensor Attributes

    We create a machine type, MoldingMachine with sensor attributes for temperature and humidity.

  2. Create a machine for the machine type, and set the data source for the sensor attributes to Direct.


    Machine Editor

    We create a machine, MoldingMachine1 for the machine type, and set the Data Source value for the sensor attributes Temp and Humidity to Direct.

  3. Set the Direct Data Source Options for the machine in the Machine Editor.


    Menu: Data Source Options


    Sensor1 Data Source Options

    As this is a directly connected device, we choose the Direct under Data Source. We specify an external ID, sensor1. The External ID is used as the Client ID when the molding machine sends data to the IoT server. We set the authentication method to use Client ID/Secret and specify a secure secret password. As we do not need a custom schema, we leave the payload set to the default schema.

  4. Generate a sample schema for the machine from the Machine Inventory page.


    Machine Inventory Page: Generate Sample Schema


    Sample Payload Schema

    We choose a JSON schema and the HTTPS (POST) protocol. We choose to generate a sample payload for all the machine sensor attributes. The entity ID is included in the endpoint here, but you could also choose to include it as part of payload. We generate a sample schema for a single measurement.

    The payload contains sample values for the sensor attributes. Note that the sensor attribute IDs that appear in the payload can be traced to their respective sensor names in the machine editor.

    When sending data, say using a REST client or curl command, copy the host, endpoint, and payload from the Sample Schema dialog. Replace MyEntityID in the host URL with the external ID for the machine (sensor1). Use the external ID/client ID as the user name and the secret, set earlier, to authenticate. Edit the payload, as required.

  5. Send data using a REST client.


    Host and Authentication

    We use the host copied from the sample schema dialog for the POST request. We replace MyEntityID in the host URL with the external ID for the machine: sensor1.We use the client ID and secret values specified in the Direct Data Source Options dialog, as the user name and password in the REST client.


    Edited JSON sample

    We copy and edit the sample payload from the Direct Data Source Options dialog, and use it as the data for the POST request.

    The following shows a sample curl command for the POST request:

    curl --request POST \
      --url https://iothost.oraclecloud.com/direct/v1/schema/entities/sensor1/json \
      --header 'Authorization: Basic c2Vuc29yMTpTZW5zb3IxMjM=' \
      --header 'Content-Type: application/json' \
      --data '{
        "4MF3YJM82MA0": 80,
        "sys_eventTime": 1659683377320,
        "4MF3YJM42MA0": 32
    }'

    You may choose to use the curl command directly in place of a REST client.

  6. Verify that the sent data appears in Operations Center.


    Received data in Operations Center