docwithnav |
|
MQTT Sparkplug API |
Supported MQTT Sparkplug API Reference for IoT Devices |
0 |
1 |
2 |
image |
title |
/images/reference/sparkplug/sparkplug-create-device-profile-1-ce.png |
Navigate to the Device profiles page and click on the "+" icon in the device profile table header to open the Add device profile dialog. Use MQTT EoN Node as profile name or any other meaningful value; |
|
image |
title |
/images/reference/sparkplug/sparkplug-create-device-profile-2-ce.png |
Navigate to Transport configuration tab and select the MQTT transport type. Make sure you have selected the “MQTT Sparkplug B Edge of Network (EoN) node” checkbox. Input the names of Sparkplug metrics you would like to store as attributes instead of time series data. This list should also include metrics you may want to update from the server side and push to the device; |
|
image |
title |
/images/reference/sparkplug/sparkplug-create-device-profile-3-ce.png |
MQTT EoN Node have been created. |
|
|
0 |
1 |
image |
title |
/images/reference/sparkplug/sparkplug-create-device-1-ce.png |
Navigate to the Devices page and click on the “+” icon in the device table header to open the Add new device dialog. Input your EoN node device name (e.g. Node 1) and select the existing device profile: MQTT EoN Node. Click Add; |
|
image |
title |
/images/reference/sparkplug/sparkplug-create-device-3-ce.png |
Navigate to the manage credentials and copy the access token. We will use it in the next step. Note that you may use other types of credentials as well. |
|
|
0 |
1 |
image |
title |
/images/reference/sparkplug/sparkplug-device-latest-telemetry-1-ce.png |
Navigate to the details of the EoN node device and open the Latest telemetry tab. You should see the device metrics, for example Current Grid Voltage; |
|
image |
title |
/images/reference/sparkplug/sparkplug-device-shared-attribute-1-ce.png |
Navigate to the Attributes tab and select Shared attributes scope. You should see metrics that you have previously configured in the Step 1. |
|
|
0 |
1 |
image |
title |
/images/reference/sparkplug/sparkplug-created-two-devices-1-ce.png |
Navigate to the Devices table and note that two new Sparkplug devices are created by the emulator: "Sparkplug Device 1" and "Sparkplug Device 2"; |
|
image |
title |
/images/reference/sparkplug/sparkplug-created-two-devices-2-ce.png |
Both devices have their own attributes and telemetry values that are generated by the emulator. |
|
|
0 |
image |
title |
/images/reference/sparkplug/sparkplug-edit-device-profile-1-ce.png |
Go to the Profiles -> Device profiles and select MQTT EoN Node device profile. In the Transport сonfiguration tab, add a new Sparkplug metric name — “Outputs/*". |
|
|
0 |
image |
title |
/images/reference/sparkplug/sparkplug-new-attributes-1-ce.png |
Go back to the Devices page and select the Sparkplug Device 1. On the Shared attributes tab, you will see two new attributes: “Outputs/LEDs/Green” with the value “true” and “Outputs/LEDs/Yellow” with the value “false”. These are metrics that are saved as attributes, and we can modify them and send values to the device. |
|
|
0 |
image |
title |
/images/reference/sparkplug/sparkplug-edit-attribute-1-ce.png |
Click on the “pencil” icon and change the value of the attribute “Outputs/LEDs/Green” from “true” to “false” by unchecking the corresponding box. Then, click Update. |
|
|
0 |
image |
title |
/images/reference/sparkplug/sparkplug-edit-attribute-2-ce.png |
Now let’s change the value of the “Device Control/Scan Rate” attribute. Click on the “pencil” icon and change the value from “60000” to “30000”. Click Update. |
|
|
0 |
image |
title |
/images/reference/sparkplug/sparkplug-edit-attribute-3-ce.png |
The new attribute values for "Outputs/LEDs/Green" and "Device Control/Scan Rate" have been successfully sent to the device. |
|
|
0 |
1 |
image |
title |
/images/reference/sparkplug/sparkplug-create-new-dashboard-1-ce.png |
Go to the Dashboard page and create a new dashboard named Sparkplug; |
|
image |
title |
/images/reference/sparkplug/sparkplug-create-new-dashboard-2-ce.png |
Open the dashboard and add an alias by clicking on Entity Aliases icon on the top-right. Name the alias (EoN Node, for example), select filter type “Single Entity”, type “Device” and choose our Node 1. Press Add and then Save. |
|
|
0 |
1 |
2 |
3 |
4 |
5 |
image |
title |
/images/reference/sparkplug/sparkplug-create-new-dashboard-3-ce.png |
Click "Add New Widget"; |
|
image |
title |
/images/reference/sparkplug/sparkplug-create-new-dashboard-4-ce.png |
Select "Control widgets" from drop down menu; |
|
image |
title |
/images/reference/sparkplug/sparkplug-create-new-dashboard-5-ce.png |
Select "RPC Button" widget; |
|
image |
title |
/images/reference/sparkplug/sparkplug-create-new-dashboard-6-ce.png |
On the Data field select created alias; |
|
image |
title |
/images/reference/sparkplug/sparkplug-create-new-dashboard-7-ce.png |
Go to "Advanced" tab and enter button label. In the RPC settings enter "RPC method" (command to the EoN Node) and "RPC method params". Click Add; |
|
image |
title |
/images/reference/sparkplug/sparkplug-create-new-dashboard-8-ce.png |
Save changes. |
|
|
0 |
image |
title |
/images/reference/sparkplug/sparkplug-create-new-dashboard-9-ce.png |
Click "REBOOT NODE" button on the widget. In the Terminal, you will see a message indicating that the RPC command has been sent to the device and the Sparkplug EoN Node 1 has been rebooted. |
|
|