|Note: This documentation refers to Gravio 3.8 or older. For Gravio 4 or newer, please refer to the respective documentation on doc.gravio.com .|
The MQTT Publish Action Component allows you to publish messages to topics within an MQTT PubSub system.
Here is an example of how to publish messages to a Google Cloud MQTT System:
Navigate to your Google Cloud console and create a project:
Navigate to Google Cloud Platform IoT Core
Enable the Google IoT Core API.
Create a Device Registry
Enter the name of your registry, select the region and add the topics (here
states for example):
Click on “Add Device” in this screen:
And you will see:
Create a certificate that you can paste into the field by entering this command in your command line:
openssl req -x509 -newkey rsa:2048 -keyout rsa_private.pem -nodes -out rsa_cert.pem -subj "/CN=unused"
This will create a file
rsa_private.pem and a file called
Copy the contents of the
rsa_cert.pem file into the window:
We’re now ready to take on messages from Gravio.
Note: The MQTT Publish component will take the variables as payload and make one MQTT publish per variable. And if you use JSON or CSV the variable name will be the key/column.
Typically you can use the CreateRecord component to inject a variable into the MQTTPublish component.
(The documentation how to retrieve MQTT messages in Gravio is currently still TBC and being written – please come back in a few days.)
Sending Sensor Data to a MQTT Broker
You can any sensor data to a MQTT broker. In order to do that, you need to fill out the variables into the respective variables using the “Create Record” component. This component will take the sensor data and turns it into output variables, that can be used in the next step with the prefix
This is required because the MQTT component needs input, and you may want to change the naming of the JSON keys. The variables to read initially are prefixed with
av (for Action Variable).
The setup looks something like this: