AWS IoT Connector

Content Type: Module
Categories: AWS

Overview

This connector enables you to quickly connect to IoT things and data on AWS. The connector contains microflow actions to interact with AWS IoT.

Things:

* Get things registered in AWS IoT

* Get thing descriptions

Data:

* Get shadow status

* Update shadow

* Send update MQTT message

* Subscribe to MQTT topic

* Unsubscribe from MQTT topic

Documentation

If your use case requires only MQTT, please use MQTT Connector

 

AWS IoT

1 Introduction

The AWS IoT connector enables easily connecting to IoT devices and data on AWS IoT.

1.1 Typical Use Cases

The connector consists of microflow actions that enable doing the following:

  • Determining devices connected to AWS IoT
  • Getting and setting the shadow of devices connected to AWS IoT through the REST API or MQTT messages

1.2 Dependencies

This connector uses source code from the following projects:

2 Configuration

The microflow actions need AWS credentials. Most use an AWS access key ID and an AWS secret access key.

For the MQTT actions you need to provide the certificates as provided by AWS IoT. These should be stored in the resources folder of your Mendix app:

2.1 Things

To get a list of all the things registered at AWS IoT, you can use Things - get list action:

This returns a JSON document as provided by AWS IoT. Then you can use a JSON import mapping to create entities from the JSON that is returned.

Input/OutputItemValue
InputAwsAccessKeyID$AwsAccounts/AwsAcessKeyId
InputAwsSecretAccessKey$AwsAccounts/AwsSecretAccessKey
InputRegion$AwsAccounts/DefaultRegion
InputAttributeName‘IsPlanePart’
InputAttributeValue‘True’
OutputReturn typeString
OutputUse return valueYes
OutputVariable nameThingsJson

To get the details of a device, you can use the Thing - describe action:

2.2 State

AWS IoT has a shadow of the device state, and it provides a REST API to this shadow. Through this API, you can determine the last known state of a device or request a state change of the device.

To read the last known status of a device, use the Data - get shadow action:

This action needs the endpoint of the REST API. You can copy-paste this from AWS IoT, or you can use the Thing - get endpoint action to determine the endpoint:

To change the status of a device, you can update the shadow using the Data - change shadow action:

2.3 Messages

In addition to the REST API, you can work with the state of devices through MQTT messages.

To receive messages from devices, you need to subscribe to the required topic using the Data - subscribe to MQTT topic action:

Typically, you should do this when your Mendix app is started.

To subscribe, you need to provide the certificate information as provided by AWS IoT:

Input/OutputNameArgument
InputBrokerHost‘A25N18ZOH23GJB.iot.us-west-2.amazonaws.com’
InputBrokerPort8883
InputTimeout60
InputTopicName‘mx/things/alerts’
InputOnMessageMicroflow‘TestMxAwsIoT.OnMessageMicroflow’
InputCA‘certs/VeriSign-Class 3-Public-Primary-Certification-Authority-G5.pem’
InputClientCerticate‘certs/2d3ea874d8-certificate.pem.crt’
InputClientKey‘certs/2d3ea874d8-private.pem.crt’
InputCertificatePassword‘password’
OutputReturn typeBoolean
OutputUse return valueYes
OutputVariable nameSubscribeResult

When a message is received, the microflow you specify is called using the topic and payload string parameters. The payload contains a JSON document that you can import using JSON import mappings. The format of this message depends on the data sent by the device.

To publish a message on an MQTT topic, you can use the Data - publish MQTT message action:

When configuring this action, you also need the certificates provided by AWS IoT:

Input/OutputNameArgument
InputBrokerHost‘A25N18ZOH23GJB.iot.us-west-2.amazonaws.com’
InputBrokerPort8883
InputTopicName‘mx/things/alerts’
InputPayload‘{“something”:True}’
InputCA‘certs/VeriSign-Class 3-Public-Primary-Certification-Authority-G5.pem’
InputClientCerticate‘certs/2d3ea874d8-certificate.pem.crt’
InputClientKey‘certs/2d3ea874d8-private.pem.crt’
InputCertificatePassword‘password’
OutputReturn typeBoolean
OutputUse return valueYes
OutputVariable namePublishResult

Releases

Version: 5.0.1
Framework Version: 7.23.19
Release Notes: * Bug fixes
Version: 5.0.0
Framework Version: 7.23.19
Release Notes: * New microflow activity to subscribe with a client id * Upgrade to Mendix 7.23.19
Version: 4.1.0
Framework Version: 7.20.1
Release Notes: Contains fixes to reduce likelyhood of parameter conflicts
Version: 4.0.0
Framework Version: 7.20.1
Release Notes: Updated client ID information, upgraded to 7.20.1 and updated parameter to accept microflows.
Version: 3.0.2
Framework Version: null
Release Notes: * Fixed MQTT topic with $ sign subscriptions